detectors

This commit is contained in:
Chris Forbes
2010-05-19 19:20:31 +12:00
parent a6a1c1aabc
commit 47af8fc8f2
5 changed files with 91 additions and 22 deletions

View File

@@ -341,31 +341,33 @@ namespace OpenRA.Graphics
}
}
public void DrawRangeCircle(Actor selectedUnit)
public void DrawRangeCircle(Color c, int2 location, int range)
{
if (selectedUnit.Owner != world.LocalPlayer)
return;
var range = (int)selectedUnit.GetPrimaryWeapon().Range;
var r2 = range * range;
var c = Color.FromArgb(128, Color.Yellow);
foreach (var t in world.FindTilesInCircle(selectedUnit.Location, range))
foreach (var t in world.FindTilesInCircle(location, range))
{
if ((selectedUnit.Location - t - new int2(-1, 0)).LengthSquared > r2)
if ((location - t - new int2(-1, 0)).LengthSquared > r2)
lineRenderer.DrawLine(Game.CellSize * t, Game.CellSize * (t + new int2(0, 1)),
c,c);
if ((selectedUnit.Location - t - new int2(1, 0)).LengthSquared > r2)
lineRenderer.DrawLine(Game.CellSize * (t + new int2(1,0)), Game.CellSize * (t + new int2(1, 1)),
c,c);
if ((selectedUnit.Location - t - new int2(0,-1)).LengthSquared > r2)
lineRenderer.DrawLine(Game.CellSize * t, Game.CellSize * (t + new int2(1,0)),
c,c);
if ((selectedUnit.Location - t - new int2(0,1)).LengthSquared > r2)
lineRenderer.DrawLine(Game.CellSize * (t + new int2(0,1)), Game.CellSize * (t + new int2(1, 1)),
c,c);
c, c);
if ((location - t - new int2(1, 0)).LengthSquared > r2)
lineRenderer.DrawLine(Game.CellSize * (t + new int2(1, 0)), Game.CellSize * (t + new int2(1, 1)),
c, c);
if ((location - t - new int2(0, -1)).LengthSquared > r2)
lineRenderer.DrawLine(Game.CellSize * t, Game.CellSize * (t + new int2(1, 0)),
c, c);
if ((location - t - new int2(0, 1)).LengthSquared > r2)
lineRenderer.DrawLine(Game.CellSize * (t + new int2(0, 1)), Game.CellSize * (t + new int2(1, 1)),
c, c);
}
}
public void DrawRangeCircle(Actor selectedUnit)
{
if (selectedUnit.Owner == world.LocalPlayer)
DrawRangeCircle(Color.FromArgb(128, Color.Yellow),
selectedUnit.Location,
(int)selectedUnit.GetPrimaryWeapon().Range);
}
}
}