summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank/game/states
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-10-10 16:00:49 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-10-10 16:00:49 +0200
commit22cea25424af3e02ae239b53ee00fa1dee2ec0f5 (patch)
tree349418a2ada499464f54bbb2f132643f40ad5b12 /core/src/ch/asynk/tankontank/game/states
parent2984813ed2e66fe5611ab017b98c76215df79eee (diff)
downloadRustAndDust-22cea25424af3e02ae239b53ee00fa1dee2ec0f5.zip
RustAndDust-22cea25424af3e02ae239b53ee00fa1dee2ec0f5.tar.gz
GameState: implement quick move from GameStateSelect
Diffstat (limited to 'core/src/ch/asynk/tankontank/game/states')
-rw-r--r--core/src/ch/asynk/tankontank/game/states/GameStateMove.java4
-rw-r--r--core/src/ch/asynk/tankontank/game/states/GameStateSelect.java14
2 files changed, 17 insertions, 1 deletions
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);