diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-21 17:08:10 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-21 17:08:10 +0100 |
commit | 1985315e60a7c9d83541daa47e602057d10d41e3 (patch) | |
tree | 07224c220e3cf57fafc727a461941ca1db1d6560 /core/src/ch/asynk/tankontank | |
parent | e2f5e85b111d36a8b5616cf9d014b95ce31f2166 (diff) | |
download | RustAndDust-1985315e60a7c9d83541daa47e602057d10d41e3.zip RustAndDust-1985315e60a7c9d83541daa47e602057d10d41e3.tar.gz |
Map,Board,Pawn: plug in objectives management
Diffstat (limited to 'core/src/ch/asynk/tankontank')
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Board.java | 5 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Pawn.java | 4 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Map.java | 9 |
3 files changed, 12 insertions, 6 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Board.java b/core/src/ch/asynk/tankontank/engine/Board.java index 080eb33..d6426bb 100644 --- a/core/src/ch/asynk/tankontank/engine/Board.java +++ b/core/src/ch/asynk/tankontank/engine/Board.java @@ -19,6 +19,7 @@ import ch.asynk.tankontank.engine.gfx.Image; import ch.asynk.tankontank.engine.gfx.Animation; import ch.asynk.tankontank.engine.gfx.animations.AnimationSequence; import ch.asynk.tankontank.engine.gfx.animations.RunnableAnimation; +import ch.asynk.tankontank.engine.gfx.animations.MoveToAnimation.MoveToAnimationCb; public abstract class Board implements Disposable { @@ -410,12 +411,12 @@ public abstract class Board implements Disposable }); } - protected void movePawn(final Pawn pawn, PossiblePaths possiblePaths, RunnableAnimation whenDone) + protected void movePawn(final Pawn pawn, PossiblePaths possiblePaths, RunnableAnimation whenDone, MoveToAnimationCb cb) { possiblePaths.applyToPawn(0); removePawn(pawn); - AnimationSequence seq = pawn.getMoveAnimation(possiblePaths.iterator(), possiblePaths.pathSteps(0) + 2); + AnimationSequence seq = pawn.getMoveAnimation(possiblePaths.iterator(), (possiblePaths.pathSteps(0) + 2), cb); seq.addAnimation(getSetPawnOntoAnimation(pawn)); seq.addAnimation(whenDone); addAnimation(seq); diff --git a/core/src/ch/asynk/tankontank/engine/Pawn.java b/core/src/ch/asynk/tankontank/engine/Pawn.java index 33c5f07..70fc641 100644 --- a/core/src/ch/asynk/tankontank/engine/Pawn.java +++ b/core/src/ch/asynk/tankontank/engine/Pawn.java @@ -345,12 +345,12 @@ public abstract class Pawn implements Moveable, Disposable return seq; } - public AnimationSequence getMoveAnimation(Iterator<Vector3> vectors, int size) + public AnimationSequence getMoveAnimation(Iterator<Vector3> vectors, int size, MoveToAnimation.MoveToAnimationCb cb) { prevPosition.set(position); AnimationSequence seq = AnimationSequence.get(size); while (vectors.hasNext()) - seq.addAnimation(MoveToAnimation.get(this, vectors.next(), MOVE_TIME)); + seq.addAnimation(MoveToAnimation.get(this, vectors.next(), MOVE_TIME, cb)); return seq; } diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java index bd04a70..dbf029e 100644 --- a/core/src/ch/asynk/tankontank/game/Map.java +++ b/core/src/ch/asynk/tankontank/game/Map.java @@ -192,6 +192,7 @@ public abstract class Map extends Board public void actionDone() { + objectives.forget(); } public boolean enterBoard(Unit unit, Hex to, int allowedMoves) @@ -206,19 +207,22 @@ public abstract class Map extends Board { unit.enterBoard(to, entry); setPawnOnto(unit, to, entry); + objectives.claim(to, unit.getArmy()); return true; } public void leaveBoard(Unit unit) { - removePawn(unit); + Hex hex = unit.getHex(); + if (removePawn(unit) == 0) + objectives.unclaim(hex); activatedUnits.add(unit); } public int moveUnit(Unit unit, Orientation o) { possiblePaths.orientation = o; - movePawn(unit, possiblePaths, notifyDoneAnimation(unit)); + movePawn(unit, possiblePaths, notifyDoneAnimation(unit), objectives); return startMove(unit); } @@ -230,6 +234,7 @@ public abstract class Map extends Board revertLastPawnMove(unit, notifyDoneAnimation(unit)); } activatedUnits.clear(); + objectives.revert(); } private int startMove(Unit unit) |