summaryrefslogtreecommitdiffstats
path: root/core/src/ch
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-10-10 09:00:01 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-10-10 09:00:01 +0200
commit47852fa8e4194ab363f535e73d84a12f4e5f33e5 (patch)
tree2e1ca91893b349f5328aa6423d1ee410f43f6dd3 /core/src/ch
parentc7a5eade2b1f0bc168a6b31b9426c2b270972f41 (diff)
downloadRustAndDust-47852fa8e4194ab363f535e73d84a12f4e5f33e5.zip
RustAndDust-47852fa8e4194ab363f535e73d84a12f4e5f33e5.tar.gz
Board: add revertLastPawnMove(), call pawn .move(int) .rotate(Orientation) .revertLastMove()
Diffstat (limited to 'core/src/ch')
-rw-r--r--core/src/ch/asynk/tankontank/engine/Board.java20
1 files changed, 19 insertions, 1 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Board.java b/core/src/ch/asynk/tankontank/engine/Board.java
index 8423fc4..f6d28bb 100644
--- a/core/src/ch/asynk/tankontank/engine/Board.java
+++ b/core/src/ch/asynk/tankontank/engine/Board.java
@@ -503,7 +503,7 @@ public abstract class Board implements Disposable
pushPawnAt(pawn, coords);
}
- protected void movePawn(final Pawn pawn, ArrayList<Vector3> path, RunnableAnimation whenDone)
+ protected void movePawn(final Pawn pawn, int cost, ArrayList<Vector3> path, RunnableAnimation whenDone)
{
removePawnFrom(pawn, getHexAt(pawn.getCenter()));
@@ -516,6 +516,23 @@ public abstract class Board implements Disposable
}));
seq.addAnimation(whenDone);
addPawnAnimation(pawn, seq);
+ pawn.move(cost);
+ }
+
+ protected void revertLastPawnMove(final Pawn pawn, RunnableAnimation whenDone)
+ {
+ removePawnFrom(pawn, getHexAt(pawn.getCenter()));
+
+ AnimationSequence seq = pawn.getRevertLastMoveAnimation();
+ seq.addAnimation(RunnableAnimation.get(pawn, new Runnable() {
+ @Override
+ public void run() {
+ pushPawnAt(pawn, getHexAt(pawn.getCenter()));
+ }
+ }));
+ seq.addAnimation(whenDone);
+ addPawnAnimation(pawn, seq);
+ pawn.revertLastMove();
}
protected void rotatePawn(final Pawn pawn, Orientation o, RunnableAnimation whenDone)
@@ -527,6 +544,7 @@ public abstract class Board implements Disposable
seq.addAnimation(whenDone);
addPawnAnimation(pawn, seq);
vector3Pool.free(v);
+ pawn.rotate(o);
}
public GridPoint2 getHexAt(Vector2 v)