diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-18 20:04:10 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-18 20:04:10 +0100 |
commit | ec9cea0aaa41f7eb1deac8f345619775593abca9 (patch) | |
tree | 2bb5ed90fd38afacf899d54680e988bcea545de0 /core | |
parent | 945f3d4a9120b2b83fca477f1d00edcf881a4ad6 (diff) | |
download | RustAndDust-ec9cea0aaa41f7eb1deac8f345619775593abca9.zip RustAndDust-ec9cea0aaa41f7eb1deac8f345619775593abca9.tar.gz |
StateMove: goto StateEscape when possible to escape
Diffstat (limited to 'core')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/states/StateMove.java | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/core/src/ch/asynk/tankontank/game/states/StateMove.java b/core/src/ch/asynk/tankontank/game/states/StateMove.java index a6747d0..d56c650 100644 --- a/core/src/ch/asynk/tankontank/game/states/StateMove.java +++ b/core/src/ch/asynk/tankontank/game/states/StateMove.java @@ -1,6 +1,5 @@ package ch.asynk.tankontank.game.states; -import ch.asynk.tankontank.engine.Zone; import ch.asynk.tankontank.game.Hex; import ch.asynk.tankontank.game.Unit; import ch.asynk.tankontank.game.hud.ActionButtons.Buttons; @@ -13,6 +12,13 @@ public class StateMove extends StateCommon boolean moreThanOne = ((map.moveablePawns.size() + map.activatedPawns.size()) > 1); ctrl.hud.actionButtons.show(Buttons.ROTATE.b | Buttons.MOVE.b | ((moreThanOne) ? Buttons.DONE.b : 0) | ((ctrl.cfg.canCancel) ? Buttons.ABORT.b : 0)); ctrl.hud.actionButtons.setOn(Buttons.MOVE); + + if (prevState == StateType.ESCAPE) { + if (map.possiblePaths.size() == 1) + ctrl.setState(StateType.ROTATE); + return; + } + map.possiblePaths.clear(); if (prevState == StateType.SELECT) { @@ -25,7 +31,8 @@ public class StateMove extends StateCommon // quick move -> replay touchUp upHex = to; touchUp(); - } + } else + checkExit(activeUnit, activeUnit.getHex()); } else { // back from rotation -> chose next Pawn if (selectedUnit.canMove()) { @@ -39,6 +46,9 @@ public class StateMove extends StateCommon @Override public void leave(StateType nextState) { + if (nextState == StateType.ESCAPE) + return; + // hide all but assists : want them when in rotation activeUnit.hideMoveable(); map.hidePossibleMoves(); @@ -102,7 +112,8 @@ public class StateMove extends StateCommon } if (s == 1) { - ctrl.setState(StateType.ROTATE); + if (!checkExit(activeUnit, to)) + ctrl.setState(StateType.ROTATE); } } @@ -123,6 +134,7 @@ public class StateMove extends StateCommon map.hidePossibleMoves(); map.collectPossibleMoves(activeUnit); map.showPossibleMoves(); + checkExit(activeUnit, activeUnit.getHex()); } private int collectPaths(Hex hex) |