You can now fire selected units with S

This commit is contained in:
Niklas Ulf Anders Cullberg
2012-10-16 16:18:21 +02:00
parent 9df0077257
commit 16f2d57aec
7 changed files with 193 additions and 150 deletions
+3
View File
@@ -127,6 +127,9 @@ namespace DepthsBelow
foreach (var body in Swarm) foreach (var body in Swarm)
body.Update(gameTime); body.Update(gameTime);
foreach (var bullet in Volley)
bullet.Update(gameTime);
TestMonster.Update(gameTime); TestMonster.Update(gameTime);
GUIManager.Update(gameTime); GUIManager.Update(gameTime);
+20 -7
View File
@@ -39,6 +39,7 @@ namespace DepthsBelow
foreach (var unit in core.Squad) foreach (var unit in core.Squad)
{ {
unit.step = 0; unit.step = 0;
unit.Fired = false;
} }
} }
else else
@@ -77,15 +78,27 @@ namespace DepthsBelow
{ {
foreach (var soldier in core.Squad) foreach (var soldier in core.Squad)
{ {
core.Volley.Add(new Shot(core)); if (soldier.Selected == true && soldier.Fired == false)
foreach (var shot in core.Volley)
{ {
if (shot.direction == Vector2.Zero) core.Volley.Add(new Shot(core));
soldier.Fired = true;
foreach (var shot in core.Volley)
{ {
double directionX = Math.Cos(soldier.GetComponent<Component.Transform>().World.Rotation); if (shot.select == false)
double directionY = Math.Sin(soldier.GetComponent<Component.Transform>().World.Rotation); {
shot.direction = new Vector2((float)directionX, (float)directionY); shot.select = true;
shot.X = soldier.X;
shot.Y = soldier.Y;
//shot.Transform.World.X += Grid.TileSize / 2;
//shot.Transform.World.Y += Grid.TileSize / 2;
}
if (shot.direction == Vector2.Zero)
{
double directionX = Math.Cos(soldier.GetComponent<Component.Transform>().World.Rotation);
double directionY = Math.Sin(soldier.GetComponent<Component.Transform>().World.Rotation);
shot.direction = new Vector2((float)directionX, (float)directionY);
shot.Transform.World.Rotation = soldier.Transform.World.Rotation;
}
} }
} }
} }
+10 -1
View File
@@ -13,7 +13,16 @@ namespace DepthsBelow
public Color Color; public Color Color;
public static Point Origin; public static Point Origin;
private bool _selected; //I guess as in "currently doing something" private bool _selected = false; //I guess as in "currently doing something"
public bool select
{
get { return _selected; }
set
{
_selected = value;
}
}
public List<Shot> Volley; public List<Shot> Volley;
+11
View File
@@ -20,6 +20,17 @@ namespace DepthsBelow
private PathFinder.Node lastNode; private PathFinder.Node lastNode;
private PathFinder.Node lastLastNode; private PathFinder.Node lastLastNode;
private bool hasFiredAlready = false;
public bool Fired
{
get { return hasFiredAlready; }
set
{
hasFiredAlready = value;
}
}
public int numberOfSteps = 14; public int numberOfSteps = 14;
public int currentStep = 0; public int currentStep = 0;
@@ -121,7 +121,14 @@
</Compile> </Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="images\Shot.bmp"> <Compile Include="images\Shot2.bmp">
<Name>Shot2</Name>
<Importer>TextureImporter</Importer>
<Processor>TextureProcessor</Processor>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="images\FireBall.PNG">
<Name>Shot</Name> <Name>Shot</Name>
<Importer>TextureImporter</Importer> <Importer>TextureImporter</Importer>
<Processor>TextureProcessor</Processor> <Processor>TextureProcessor</Processor>
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Before

Width:  |  Height:  |  Size: 222 B

After

Width:  |  Height:  |  Size: 222 B