diff options
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Board.java | 13 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Pawn.java | 10 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Map.java | 7 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/states/StateRotate.java | 35 |
4 files changed, 19 insertions, 46 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Board.java b/core/src/ch/asynk/tankontank/engine/Board.java index 0d8f3dc..203436c 100644 --- a/core/src/ch/asynk/tankontank/engine/Board.java +++ b/core/src/ch/asynk/tankontank/engine/Board.java @@ -436,19 +436,6 @@ public abstract class Board implements Disposable pawn.move(); } - protected void rotatePawn(final Pawn pawn, Orientation o, RunnableAnimation whenDone) - { - pawn.movement.setRotation(pawn.getTile(), o); - removePawn(pawn); - - AnimationSequence seq = pawn.getRotateAnimation(o.r(), 2); - seq.addAnimation(getSetPawnOntoAnimation(pawn)); - seq.addAnimation(whenDone); - addAnimation(seq); - - pawn.move(); - } - protected void revertLastPawnMove(final Pawn pawn, RunnableAnimation whenDone) { removePawn(pawn); diff --git a/core/src/ch/asynk/tankontank/engine/Pawn.java b/core/src/ch/asynk/tankontank/engine/Pawn.java index 57f8c0f..991e97e 100644 --- a/core/src/ch/asynk/tankontank/engine/Pawn.java +++ b/core/src/ch/asynk/tankontank/engine/Pawn.java @@ -67,16 +67,6 @@ public abstract class Pawn implements Moveable, Disposable return "move : [" + from.col + ";" + from.row + "] -> [" + to.col + ";" + to.row + ";" + orientation + "] dist:" + distance + " cost:" + cost + " road:" + roadMarch + " entry:" + entryMove; } - public void setRotation(Tile tile, Orientation o) - { - from = tile; - to = tile; - cost = 0; - roadMarch = false; - entryMove = false; - orientation = o; - } - public void reset() { from = null; diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java index 3735d40..089c93b 100644 --- a/core/src/ch/asynk/tankontank/game/Map.java +++ b/core/src/ch/asynk/tankontank/game/Map.java @@ -198,13 +198,6 @@ public abstract class Map extends Board return startMove(pawn); } - public int rotatePawn(Pawn pawn, Orientation o) - { - rotatePawn(pawn, o, notifyDoneAnimation(pawn)); - - return startMove(pawn); - } - public void revertMoves() { TankOnTank.debug(" revertMoves()"); diff --git a/core/src/ch/asynk/tankontank/game/states/StateRotate.java b/core/src/ch/asynk/tankontank/game/states/StateRotate.java index ec085b0..814f90f 100644 --- a/core/src/ch/asynk/tankontank/game/states/StateRotate.java +++ b/core/src/ch/asynk/tankontank/game/states/StateRotate.java @@ -17,16 +17,23 @@ public class StateRotate extends StateCommon ctrl.hud.actionButtons.show(Buttons.ROTATE.b | ((ctrl.cfg.canCancel) ? Buttons.ABORT.b : 0)); ctrl.hud.actionButtons.setOn(Buttons.ROTATE); - if (prevState == StateType.MOVE) { - rotateOnly = false; - if (to == null) - TankOnTank.debug("to is null but should not be"); - map.showFinalPath(to); - } else { - rotateOnly = true; + if (activeUnit == null) + activeUnit = selectedUnit; + if (to == null) to = activeUnit.getHex(); + + if (!map.possiblePaths.isSet()) { + map.possiblePaths.init(activeUnit); + map.possiblePaths.build(to); } + if (map.possiblePaths.size() != 1) + TankOnTank.debug("ERROR: possiblePaths.size() == " + map.possiblePaths.size()); + + rotateOnly = (to == activeUnit.getHex()); + + if (!rotateOnly) + map.showFinalPath(to); map.selectHex(activeUnit.getHex()); map.showDirections(to); @@ -40,6 +47,8 @@ public class StateRotate extends StateCommon map.hideFinalPath(to); map.hideDirections(to); map.hideOrientation(to); + map.possiblePaths.clear(); + to = null; } @Override @@ -105,15 +114,9 @@ public class StateRotate extends StateCommon StateType whenDone = StateType.DONE; ctrl.hud.notify("Move " + activeUnit); - if (rotateOnly) { - ctrl.setAnimationCount(1); - if (map.rotatePawn(activeUnit, o) > 0) - whenDone = StateType.MOVE; - } else { - ctrl.setAnimationCount(1); - if (map.movePawn(activeUnit, o) > 0) - whenDone = StateType.MOVE; - } + ctrl.setAnimationCount(1); + if (map.movePawn(activeUnit, o) > 0) + whenDone = StateType.MOVE; ctrl.setState(StateType.ANIMATION, whenDone); } |