diff options
Diffstat (limited to 'core/src/ch/asynk/tankontank')
5 files changed, 24 insertions, 16 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java index 066de97..ca1fffd 100644 --- a/core/src/ch/asynk/tankontank/game/Map.java +++ b/core/src/ch/asynk/tankontank/game/Map.java @@ -293,15 +293,19 @@ public abstract class Map extends Board return true; } - public void exitBoard(Unit unit) + public int exitBoard(Unit unit) { - Hex hex = unit.getHex(); - if (unit.justEntered()) { - objectives.revert(); - unit.reset(); - } - removePawn(unit); - activatedUnits.add(unit); + // if (unit.justEntered()) { + // objectives.revert(); + // unit.reset(); + // } + + Move move = possiblePaths.getMove(); + move.setExit(); + + movePawn(unit, move, notifyDoneAnimation(unit), objectives); + + return startMove(unit); } public void promoteUnit(final Player player, final Unit unit) @@ -338,6 +342,14 @@ public abstract class Map extends Board objectives.revert(); } + public void revertEnter(Unit unit) + { + unit.reset(); + removePawn(unit); + objectives.revert(); + ctrl.player.revertUnitEntry(unit); + } + private int startMove(Unit unit) { moveableUnits.remove(unit); diff --git a/core/src/ch/asynk/tankontank/game/states/StateDeployment.java b/core/src/ch/asynk/tankontank/game/states/StateDeployment.java index 24e8b12..ee8d684 100644 --- a/core/src/ch/asynk/tankontank/game/states/StateDeployment.java +++ b/core/src/ch/asynk/tankontank/game/states/StateDeployment.java @@ -89,8 +89,7 @@ public class StateDeployment extends StateCommon { map.unselectHex(selectedHex); map.hideDirections(selectedHex); - map.exitBoard(selectedUnit); - ctrl.player.revertUnitEntry(selectedUnit); + map.revertEnter(activeUnit); activeUnit = null; selectedUnit = null; ctrl.hud.update(); diff --git a/core/src/ch/asynk/tankontank/game/states/StateEscape.java b/core/src/ch/asynk/tankontank/game/states/StateEscape.java index c6a0cf4..98e4a8b 100644 --- a/core/src/ch/asynk/tankontank/game/states/StateEscape.java +++ b/core/src/ch/asynk/tankontank/game/states/StateEscape.java @@ -60,10 +60,9 @@ public class StateEscape extends StateCommon map.hidePossibleMoves(); map.unselectHex(unit.getHex()); - map.exitBoard(unit); ctrl.player.unitEscape(unit); - if (map.moveUnit(activeUnit) > 0) + if (map.exitBoard(unit) > 0) return StateType.MOVE; return StateType.DONE; } diff --git a/core/src/ch/asynk/tankontank/game/states/StateMove.java b/core/src/ch/asynk/tankontank/game/states/StateMove.java index c56971c..7f2767b 100644 --- a/core/src/ch/asynk/tankontank/game/states/StateMove.java +++ b/core/src/ch/asynk/tankontank/game/states/StateMove.java @@ -70,8 +70,7 @@ public class StateMove extends StateCommon { hideAssists(); if (activeUnit.justEntered()) { - map.exitBoard(activeUnit); - ctrl.player.revertUnitEntry(activeUnit); + map.revertEnter(activeUnit); return StateType.ABORT; } int n = map.activatedUnits.size(); diff --git a/core/src/ch/asynk/tankontank/game/states/StateRotate.java b/core/src/ch/asynk/tankontank/game/states/StateRotate.java index c282733..4331d3d 100644 --- a/core/src/ch/asynk/tankontank/game/states/StateRotate.java +++ b/core/src/ch/asynk/tankontank/game/states/StateRotate.java @@ -55,8 +55,7 @@ public class StateRotate extends StateCommon StateType nextState = StateType.ABORT; ctrl.hud.actionButtons.hide(); if (activeUnit.justEntered()) { - map.exitBoard(activeUnit); - ctrl.player.revertUnitEntry(activeUnit); + map.revertEnter(activeUnit); nextState = StateType.ABORT; } else if (map.activatedUnits.size() == 0) { map.hideMoveableUnits(); |