summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-10-08 08:59:41 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-10-08 08:59:41 +0200
commit1ff9f420eb81ad79f44be55f548ecdb2c642ce01 (patch)
tree6c959d4a6072fdeeb86dbd74d81a82760f238242 /core
parent5a55d4e4f66869b02fca79ead61e6e5d2a2915db (diff)
downloadRustAndDust-1ff9f420eb81ad79f44be55f548ecdb2c642ce01.zip
RustAndDust-1ff9f420eb81ad79f44be55f548ecdb2c642ce01.tar.gz
GameStateRotate: clean up select() unselect() reselect()
Diffstat (limited to 'core')
-rw-r--r--core/src/ch/asynk/tankontank/game/states/GameStateAnimation.java2
-rw-r--r--core/src/ch/asynk/tankontank/game/states/GameStateCommon.java16
-rw-r--r--core/src/ch/asynk/tankontank/game/states/GameStateDirection.java4
-rw-r--r--core/src/ch/asynk/tankontank/game/states/GameStateMove.java6
-rw-r--r--core/src/ch/asynk/tankontank/game/states/GameStateRotate.java8
-rw-r--r--core/src/ch/asynk/tankontank/game/states/GameStateView.java2
6 files changed, 14 insertions, 24 deletions
diff --git a/core/src/ch/asynk/tankontank/game/states/GameStateAnimation.java b/core/src/ch/asynk/tankontank/game/states/GameStateAnimation.java
index c4a2dd8..435a066 100644
--- a/core/src/ch/asynk/tankontank/game/states/GameStateAnimation.java
+++ b/core/src/ch/asynk/tankontank/game/states/GameStateAnimation.java
@@ -20,7 +20,7 @@ public class GameStateAnimation extends GameStateCommon
@Override
public void abort()
{
- unselectHex();
+ unselectHex(hex);
pawn = null;
super.abort();
}
diff --git a/core/src/ch/asynk/tankontank/game/states/GameStateCommon.java b/core/src/ch/asynk/tankontank/game/states/GameStateCommon.java
index 4653518..94ec4af 100644
--- a/core/src/ch/asynk/tankontank/game/states/GameStateCommon.java
+++ b/core/src/ch/asynk/tankontank/game/states/GameStateCommon.java
@@ -68,31 +68,21 @@ public abstract class GameStateCommon implements GameState
return (pawn != null);
}
- protected void unselectHex()
- {
- unselectHex(hex);
- }
-
protected void unselectHex(GridPoint2 hex)
{
map.enableOverlayOn(hex, Hex.BLUE, false);
}
- protected void selectHex()
- {
- selectHex(hex);
- }
-
protected void selectHex(GridPoint2 hex)
{
map.enableOverlayOn(hex, Hex.BLUE, true);
}
- protected void reselect()
+ protected void reselectHex()
{
- unselectHex();
+ unselectHex(hex);
setHexAndPawn(downHex);
- selectHex();
+ selectHex(hex);
}
protected boolean sameHexes(GridPoint2 a, GridPoint2 b)
diff --git a/core/src/ch/asynk/tankontank/game/states/GameStateDirection.java b/core/src/ch/asynk/tankontank/game/states/GameStateDirection.java
index c82b96b..658c70a 100644
--- a/core/src/ch/asynk/tankontank/game/states/GameStateDirection.java
+++ b/core/src/ch/asynk/tankontank/game/states/GameStateDirection.java
@@ -22,9 +22,9 @@ public class GameStateDirection extends GameStateCommon
if (o != Orientation.KEEP) {
map.movePawn(pawn, o);
clear();
- unselectHex();
+ unselectHex(hex);
hex.set(tmp.x, tmp.y);
- unselectHex();
+ unselectHex(hex);
ctrl.setState(State.ANIMATION);
}
}
diff --git a/core/src/ch/asynk/tankontank/game/states/GameStateMove.java b/core/src/ch/asynk/tankontank/game/states/GameStateMove.java
index daf5b3c..bb992c3 100644
--- a/core/src/ch/asynk/tankontank/game/states/GameStateMove.java
+++ b/core/src/ch/asynk/tankontank/game/states/GameStateMove.java
@@ -10,7 +10,7 @@ public class GameStateMove extends GameStateCommon
map.enablePossibleTargets(false);
map.enablePossiblePaths(false, false);
if (hasPawn()) {
- selectHex();
+ selectHex(hex);
skipFirst = false;
map.clearPossiblePaths();
map.buildAndShowPossibleMoves(pawn, hex);
@@ -22,7 +22,7 @@ public class GameStateMove extends GameStateCommon
public void touchDown()
{
if (!hasPawn()) {
- reselect();
+ reselect(hex);
if (hasPawn()) {
skipFirst = true;
map.clearPossiblePaths();
@@ -36,7 +36,7 @@ public class GameStateMove extends GameStateCommon
public void touchUp()
{
if (!hasPawn()) {
- unselectHex();
+ unselectHex(hex);
return;
}
diff --git a/core/src/ch/asynk/tankontank/game/states/GameStateRotate.java b/core/src/ch/asynk/tankontank/game/states/GameStateRotate.java
index d4bf2ae..661efa7 100644
--- a/core/src/ch/asynk/tankontank/game/states/GameStateRotate.java
+++ b/core/src/ch/asynk/tankontank/game/states/GameStateRotate.java
@@ -9,7 +9,7 @@ public class GameStateRotate extends GameStateCommon
{
map.hidePossibles();
if (hasPawn()) {
- selectHex();
+ selectHex(hex);
map.enableDirections(hex, true);
}
}
@@ -18,7 +18,7 @@ public class GameStateRotate extends GameStateCommon
public void touchDown()
{
if (!hasPawn()) {
- reselect();
+ reselectHex();
if (hasPawn()) {
map.enableDirections(hex, true);
}
@@ -29,14 +29,14 @@ public class GameStateRotate extends GameStateCommon
public void touchUp()
{
if (!hasPawn()) {
- unselectHex();
+ unselectHex(hex);
return;
}
Orientation o = Orientation.fromAdj(hex.x, hex.y, downHex.x, downHex.y);
if (o != Orientation.KEEP) {
- unselectHex();
+ unselectHex(hex);
map.enableDirections(hex, false);
if (pawn.getOrientation() != o) {
map.rotatePawn(pawn, o);
diff --git a/core/src/ch/asynk/tankontank/game/states/GameStateView.java b/core/src/ch/asynk/tankontank/game/states/GameStateView.java
index 9313bc9..fc67ccb 100644
--- a/core/src/ch/asynk/tankontank/game/states/GameStateView.java
+++ b/core/src/ch/asynk/tankontank/game/states/GameStateView.java
@@ -18,7 +18,7 @@ public class GameStateView extends GameStateCommon
@Override
public void touchDown()
{
- reselect();
+ reselectHex();
}
@Override