summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-11-14 12:20:01 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-11-14 12:20:01 +0100
commit632d5304a38dd8598a2563b7788aa8a52880ff2d (patch)
tree2ad88c3ff7ae3d110f6f160593387a29b8f9a0e0 /core/src/ch/asynk
parent2465a1742e9caac4eb5056751767d77cde9f55f7 (diff)
downloadRustAndDust-632d5304a38dd8598a2563b7788aa8a52880ff2d.zip
RustAndDust-632d5304a38dd8598a2563b7788aa8a52880ff2d.tar.gz
States: code reoder
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateAnimation.java12
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateAttack.java60
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateBreak.java26
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateMove.java48
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StatePromote.java12
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateReinforcement.java24
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateRotate.java50
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateSelect.java32
8 files changed, 132 insertions, 132 deletions
diff --git a/core/src/ch/asynk/tankontank/game/states/StateAnimation.java b/core/src/ch/asynk/tankontank/game/states/StateAnimation.java
index 8690e9c..86bf61c 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateAnimation.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateAnimation.java
@@ -14,24 +14,24 @@ public class StateAnimation extends StateCommon
}
@Override
- public void touchDown()
+ public StateType abort()
{
+ return StateType.ABORT;
}
@Override
- public void touchUp()
+ public StateType done()
{
+ return StateType.DONE;
}
@Override
- public StateType abort()
+ public void touchDown()
{
- return StateType.ABORT;
}
@Override
- public StateType done()
+ public void touchUp()
{
- return StateType.DONE;
}
}
diff --git a/core/src/ch/asynk/tankontank/game/states/StateAttack.java b/core/src/ch/asynk/tankontank/game/states/StateAttack.java
index 37df9f7..97efd87 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateAttack.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateAttack.java
@@ -44,36 +44,6 @@ public class StateAttack extends StateCommon
}
@Override
- public void touchDown()
- {
- }
-
- @Override
- public void touchUp()
- {
- Unit unit = upHex.getUnit();
-
- // activeUnit is the target
- if ((activeUnit == null) && map.possibleTargets.contains(unit)) {
- ctrl.hud.notify("Attack " + unit);
- map.hidePossibleTargets();
- to = upHex;
- activeUnit = unit;
- activeUnit.showTarget();
- map.collectAttackAssists(selectedUnit, activeUnit, ctrl.player.unitIterator());
- map.showAttackAssists();
- ctrl.hud.actionButtons.show(Buttons.ATTACK.b | Buttons.DONE.b | ((ctrl.cfg.canCancel) ? Buttons.ABORT.b : 0));
- }
-
- if ((activeUnit != null) && map.attackAssists.contains(unit)) {
- if(map.toggleAttackAssist(unit))
- ctrl.hud.notify(unit + " will fire");
- else
- ctrl.hud.notify(unit + " wont fire");
- }
- }
-
- @Override
public StateType abort()
{
map.activatedPawns.clear();
@@ -104,4 +74,34 @@ public class StateAttack extends StateCommon
return nextState;
}
+
+ @Override
+ public void touchDown()
+ {
+ }
+
+ @Override
+ public void touchUp()
+ {
+ Unit unit = upHex.getUnit();
+
+ // activeUnit is the target
+ if ((activeUnit == null) && map.possibleTargets.contains(unit)) {
+ ctrl.hud.notify("Attack " + unit);
+ map.hidePossibleTargets();
+ to = upHex;
+ activeUnit = unit;
+ activeUnit.showTarget();
+ map.collectAttackAssists(selectedUnit, activeUnit, ctrl.player.unitIterator());
+ map.showAttackAssists();
+ ctrl.hud.actionButtons.show(Buttons.ATTACK.b | Buttons.DONE.b | ((ctrl.cfg.canCancel) ? Buttons.ABORT.b : 0));
+ }
+
+ if ((activeUnit != null) && map.attackAssists.contains(unit)) {
+ if(map.toggleAttackAssist(unit))
+ ctrl.hud.notify(unit + " will fire");
+ else
+ ctrl.hud.notify(unit + " wont fire");
+ }
+ }
}
diff --git a/core/src/ch/asynk/tankontank/game/states/StateBreak.java b/core/src/ch/asynk/tankontank/game/states/StateBreak.java
index debc9c1..a64a494 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateBreak.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateBreak.java
@@ -31,6 +31,19 @@ public class StateBreak extends StateCommon
}
@Override
+ public StateType abort()
+ {
+ return StateType.ABORT;
+ }
+
+ @Override
+ public StateType done()
+ {
+ doRotation(o);
+ return StateType.DONE;
+ }
+
+ @Override
public void touchDown()
{
}
@@ -61,19 +74,6 @@ public class StateBreak extends StateCommon
}
}
- @Override
- public StateType abort()
- {
- return StateType.ABORT;
- }
-
- @Override
- public StateType done()
- {
- doRotation(o);
- return StateType.DONE;
- }
-
private void doRotation(Orientation o)
{
if (done || (activeUnit == null)) return;
diff --git a/core/src/ch/asynk/tankontank/game/states/StateMove.java b/core/src/ch/asynk/tankontank/game/states/StateMove.java
index 02f814e..fbc71ea 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateMove.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateMove.java
@@ -53,6 +53,30 @@ public class StateMove extends StateCommon
}
@Override
+ public StateType abort()
+ {
+ hideAssists();
+ ctrl.setAnimationCount(map.activatedPawns.size());
+ map.revertMoves();
+ if (activeUnit.move.entryMove) {
+ map.leaveBoard(activeUnit);
+ ctrl.player.revertUnitEntry(activeUnit);
+ }
+ return StateType.ABORT;
+ }
+
+ @Override
+ public StateType done()
+ {
+ hideAssists();
+ // be sure that the hq is activated
+ if (selectedUnit.canMove() && (map.activatedPawns.size() > 0)) {
+ selectedUnit.move();
+ }
+ return StateType.DONE;
+ }
+
+ @Override
public void touchDown()
{
}
@@ -78,30 +102,6 @@ public class StateMove extends StateCommon
}
}
- @Override
- public StateType abort()
- {
- hideAssists();
- ctrl.setAnimationCount(map.activatedPawns.size());
- map.revertMoves();
- if (activeUnit.move.entryMove) {
- map.leaveBoard(activeUnit);
- ctrl.player.revertUnitEntry(activeUnit);
- }
- return StateType.ABORT;
- }
-
- @Override
- public StateType done()
- {
- hideAssists();
- // be sure that the hq is activated
- if (selectedUnit.canMove() && (map.activatedPawns.size() > 0)) {
- selectedUnit.move();
- }
- return StateType.DONE;
- }
-
private void hideAssists()
{
map.hideMoveablePawns();
diff --git a/core/src/ch/asynk/tankontank/game/states/StatePromote.java b/core/src/ch/asynk/tankontank/game/states/StatePromote.java
index 49bcad5..70cb875 100644
--- a/core/src/ch/asynk/tankontank/game/states/StatePromote.java
+++ b/core/src/ch/asynk/tankontank/game/states/StatePromote.java
@@ -22,24 +22,24 @@ public class StatePromote extends StateCommon
}
@Override
- public void touchDown()
+ public StateType abort()
{
+ return StateType.ABORT;
}
@Override
- public void touchUp()
+ public StateType done()
{
+ return StateType.DONE;
}
@Override
- public StateType abort()
+ public void touchDown()
{
- return StateType.ABORT;
}
@Override
- public StateType done()
+ public void touchUp()
{
- return StateType.DONE;
}
}
diff --git a/core/src/ch/asynk/tankontank/game/states/StateReinforcement.java b/core/src/ch/asynk/tankontank/game/states/StateReinforcement.java
index 5a611f9..2c423c6 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateReinforcement.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateReinforcement.java
@@ -31,6 +31,18 @@ public class StateReinforcement extends StateCommon
}
@Override
+ public StateType abort()
+ {
+ return StateType.ABORT;
+ }
+
+ @Override
+ public StateType done()
+ {
+ return StateType.DONE;
+ }
+
+ @Override
public void touchDown()
{
}
@@ -47,18 +59,6 @@ public class StateReinforcement extends StateCommon
ctrl.setState(StateType.SELECT);
}
- @Override
- public StateType abort()
- {
- return StateType.ABORT;
- }
-
- @Override
- public StateType done()
- {
- return StateType.DONE;
- }
-
private void changeUnit(Unit unit)
{
activeUnit = unit;
diff --git a/core/src/ch/asynk/tankontank/game/states/StateRotate.java b/core/src/ch/asynk/tankontank/game/states/StateRotate.java
index 7390b0d..2066a8a 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateRotate.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateRotate.java
@@ -43,31 +43,6 @@ public class StateRotate extends StateCommon
}
@Override
- public void touchDown()
- {
- }
-
- @Override
- public void touchUp()
- {
- if (rotationSet) return;
-
- o = Orientation.fromAdj(to.getCol(), to.getRow(), downHex.getCol(), downHex.getRow());
-
- if (o == Orientation.KEEP) return;
- if (!activeUnit.move.entryMove && rotateOnly && (o == activeUnit.getOrientation())) return;
- rotationSet = true;
-
-
- if (ctrl.cfg.mustValidate) {
- map.hideDirections(to);
- map.showOrientation(to, o);
- ctrl.hud.actionButtons.show(Buttons.ROTATE.b | Buttons.DONE.b | ((ctrl.cfg.canCancel) ? Buttons.ABORT.b : 0));
- } else
- doRotation(o);
- }
-
- @Override
public StateType abort()
{
StateType nextState = StateType.ABORT;
@@ -93,6 +68,31 @@ public class StateRotate extends StateCommon
return StateType.DONE;
}
+ @Override
+ public void touchDown()
+ {
+ }
+
+ @Override
+ public void touchUp()
+ {
+ if (rotationSet) return;
+
+ o = Orientation.fromAdj(to.getCol(), to.getRow(), downHex.getCol(), downHex.getRow());
+
+ if (o == Orientation.KEEP) return;
+ if (!activeUnit.move.entryMove && rotateOnly && (o == activeUnit.getOrientation())) return;
+ rotationSet = true;
+
+
+ if (ctrl.cfg.mustValidate) {
+ map.hideDirections(to);
+ map.showOrientation(to, o);
+ ctrl.hud.actionButtons.show(Buttons.ROTATE.b | Buttons.DONE.b | ((ctrl.cfg.canCancel) ? Buttons.ABORT.b : 0));
+ } else
+ doRotation(o);
+ }
+
private void hideAssists()
{
map.hideMoveablePawns();
diff --git a/core/src/ch/asynk/tankontank/game/states/StateSelect.java b/core/src/ch/asynk/tankontank/game/states/StateSelect.java
index e8b9539..82733fb 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateSelect.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateSelect.java
@@ -29,6 +29,22 @@ public class StateSelect extends StateCommon
}
@Override
+ public StateType abort()
+ {
+ if (selectedHex != null)
+ map.unselectHex(selectedHex);
+ hidePossibilities();
+ map.clearAll();
+ return StateType.ABORT;
+ }
+
+ @Override
+ public StateType done()
+ {
+ return StateType.DONE;
+ }
+
+ @Override
public void touchDown()
{
if (selectedHex != null)
@@ -79,20 +95,4 @@ public class StateSelect extends StateCommon
}
if (selectedUnit != null) ctrl.hud.notify(selectedUnit.toString());
}
-
- @Override
- public StateType abort()
- {
- if (selectedHex != null)
- map.unselectHex(selectedHex);
- hidePossibilities();
- map.clearAll();
- return StateType.ABORT;
- }
-
- @Override
- public StateType done()
- {
- return StateType.DONE;
- }
}