From 659c3669e778a130c48cc4223c9771bb0bf10d66 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Wed, 21 Oct 2009 20:37:38 +1300 Subject: [PATCH] health --- OpenRa.Game/Actor.cs | 4 +++- OpenRa.Game/Graphics/WorldRenderer.cs | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/OpenRa.Game/Actor.cs b/OpenRa.Game/Actor.cs index 967c52901d..b66edc8dca 100755 --- a/OpenRa.Game/Actor.cs +++ b/OpenRa.Game/Actor.cs @@ -17,7 +17,8 @@ namespace OpenRa.Game public readonly UnitInfo unitInfo; public int2 Location; - public Player Owner; + public Player Owner; + public int Health; public Actor( string name, int2 location, Player owner ) { @@ -25,6 +26,7 @@ namespace OpenRa.Game Location = location; CenterLocation = new float2( 12, 12 ) + Game.CellSize * (float2)Location; Owner = owner; + Health = unitInfo.Strength; /* todo: handle cases where this is not true! */ if( unitInfo.Traits != null ) { diff --git a/OpenRa.Game/Graphics/WorldRenderer.cs b/OpenRa.Game/Graphics/WorldRenderer.cs index a53b49fcf3..643a84ccf7 100644 --- a/OpenRa.Game/Graphics/WorldRenderer.cs +++ b/OpenRa.Game/Graphics/WorldRenderer.cs @@ -79,7 +79,7 @@ namespace OpenRa.Game.Graphics var selection = Game.controller.orderGenerator as UnitOrderGenerator; if (selection != null) - foreach( var a in Game.world.Actors.Intersect(selection.selection) ) /* make sure we don't grab actors that are dead */ + foreach( var a in Game.world.Actors.Intersect(selection.selection) ) DrawSelectionBox(a, Color.White, true); lineRenderer.Flush(); @@ -114,7 +114,7 @@ namespace OpenRa.Game.Graphics 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); - var healthAmount = 0.6f; + var healthAmount = (float)selectedUnit.Health / selectedUnit.unitInfo.Strength; var healthColor = (healthAmount < conditionRed) ? Color.Red : (healthAmount < conditionYellow) ? Color.Yellow : Color.LimeGreen;