diff options
Diffstat (limited to 'core/src/ch/asynk/rustanddust/game/states')
-rw-r--r-- | core/src/ch/asynk/rustanddust/game/states/StateMove.java | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/states/StateMove.java b/core/src/ch/asynk/rustanddust/game/states/StateMove.java index f7597ff..3a2bc76 100644 --- a/core/src/ch/asynk/rustanddust/game/states/StateMove.java +++ b/core/src/ch/asynk/rustanddust/game/states/StateMove.java @@ -16,8 +16,7 @@ public class StateMove extends StateCommon ); if (prevState == StateType.WITHDRAW) { - if (map.pathsSize() == 1) - ctrl.setState(StateType.ROTATE); + completePath(map.pathsSize()); return; } @@ -110,14 +109,9 @@ public class StateMove extends StateCommon if(unit != activeUnit) changeUnit(unit); } else if ((s == 0) && map.movesContains(hex)) { - s = collectPaths(hex); + collectPaths(hex); } else if (map.pathsContains(hex)) { - s = togglePoint(hex, s); - } - - if (s == 1) { - if (!checkExit(activeUnit, hex)) - ctrl.setState(StateType.ROTATE); + togglePoint(hex, s); } } @@ -133,6 +127,7 @@ public class StateMove extends StateCommon if (activeUnit.canMove()) activeUnit.showActiveable(); } + to = null; activeUnit = unit; activeUnit.hideActiveable(); Hex hex = activeUnit.getHex(); @@ -145,19 +140,26 @@ public class StateMove extends StateCommon checkExit(activeUnit); } - private int collectPaths(Hex hex) + private void collectPaths(Hex hex) { to = hex; + map.movesHide(); + map.hexMoveShow(to); int s = map.pathsBuild(to); + if (!checkExit(activeUnit, hex)) + completePath(s); + } + + private void completePath(int s) + { if (cfg.autoPath && (s > 1)) s = map.pathsChooseBest(); - map.hexMoveShow(to); - map.movesHide(); map.pathsShow(); - return s; + if (s == 1) + ctrl.setState(StateType.ROTATE); } - private int togglePoint(Hex hex, int s) + private void togglePoint(Hex hex, int s) { if (hex == activeUnit.getHex()) { // @@ -169,7 +171,10 @@ public class StateMove extends StateCommon map.pathsShow(); } - return s; + if (s == 1) { + if (!checkExit(activeUnit, hex)) + ctrl.setState(StateType.ROTATE); + } } private boolean checkExit(Unit unit) |