diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-10 09:00:01 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-10 09:00:01 +0200 |
commit | 47852fa8e4194ab363f535e73d84a12f4e5f33e5 (patch) | |
tree | 2e1ca91893b349f5328aa6423d1ee410f43f6dd3 /core | |
parent | c7a5eade2b1f0bc168a6b31b9426c2b270972f41 (diff) | |
download | RustAndDust-47852fa8e4194ab363f535e73d84a12f4e5f33e5.zip RustAndDust-47852fa8e4194ab363f535e73d84a12f4e5f33e5.tar.gz |
Board: add revertLastPawnMove(), call pawn .move(int) .rotate(Orientation) .revertLastMove()
Diffstat (limited to 'core')
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Board.java | 20 |
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) |