summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r--core/src/ch/asynk/rustanddust/game/states/StateMove.java19
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;