From 24c49ebb8f4f64766a28a5c8e47f3b9bd2319dd4 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 20 Oct 2009 17:46:58 +1300 Subject: [PATCH] better healthbar rendering --- OpenRa.Game/Graphics/WorldRenderer.cs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/OpenRa.Game/Graphics/WorldRenderer.cs b/OpenRa.Game/Graphics/WorldRenderer.cs index edf24521ff..0fe733e982 100644 --- a/OpenRa.Game/Graphics/WorldRenderer.cs +++ b/OpenRa.Game/Graphics/WorldRenderer.cs @@ -113,8 +113,6 @@ namespace OpenRa.Game.Graphics if (drawHealthBar) { c = Color.Gray; - lineRenderer.DrawLine(xy + new float2(0, -4), Xy + new float2(0,-4), c, c); - lineRenderer.DrawLine(xy + new float2(0, -2), Xy + new float2(0, -2), c, c); lineRenderer.DrawLine(xy + new float2(0, -2), xy + new float2(0, -4), c, c); lineRenderer.DrawLine(Xy + new float2(0, -2), Xy + new float2(0, -4), c, c); @@ -123,9 +121,28 @@ namespace OpenRa.Game.Graphics : (healthAmount < conditionYellow) ? Color.Yellow : Color.LimeGreen; + var healthColor2 = Color.FromArgb( + 255, + healthColor.R / 2, + healthColor.G / 2, + healthColor.B / 2); + + var z = float2.Lerp(xy, Xy, healthAmount); + + lineRenderer.DrawLine(z + new float2(0, -4), Xy + new float2(0,-4), c, c); + lineRenderer.DrawLine(z + new float2(0, -2), Xy + new float2(0, -2), c, c); + lineRenderer.DrawLine(xy + new float2(0, -3), - float2.Lerp(xy, Xy, healthAmount) + new float2(0, -3), + z + new float2(0, -3), healthColor, healthColor); + + lineRenderer.DrawLine(xy + new float2(0, -2), + z + new float2(0, -2), + healthColor2, healthColor2); + + lineRenderer.DrawLine(xy + new float2(0, -4), + z + new float2(0, -4), + healthColor2, healthColor2); } } }