diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-03 15:12:15 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-03 15:12:15 +0200 |
commit | 0a83731af59a7d89eafefe11970aabd9c73b2daa (patch) | |
tree | 4a3645e738de7e45cb1bca1340930967c32bcfa2 | |
parent | 9c1b4170e5fa0a9899f6b6b7d370270e47166640 (diff) | |
download | RustAndDust-0a83731af59a7d89eafefe11970aabd9c73b2daa.zip RustAndDust-0a83731af59a7d89eafefe11970aabd9c73b2daa.tar.gz |
GameSates*: cleanup
-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; } |