diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-01 09:45:36 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-01 09:45:36 +0100 |
commit | 9c2912ed1da661547a40b2ac519ba73af428df88 (patch) | |
tree | ae173e5e303966f21edaacfd111cb6255c554aec /core/src | |
parent | 56b596ec85547c40ecaa14ded6ee7a6ad6468d8a (diff) | |
download | RustAndDust-9c2912ed1da661547a40b2ac519ba73af428df88.zip RustAndDust-9c2912ed1da661547a40b2ac519ba73af428df88.tar.gz |
Board: factorize pawn animation code
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Board.java | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Board.java b/core/src/ch/asynk/tankontank/engine/Board.java index 28e94ea..0a8541d 100644 --- a/core/src/ch/asynk/tankontank/engine/Board.java +++ b/core/src/ch/asynk/tankontank/engine/Board.java @@ -362,20 +362,25 @@ public abstract class Board implements Disposable return pawn; } + private RunnableAnimation getSetPawnOntoAnimation(final Pawn pawn, final Tile dest ) + { + return RunnableAnimation.get(pawn, new Runnable() { + @Override + public void run() { + setPawnOnto(pawn, dest, pawn.getRotation()); + } + }); + } + protected void movePawn(final Pawn pawn, PossiblePaths possiblePaths, RunnableAnimation whenDone) { removePawn(pawn); - final Tile destination = possiblePaths.to; AnimationSequence seq = pawn.getMoveAnimation(possiblePaths.iterator(), possiblePaths.pathSteps(0) + 2); - seq.addAnimation(RunnableAnimation.get(pawn, new Runnable() { - @Override - public void run() { - setPawnOnto(pawn, destination, pawn.getRotation()); - } - })); + seq.addAnimation(getSetPawnOntoAnimation(pawn, possiblePaths.to)); seq.addAnimation(whenDone); addAnimation(seq); + pawn.move(possiblePaths.pathCost(0)); } @@ -384,14 +389,10 @@ public abstract class Board implements Disposable removePawn(pawn); AnimationSequence seq = pawn.getRotateAnimation(o.r(), 2); - seq.addAnimation(RunnableAnimation.get(pawn, new Runnable() { - @Override - public void run() { - setPawnOnto(pawn, pawn.getTile(), pawn.getRotation()); - } - })); + seq.addAnimation(getSetPawnOntoAnimation(pawn, pawn.getTile())); seq.addAnimation(whenDone); addAnimation(seq); + pawn.rotate(o); } @@ -408,6 +409,7 @@ public abstract class Board implements Disposable })); seq.addAnimation(whenDone); addAnimation(seq); + pawn.revertLastMove(); } |