diff options
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/PossiblePaths.java | 5 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/states/StateEscape.java | 15 |
2 files changed, 13 insertions, 7 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/PossiblePaths.java b/core/src/ch/asynk/tankontank/engine/PossiblePaths.java index 49a317f..b54835e 100644 --- a/core/src/ch/asynk/tankontank/engine/PossiblePaths.java +++ b/core/src/ch/asynk/tankontank/engine/PossiblePaths.java @@ -235,12 +235,13 @@ public class PossiblePaths implements Disposable return filteredPaths.get(i); } - public void setExit(Orientation exit) + public void setExit(Orientation o) { + orientation = o; Path path = getPath(0); path.cost += 1; path.tiles.add(to); - to = board.getAdjTileAt(to, exit); + to = board.getAdjTileAt(to, o); } private void printToErr(String what, List<Path> paths) diff --git a/core/src/ch/asynk/tankontank/game/states/StateEscape.java b/core/src/ch/asynk/tankontank/game/states/StateEscape.java index 98e4a8b..2d8eefd 100644 --- a/core/src/ch/asynk/tankontank/game/states/StateEscape.java +++ b/core/src/ch/asynk/tankontank/game/states/StateEscape.java @@ -1,6 +1,7 @@ package ch.asynk.tankontank.game.states; import ch.asynk.tankontank.game.Zone; +import ch.asynk.tankontank.game.Hex; import ch.asynk.tankontank.game.Unit; public class StateEscape extends StateCommon @@ -48,12 +49,16 @@ public class StateEscape extends StateCommon // ctrl.hud.notify("Escape " + unit); Zone exitZone = ctrl.battle.getExitZone(unit); + Hex hex = unit.getHex(); - if (map.possiblePaths.size() == 1) - map.possiblePaths.setExit(exitZone.orientation); - else - map.possiblePaths.build(map.getAdjTileAt(unit.getTile(), exitZone.orientation)); - map.possiblePaths.orientation = exitZone.orientation; + if (selectedHex == hex) + map.possiblePaths.build(hex); + + Hex exitHex = (Hex) map.possiblePaths.to; + if (!exitZone.contains(exitHex)) + throw new RuntimeException(String.format("%s not in exitZone", exitHex)); + + map.possiblePaths.setExit(exitZone.orientation); unit.hideMoveable(); map.hidePath(to); |