summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-10-06 16:28:19 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-10-06 16:28:19 +0200
commit940cf359bdc79875dfd58725eca41f8bf4b6f47a (patch)
treeb0f90d3f26f297981a2f15a825cd9d78f9be38a0 /core/src/ch/asynk
parent413470de7d87de33752930a67a7e8d65c5f9032f (diff)
downloadRustAndDust-940cf359bdc79875dfd58725eca41f8bf4b6f47a.zip
RustAndDust-940cf359bdc79875dfd58725eca41f8bf4b6f47a.tar.gz
add abort() and enter() to GameState, set default implementation in GameStateCommon
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r--core/src/ch/asynk/tankontank/game/GameCtrl.java10
-rw-r--r--core/src/ch/asynk/tankontank/game/GameState.java12
-rw-r--r--core/src/ch/asynk/tankontank/game/states/GameStateCommon.java27
3 files changed, 43 insertions, 6 deletions
diff --git a/core/src/ch/asynk/tankontank/game/GameCtrl.java b/core/src/ch/asynk/tankontank/game/GameCtrl.java
index d295185..be26fd2 100644
--- a/core/src/ch/asynk/tankontank/game/GameCtrl.java
+++ b/core/src/ch/asynk/tankontank/game/GameCtrl.java
@@ -47,7 +47,7 @@ public class GameCtrl implements Disposable
factory.dispose();
}
- public void setState(GameState.State state, boolean forward)
+ public void setState(GameState.State state)
{
switch(state) {
case NONE:
@@ -63,8 +63,12 @@ public class GameCtrl implements Disposable
break;
}
- if (forward)
- this.state.touchDown();
+ this.state.enter();
+ }
+
+ public void abort()
+ {
+ state.abort();
}
public void touchDown(float x, float y)
diff --git a/core/src/ch/asynk/tankontank/game/GameState.java b/core/src/ch/asynk/tankontank/game/GameState.java
index a66dba1..316129e 100644
--- a/core/src/ch/asynk/tankontank/game/GameState.java
+++ b/core/src/ch/asynk/tankontank/game/GameState.java
@@ -3,11 +3,17 @@ package ch.asynk.tankontank.game;
public interface GameState
{
enum State {
- NONE,
- PATH,
- DIRECTION
+ VIEW,
+ MOVE,
+ DIRECTION,
+ ROTATE,
+ ANIMATION
};
+ public void enter();
+
+ public void abort();
+
public void touchDown();
public void touchUp();
diff --git a/core/src/ch/asynk/tankontank/game/states/GameStateCommon.java b/core/src/ch/asynk/tankontank/game/states/GameStateCommon.java
index d02d345..8b921f7 100644
--- a/core/src/ch/asynk/tankontank/game/states/GameStateCommon.java
+++ b/core/src/ch/asynk/tankontank/game/states/GameStateCommon.java
@@ -30,6 +30,28 @@ public abstract class GameStateCommon implements GameState
this.map = map;
}
+ @Override
+ public void enter()
+ {
+ map.hidePossibles();
+ unselectHex();
+ pawn = null;
+ }
+
+ @Override
+ public void abort()
+ {
+ ctrl.setState(State.VIEW);
+ }
+
+ @Override
+ public void touchDown()
+ {
+ unselectHex();
+ setHex();
+ selectHex();
+ }
+
protected static boolean hexInMap(GridPoint2 hex)
{
if (hex.x == -1) return false;
@@ -72,4 +94,9 @@ public abstract class GameStateCommon implements GameState
{
map.enableOverlayOn(hex, Hex.BLUE, true);
}
+
+ protected boolean downIsHex()
+ {
+ return ((downHex.x == hex.x) && (upHex.y == hex.y));
+ }
}