diff options
Diffstat (limited to 'core/src/ch/asynk/tankontank')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/GameStateDirection.java | 4 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/GameStateNone.java | 13 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/GameStatePath.java | 29 |
3 files changed, 25 insertions, 21 deletions
diff --git a/core/src/ch/asynk/tankontank/game/GameStateDirection.java b/core/src/ch/asynk/tankontank/game/GameStateDirection.java index a65c742..995f9ab 100644 --- a/core/src/ch/asynk/tankontank/game/GameStateDirection.java +++ b/core/src/ch/asynk/tankontank/game/GameStateDirection.java @@ -35,7 +35,11 @@ public class GameStateDirection extends GameStateCommon } if (o != Orientation.KEEP) { + selectHex(); map.movePawn(pawn, o); } + map.enableFinalPath(hex, false); + map.resetPaths(); + ctrl.setState(State.NONE, false); } } diff --git a/core/src/ch/asynk/tankontank/game/GameStateNone.java b/core/src/ch/asynk/tankontank/game/GameStateNone.java index 1d7789a..a66f30b 100644 --- a/core/src/ch/asynk/tankontank/game/GameStateNone.java +++ b/core/src/ch/asynk/tankontank/game/GameStateNone.java @@ -23,19 +23,18 @@ public class GameStateNone extends GameStateCommon unselectHex(); setHex(); selectHex(); - if (hexHasUnit()) { - setPawn(); - map.showPossibleActions(pawn, hex, true); - } else { - map.showPossibleActions(pawn, hex, false); - } } } @Override public void touchUp() { - if (!hexHasUnit()) + if (hexHasUnit()) { + setPawn(); + map.showPossibleActions(pawn, hex, true); + } else { + map.showPossibleActions(pawn, hex, false); unselectHex(); + } } } diff --git a/core/src/ch/asynk/tankontank/game/GameStatePath.java b/core/src/ch/asynk/tankontank/game/GameStatePath.java index 5bd3964..fdb407d 100644 --- a/core/src/ch/asynk/tankontank/game/GameStatePath.java +++ b/core/src/ch/asynk/tankontank/game/GameStatePath.java @@ -10,29 +10,31 @@ public class GameStatePath extends GameStateCommon @Override public void touchDown() { + } + + @Override + public void touchUp() + { int s = map.possiblePathsSize(); if (s == 0) { s = buildPaths(); } else { - if (map.isInPossiblePaths(downHex)) { + if (map.isInPossiblePaths(downHex)) s = togglePoint(); - } else { - s = reset(false); - } + else + s = reset(); } + // FIXME maybe there's more than one path left, + // but that's irrelevant, ie 1 hex far if (s == 1) { + unselectHex(); hex.set(to.x, to.y); map.enableFinalPath(to, true); ctrl.setState(State.DIRECTION, false); } } - @Override - public void touchUp() - { - } - private int buildPaths() { from.set(hex.x, hex.y); @@ -50,7 +52,7 @@ public class GameStatePath extends GameStateCommon if ((downHex.x == from.x) && (downHex.y == from.y)) { s = map.possiblePathsSize(); } else if ((downHex.x == to.x) && (downHex.y == to.y)) { - s = reset(true); + s = reset(); } else { map.enablePossiblePaths(false, true); map.toggleDotOverlay(downHex); @@ -60,13 +62,12 @@ public class GameStatePath extends GameStateCommon return s; } - private int reset(boolean showMoves) + private int reset() { to.set(-1, -1); from.set(-1, -1); - map.clearPossibles(); - if (showMoves) - map.enablePossibleMoves(true); + map.hidePaths(); + map.resetPaths(); ctrl.setState(State.NONE, false); return -1; } |