diff --git a/OpenRa.Game/Game.cs b/OpenRa.Game/Game.cs index 58bacad185..a9e6f4d2c0 100644 --- a/OpenRa.Game/Game.cs +++ b/OpenRa.Game/Game.cs @@ -23,7 +23,7 @@ namespace OpenRa.Game public readonly WorldRenderer worldRenderer; public readonly Controller controller; - int localPlayerIndex = 2; + int localPlayerIndex = 0; public readonly Dictionary players = new Dictionary(); diff --git a/OpenRa.Game/Graphics/OverlayRenderer.cs b/OpenRa.Game/Graphics/OverlayRenderer.cs index a662bbf000..885d1f2a92 100755 --- a/OpenRa.Game/Graphics/OverlayRenderer.cs +++ b/OpenRa.Game/Graphics/OverlayRenderer.cs @@ -60,24 +60,21 @@ namespace OpenRa.Game.Graphics public void Draw() { for( int y = 0 ; y < 128 ; y++ ) - { - for( int x = 0 ; x < 128 ; x++ ) + for (int x = 0; x < 128; x++) { - if( map.MapTiles[ x, y ].overlay < overlaySprites.Length ) + var o = map.MapTiles[x, y].overlay; + if (o < overlaySprites.Length) { - var location = new int2( x, y ); - var sprites = overlaySprites[ map.MapTiles[ x, y ].overlay ]; + var location = new int2(x, y); + var sprites = overlaySprites[o]; var spriteIndex = 0; - if( overlayIsFence[ map.MapTiles[ x, y ].overlay ] ) - spriteIndex = NearbyFences( x, y ); - else if( overlayIsOre[ map.MapTiles[ x, y ].overlay ] ) - spriteIndex = 11; - else if( overlayIsGems[ map.MapTiles[ x, y ].overlay ] ) - spriteIndex = 2; - spriteRenderer.DrawSprite( sprites[ spriteIndex ], Game.CellSize * (float2)( location - map.Offset ), 0 ); + if (overlayIsFence[o]) spriteIndex = NearbyFences(x, y); + else if (overlayIsOre[o]) spriteIndex = 11; + else if (overlayIsGems[o]) spriteIndex = 2; + spriteRenderer.DrawSprite(sprites[spriteIndex], + Game.CellSize * (float2)(location - map.Offset), 0); } } - } spriteRenderer.Flush(); } diff --git a/OpenRa.Game/Graphics/WorldRenderer.cs b/OpenRa.Game/Graphics/WorldRenderer.cs index a5b7e5c942..edf24521ff 100644 --- a/OpenRa.Game/Graphics/WorldRenderer.cs +++ b/OpenRa.Game/Graphics/WorldRenderer.cs @@ -76,18 +76,21 @@ namespace OpenRa.Game.Graphics lineRenderer.DrawLine(a, a + c, Color.White, Color.White); foreach (var u in game.FindUnits(selbox.Value.First, selbox.Value.Second)) - DrawSelectionBox(u, Color.Yellow); + DrawSelectionBox(u, Color.Yellow, false); } 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 */ - DrawSelectionBox(a, Color.White); + DrawSelectionBox(a, Color.White, true); lineRenderer.Flush(); } - void DrawSelectionBox(Actor selectedUnit, Color c) + const float conditionYellow = 0.5f; /* todo: get these from gamerules */ + const float conditionRed = 0.25f; + + void DrawSelectionBox(Actor selectedUnit, Color c, bool drawHealthBar) { var center = selectedUnit.CenterLocation; var size = selectedUnit.SelectedSize; @@ -105,7 +108,25 @@ namespace OpenRa.Game.Graphics lineRenderer.DrawLine(xY, xY + new float2(4, 0), c, c); lineRenderer.DrawLine(xY, xY + new float2(0, -4), c, c); lineRenderer.DrawLine(XY, XY + new float2(-4, 0), c, c); - lineRenderer.DrawLine(XY, XY + new float2(0, -4), c, c); + lineRenderer.DrawLine(XY, XY + new float2(0, -4), c, c); + + 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); + + var healthAmount = 0.6f; + var healthColor = (healthAmount < conditionRed) ? Color.Red + : (healthAmount < conditionYellow) ? Color.Yellow + : Color.LimeGreen; + + lineRenderer.DrawLine(xy + new float2(0, -3), + float2.Lerp(xy, Xy, healthAmount) + new float2(0, -3), + healthColor, healthColor); + } } } }