From 22cea25424af3e02ae239b53ee00fa1dee2ec0f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 10 Oct 2014 16:00:49 +0200 Subject: GameState: implement quick move from GameStateSelect --- .../src/ch/asynk/tankontank/game/states/GameStateMove.java | 4 ++++ .../ch/asynk/tankontank/game/states/GameStateSelect.java | 14 +++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/core/src/ch/asynk/tankontank/game/states/GameStateMove.java b/core/src/ch/asynk/tankontank/game/states/GameStateMove.java index 0c12ef1..8c76484 100644 --- a/core/src/ch/asynk/tankontank/game/states/GameStateMove.java +++ b/core/src/ch/asynk/tankontank/game/states/GameStateMove.java @@ -13,6 +13,10 @@ public class GameStateMove extends GameStateCommon from.set(hex); activePawn = pawn; map.buildAndShowMovesAndAssits(activePawn, from); + if (to.x != -1) { + upHex.set(to); + touchUp(); + } } else { if ((activePawn == pawn) || !pawn.canMove()) { upHex.set(map.getFirstMoveAssist()); diff --git a/core/src/ch/asynk/tankontank/game/states/GameStateSelect.java b/core/src/ch/asynk/tankontank/game/states/GameStateSelect.java index b4c10f0..b4df8c0 100644 --- a/core/src/ch/asynk/tankontank/game/states/GameStateSelect.java +++ b/core/src/ch/asynk/tankontank/game/states/GameStateSelect.java @@ -5,6 +5,8 @@ import ch.asynk.tankontank.game.GameCtrl; public class GameStateSelect extends GameStateCommon { + private boolean jumpToMove; + public GameStateSelect(GameCtrl ctrl, Map map) { super(ctrl, map); @@ -14,6 +16,7 @@ public class GameStateSelect extends GameStateCommon public void enter(boolean flag) { ctrl.hud.hide(); + jumpToMove = false; } @Override @@ -25,12 +28,21 @@ public class GameStateSelect extends GameStateCommon @Override public void touchDown() { - reselectHex(); + if (map.isInPossibleMoves(downHex)) + jumpToMove = true; + else + reselectHex(); } @Override public void touchUp() { + if (jumpToMove) { + to.set(downHex); + ctrl.setState(State.MOVE); + return; + } + hidePossibleTargetsMovesAssists(); if (hasPawn()) { int moves = map.buildPossibleMoves(pawn, hex); -- cgit v1.1-2-g2b99