summaryrefslogtreecommitdiffstats
path: root/core/src
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-11-05 16:34:46 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-11-05 16:34:46 +0100
commitf3026c8e3ef637ee303d2b6c94c044d99edd6fbd (patch)
treec16d72b1e419b8759e62a416f96e1efc51d2557f /core/src
parent119ab78da2b9021c84239946a2d9146d3df8dbcc (diff)
downloadRustAndDust-f3026c8e3ef637ee303d2b6c94c044d99edd6fbd.zip
RustAndDust-f3026c8e3ef637ee303d2b6c94c044d99edd6fbd.tar.gz
PossiblePaths: implements applyToPawn that feed Pawn.Move and is called from Board.movePawn(...)
Diffstat (limited to 'core/src')
-rw-r--r--core/src/ch/asynk/tankontank/engine/Board.java1
-rw-r--r--core/src/ch/asynk/tankontank/engine/PossiblePaths.java12
2 files changed, 13 insertions, 0 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Board.java b/core/src/ch/asynk/tankontank/engine/Board.java
index 78629f9..0a076c7 100644
--- a/core/src/ch/asynk/tankontank/engine/Board.java
+++ b/core/src/ch/asynk/tankontank/engine/Board.java
@@ -436,6 +436,7 @@ public abstract class Board implements Disposable
protected void movePawn(final Pawn pawn, PossiblePaths possiblePaths, RunnableAnimation whenDone)
{
+ possiblePaths.applyToPawn(0);
removePawn(pawn);
AnimationSequence seq = pawn.getMoveAnimation(possiblePaths.iterator(), possiblePaths.pathSteps(0) + 2);
diff --git a/core/src/ch/asynk/tankontank/engine/PossiblePaths.java b/core/src/ch/asynk/tankontank/engine/PossiblePaths.java
index cf97653..318aafc 100644
--- a/core/src/ch/asynk/tankontank/engine/PossiblePaths.java
+++ b/core/src/ch/asynk/tankontank/engine/PossiblePaths.java
@@ -168,6 +168,14 @@ public class PossiblePaths implements Iterable<Vector3>
return filteredPaths.size();
}
+ public void applyToPawn(int i)
+ {
+ pawn.move.from = from;
+ pawn.move.to = to;
+ pawn.move.orientation = orientation;
+ pathCost(i);
+ }
+
public int pathCost(int i)
{
int cost = 0;
@@ -188,6 +196,10 @@ public class PossiblePaths implements Iterable<Vector3>
if (cost < 1)
cost = 1;
+ pawn.move.cost = cost;
+ pawn.move.roadMarch = roadMarch;
+ pawn.move.distance = (1 + paths.get(i).size());
+
return cost;
}