This commit is contained in:
Chris Forbes
2009-10-21 20:37:38 +13:00
parent cfa56a791d
commit 659c3669e7
2 changed files with 5 additions and 3 deletions

View File

@@ -18,6 +18,7 @@ namespace OpenRa.Game
public int2 Location; public int2 Location;
public Player Owner; public Player Owner;
public int Health;
public Actor( string name, int2 location, Player owner ) public Actor( string name, int2 location, Player owner )
{ {
@@ -25,6 +26,7 @@ namespace OpenRa.Game
Location = location; Location = location;
CenterLocation = new float2( 12, 12 ) + Game.CellSize * (float2)Location; CenterLocation = new float2( 12, 12 ) + Game.CellSize * (float2)Location;
Owner = owner; Owner = owner;
Health = unitInfo.Strength; /* todo: handle cases where this is not true! */
if( unitInfo.Traits != null ) if( unitInfo.Traits != null )
{ {

View File

@@ -79,7 +79,7 @@ namespace OpenRa.Game.Graphics
var selection = Game.controller.orderGenerator as UnitOrderGenerator; var selection = Game.controller.orderGenerator as UnitOrderGenerator;
if (selection != null) 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); DrawSelectionBox(a, Color.White, true);
lineRenderer.Flush(); 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);
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 var healthColor = (healthAmount < conditionRed) ? Color.Red
: (healthAmount < conditionYellow) ? Color.Yellow : (healthAmount < conditionYellow) ? Color.Yellow
: Color.LimeGreen; : Color.LimeGreen;