NumberOfSteps, CurrentStep, Enter = Next Turn

Also, added KeyboardInput
This commit is contained in:
Niklas Ulf Anders Cullberg
2012-10-09 15:43:07 +02:00
parent 0c9e99b146
commit 6e3b2f2f94
6 changed files with 191 additions and 122 deletions
+3
View File
@@ -22,6 +22,7 @@ namespace DepthsBelow
public Camera Camera;
public static MouseInput MouseInput;
public static KeyboardInput KeyboardInput;
public List<Soldier> Squad;
public List<SmallEnemy> Swarm;
public static Map Map;
@@ -81,6 +82,7 @@ namespace DepthsBelow
MouseInput = new MouseInput(this);
MouseInput.LoadContent();
KeyboardInput = new KeyboardInput(this);
}
/// <summary>
@@ -105,6 +107,7 @@ namespace DepthsBelow
Camera.Update(gameTime);
MouseInput.Update(gameTime);
KeyboardInput.Update(gameTime);
// Update soldiers in squad
foreach (var soldier in Squad)
@@ -122,6 +122,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Camera.cs" />
<Compile Include="KeyboardInput.cs" />
<Compile Include="Component\PathFinder.cs" />
<Compile Include="Component\Transform.cs" />
<Compile Include="Grid.cs" />
+35
View File
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
namespace DepthsBelow
{
public class KeyboardInput
{
Core core;
public KeyboardInput(Core core)
{
this.core = core;
}
public void Update(GameTime gameTime)
{
KeyboardState ks = Keyboard.GetState();
if (ks.IsKeyDown(Keys.Enter))
{
foreach (var unit in core.Squad)
{
unit.step = 0;
}
}
}
}
}
+23
View File
@@ -20,6 +20,21 @@ namespace DepthsBelow
private PathFinder.Node lastNode;
private PathFinder.Node lastLastNode;
public int numberOfSteps = 14;
public int currentStep = 0;
public int step
{
get
{
return currentStep;
}
set
{
currentStep = value;
}
}
public Soldier(Core core, ref List<Soldier> squad) : base(core)
{
if (Texture == null)
@@ -108,10 +123,18 @@ namespace DepthsBelow
if (Transform.World == nodeWorldPos)
{
if (currentStep < numberOfSteps)
{
currentStep++;
lastLastNode = lastNode;
lastNode = nextNode;
nextNode = GetComponent<PathFinder>().Next();
}
else
{
GetComponent<PathFinder>().Stop();
}
}
}
}
@@ -106,6 +106,13 @@
<Processor>TextureProcessor</Processor>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="images\Enter.bmp">
<Name>Enter</Name>
<Importer>TextureImporter</Importer>
<Processor>TextureProcessor</Processor>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Binary file not shown.

After

Width:  |  Height:  |  Size: 670 B