summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank/engine
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-11-01 09:45:36 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-11-01 09:45:36 +0100
commit9c2912ed1da661547a40b2ac519ba73af428df88 (patch)
treeae173e5e303966f21edaacfd111cb6255c554aec /core/src/ch/asynk/tankontank/engine
parent56b596ec85547c40ecaa14ded6ee7a6ad6468d8a (diff)
downloadRustAndDust-9c2912ed1da661547a40b2ac519ba73af428df88.zip
RustAndDust-9c2912ed1da661547a40b2ac519ba73af428df88.tar.gz
Board: factorize pawn animation code
Diffstat (limited to 'core/src/ch/asynk/tankontank/engine')
-rw-r--r--core/src/ch/asynk/tankontank/engine/Board.java28
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();
}