diff options
Diffstat (limited to 'core/src/ch/asynk/tankontank/game')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/GameStateDirection.java | 29 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/GameStatePath.java | 3 |
2 files changed, 30 insertions, 2 deletions
diff --git a/core/src/ch/asynk/tankontank/game/GameStateDirection.java b/core/src/ch/asynk/tankontank/game/GameStateDirection.java index 5b98e39..a65c742 100644 --- a/core/src/ch/asynk/tankontank/game/GameStateDirection.java +++ b/core/src/ch/asynk/tankontank/game/GameStateDirection.java @@ -1,6 +1,8 @@ package ch.asynk.tankontank.game; -public class GameStateDirection implements GameState +import ch.asynk.tankontank.engine.Orientation; + +public class GameStateDirection extends GameStateCommon { @Override public void touchDown() @@ -10,5 +12,30 @@ public class GameStateDirection implements GameState @Override public void touchUp() { + Orientation o = Orientation.KEEP;; + if (downHex.y == hex.y) { + if (downHex.x == (hex.x - 1)) { + o = Orientation.SOUTH; + } else if (downHex.x == (hex.x + 1)) { + o = Orientation.NORTH; + } + } else if (downHex.y == (hex.y - 1)) { + if (downHex.x == (hex.x - 1)) { + o = Orientation.SOUTH_EAST; + } else if (downHex.x == hex.x) { + o = Orientation.NORTH_EAST; + } + + } else if (downHex.y == (hex.y + 1)) { + if (downHex.x == hex.x) { + o = Orientation.SOUTH_WEST; + } else if (downHex.x == (hex.x + 1)) { + o = Orientation.NORTH_WEST; + } + } + + if (o != Orientation.KEEP) { + map.movePawn(pawn, o); + } } } diff --git a/core/src/ch/asynk/tankontank/game/GameStatePath.java b/core/src/ch/asynk/tankontank/game/GameStatePath.java index c13c14a..5bd3964 100644 --- a/core/src/ch/asynk/tankontank/game/GameStatePath.java +++ b/core/src/ch/asynk/tankontank/game/GameStatePath.java @@ -22,8 +22,9 @@ public class GameStatePath extends GameStateCommon } if (s == 1) { + hex.set(to.x, to.y); map.enableFinalPath(to, true); - ctrl.setState(State.DIRECTION, true); + ctrl.setState(State.DIRECTION, false); } } |