summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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));
+ }
}