diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-01-04 21:43:30 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-01-04 21:43:30 +0100 |
commit | f4e47fdceb73d2fcd5a9d3af9876b9612f8cf8cf (patch) | |
tree | 1f47a0c15fb61185ed8215a80d77d01217b3fc8e /core/src/ch/asynk/rustanddust | |
parent | 45ce22c8270959dbefeb73a02b4fc49681afa475 (diff) | |
download | RustAndDust-f4e47fdceb73d2fcd5a9d3af9876b9612f8cf8cf.zip RustAndDust-f4e47fdceb73d2fcd5a9d3af9876b9612f8cf8cf.tar.gz |
StateMove: split checkExit() -> inplace | from hex
Diffstat (limited to 'core/src/ch/asynk/rustanddust')
-rw-r--r-- | core/src/ch/asynk/rustanddust/game/states/StateMove.java | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/states/StateMove.java b/core/src/ch/asynk/rustanddust/game/states/StateMove.java index 1a088ac..f7597ff 100644 --- a/core/src/ch/asynk/rustanddust/game/states/StateMove.java +++ b/core/src/ch/asynk/rustanddust/game/states/StateMove.java @@ -32,7 +32,7 @@ public class StateMove extends StateCommon // quick move -> replay touchUp touch(to); } else - checkExit(activeUnit, activeUnit.getHex()); + checkExit(activeUnit); } else { // back from rotation -> chose next Pawn if (selectedUnit.canMove()) { @@ -142,7 +142,7 @@ public class StateMove extends StateCommon map.movesShow(); map.hexSelect(hex); ctrl.hud.notify(activeUnit.toString(), Position.TOP_CENTER); - checkExit(activeUnit, hex); + checkExit(activeUnit); } private int collectPaths(Hex hex) @@ -172,14 +172,23 @@ public class StateMove extends StateCommon return s; } - private boolean checkExit(Unit unit, Hex hex) + private boolean checkExit(Unit unit) { - if ((hex == unit.getHex()) && (unit.justEntered())) + if (unit.justEntered()) + return false; + Zone exitZone = ctrl.battle.getExitZone(unit); + if ((exitZone == null) || !exitZone.contains(unit.getHex())) return false; + ctrl.setState(StateType.WITHDRAW); + return true; + } + + private boolean checkExit(Unit unit, Hex hex) + { Zone exitZone = ctrl.battle.getExitZone(unit); if ((exitZone == null) || !exitZone.contains(hex)) return false; - if ((unit.getHex() != hex) && !map.pathsCanExit(exitZone.orientation)) + if (!map.pathsCanExit(exitZone.orientation)) return false; ctrl.setState(StateType.WITHDRAW); return true; |