From f3026c8e3ef637ee303d2b6c94c044d99edd6fbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 5 Nov 2014 16:34:46 +0100 Subject: PossiblePaths: implements applyToPawn that feed Pawn.Move and is called from Board.movePawn(...) --- core/src/ch/asynk/tankontank/engine/Board.java | 1 + core/src/ch/asynk/tankontank/engine/PossiblePaths.java | 12 ++++++++++++ 2 files changed, 13 insertions(+) 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 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 if (cost < 1) cost = 1; + pawn.move.cost = cost; + pawn.move.roadMarch = roadMarch; + pawn.move.distance = (1 + paths.get(i).size()); + return cost; } -- cgit v1.1-2-g2b99