Monster will stop beside soldier and not on top

This commit is contained in:
Niklas Ulf Anders Cullberg
2012-10-09 19:11:48 +02:00
parent 29288df309
commit 047899b43d
2 changed files with 39 additions and 1 deletions
+1
View File
@@ -43,6 +43,7 @@ namespace DepthsBelow
}
else
{
core.TestMonster.step = 0;
core.PlayerTurn = false;
Point target = Point.Zero;
int distance = 7000;
+38 -1
View File
@@ -18,6 +18,18 @@ namespace DepthsBelow
private PathFinder.Node nextNode;
public int numberOfSteps = 5;
public int currentStep = 0;
public int step
{
get { return currentStep; }
set
{
currentStep = value;
}
}
public SmallEnemy(Core core, ref List<SmallEnemy> swarm)
: base(core)
{
@@ -81,6 +93,19 @@ namespace DepthsBelow
}
}
foreach (var soldier in core.Squad)
{
var pathFinder = soldier.GetComponent<PathFinder>();
var position = nextNode.Position;
if (soldier.Transform.Grid == position)
{
soldierCollisions.Add(soldier.Transform.Grid);
GetComponent<PathFinder>().RecreatePath(soldierCollisions);
nextNode = GetComponent<PathFinder>().Next();
break;
}
}
if (nextNode != null)
{
var nodeWorldPos = Grid.GridToWorld(nextNode.Position);
@@ -96,7 +121,19 @@ namespace DepthsBelow
Transform.World.Y -= speed;
if (Transform.World == nodeWorldPos)
nextNode = GetComponent<PathFinder>().Next();
{
if (currentStep < numberOfSteps)
{
currentStep++;
//lastLastNode = lastNode;
//lastNode = nextNode;
nextNode = GetComponent<PathFinder>().Next();
}
else
{
GetComponent<PathFinder>().Stop();
}
}
}
}