healthbars, sortof
This commit is contained in:
@@ -23,7 +23,7 @@ namespace OpenRa.Game
|
|||||||
public readonly WorldRenderer worldRenderer;
|
public readonly WorldRenderer worldRenderer;
|
||||||
public readonly Controller controller;
|
public readonly Controller controller;
|
||||||
|
|
||||||
int localPlayerIndex = 2;
|
int localPlayerIndex = 0;
|
||||||
|
|
||||||
public readonly Dictionary<int, Player> players = new Dictionary<int, Player>();
|
public readonly Dictionary<int, Player> players = new Dictionary<int, Player>();
|
||||||
|
|
||||||
|
|||||||
@@ -60,24 +60,21 @@ namespace OpenRa.Game.Graphics
|
|||||||
public void Draw()
|
public void Draw()
|
||||||
{
|
{
|
||||||
for( int y = 0 ; y < 128 ; y++ )
|
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 location = new int2(x, y);
|
||||||
var sprites = overlaySprites[ map.MapTiles[ x, y ].overlay ];
|
var sprites = overlaySprites[o];
|
||||||
var spriteIndex = 0;
|
var spriteIndex = 0;
|
||||||
if( overlayIsFence[ map.MapTiles[ x, y ].overlay ] )
|
if (overlayIsFence[o]) spriteIndex = NearbyFences(x, y);
|
||||||
spriteIndex = NearbyFences( x, y );
|
else if (overlayIsOre[o]) spriteIndex = 11;
|
||||||
else if( overlayIsOre[ map.MapTiles[ x, y ].overlay ] )
|
else if (overlayIsGems[o]) spriteIndex = 2;
|
||||||
spriteIndex = 11;
|
spriteRenderer.DrawSprite(sprites[spriteIndex],
|
||||||
else if( overlayIsGems[ map.MapTiles[ x, y ].overlay ] )
|
Game.CellSize * (float2)(location - map.Offset), 0);
|
||||||
spriteIndex = 2;
|
|
||||||
spriteRenderer.DrawSprite( sprites[ spriteIndex ], Game.CellSize * (float2)( location - map.Offset ), 0 );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
spriteRenderer.Flush();
|
spriteRenderer.Flush();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,18 +76,21 @@ namespace OpenRa.Game.Graphics
|
|||||||
lineRenderer.DrawLine(a, a + c, Color.White, Color.White);
|
lineRenderer.DrawLine(a, a + c, Color.White, Color.White);
|
||||||
|
|
||||||
foreach (var u in game.FindUnits(selbox.Value.First, selbox.Value.Second))
|
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;
|
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) ) /* make sure we don't grab actors that are dead */
|
||||||
DrawSelectionBox(a, Color.White);
|
DrawSelectionBox(a, Color.White, true);
|
||||||
|
|
||||||
lineRenderer.Flush();
|
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 center = selectedUnit.CenterLocation;
|
||||||
var size = selectedUnit.SelectedSize;
|
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(4, 0), c, c);
|
||||||
lineRenderer.DrawLine(xY, xY + new float2(0, -4), 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(-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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user