From 047899b43d2d987d1323f859476bfda9e1582292 Mon Sep 17 00:00:00 2001 From: Niklas Ulf Anders Cullberg Date: Tue, 9 Oct 2012 19:11:48 +0200 Subject: [PATCH] Monster will stop beside soldier and not on top --- DepthsBelow/DepthsBelow/KeyboardInput.cs | 1 + DepthsBelow/DepthsBelow/SmallEnemy.cs | 39 +++++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/DepthsBelow/DepthsBelow/KeyboardInput.cs b/DepthsBelow/DepthsBelow/KeyboardInput.cs index b3d9f02..71db3e1 100644 --- a/DepthsBelow/DepthsBelow/KeyboardInput.cs +++ b/DepthsBelow/DepthsBelow/KeyboardInput.cs @@ -43,6 +43,7 @@ namespace DepthsBelow } else { + core.TestMonster.step = 0; core.PlayerTurn = false; Point target = Point.Zero; int distance = 7000; diff --git a/DepthsBelow/DepthsBelow/SmallEnemy.cs b/DepthsBelow/DepthsBelow/SmallEnemy.cs index b8f4404..b1b4aa2 100644 --- a/DepthsBelow/DepthsBelow/SmallEnemy.cs +++ b/DepthsBelow/DepthsBelow/SmallEnemy.cs @@ -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 swarm) : base(core) { @@ -81,6 +93,19 @@ namespace DepthsBelow } } + foreach (var soldier in core.Squad) + { + var pathFinder = soldier.GetComponent(); + var position = nextNode.Position; + if (soldier.Transform.Grid == position) + { + soldierCollisions.Add(soldier.Transform.Grid); + GetComponent().RecreatePath(soldierCollisions); + nextNode = GetComponent().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().Next(); + { + if (currentStep < numberOfSteps) + { + currentStep++; + //lastLastNode = lastNode; + //lastNode = nextNode; + nextNode = GetComponent().Next(); + } + else + { + GetComponent().Stop(); + } + } } }