summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/rustanddust/game/states
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2015-12-24 19:18:07 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2015-12-24 19:18:07 +0100
commit4e84edbf55e8ac24fbe78e86395bfea189bec187 (patch)
tree43f564ce028a2580e1662a822bee2630db132ad4 /core/src/ch/asynk/rustanddust/game/states
parent3d7c5a8f04db00072d591fdc3e824c2c53fafdc0 (diff)
downloadRustAndDust-4e84edbf55e8ac24fbe78e86395bfea189bec187.zip
RustAndDust-4e84edbf55e8ac24fbe78e86395bfea189bec187.tar.gz
State: replace touchUp() and touchDown() with touch(Hex)
Diffstat (limited to 'core/src/ch/asynk/rustanddust/game/states')
-rw-r--r--core/src/ch/asynk/rustanddust/game/states/StateAnimation.java10
-rw-r--r--core/src/ch/asynk/rustanddust/game/states/StateBreak.java14
-rw-r--r--core/src/ch/asynk/rustanddust/game/states/StateCommon.java19
-rw-r--r--core/src/ch/asynk/rustanddust/game/states/StateDeployment.java21
-rw-r--r--core/src/ch/asynk/rustanddust/game/states/StateEngage.java15
-rw-r--r--core/src/ch/asynk/rustanddust/game/states/StateMove.java24
-rw-r--r--core/src/ch/asynk/rustanddust/game/states/StatePromote.java10
-rw-r--r--core/src/ch/asynk/rustanddust/game/states/StateReinforcement.java13
-rw-r--r--core/src/ch/asynk/rustanddust/game/states/StateRotate.java11
-rw-r--r--core/src/ch/asynk/rustanddust/game/states/StateSelect.java25
-rw-r--r--core/src/ch/asynk/rustanddust/game/states/StateWithdraw.java10
11 files changed, 48 insertions, 124 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/states/StateAnimation.java b/core/src/ch/asynk/rustanddust/game/states/StateAnimation.java
index 41831e0..4b50bec 100644
--- a/core/src/ch/asynk/rustanddust/game/states/StateAnimation.java
+++ b/core/src/ch/asynk/rustanddust/game/states/StateAnimation.java
@@ -24,14 +24,4 @@ public class StateAnimation extends StateCommon
{
return StateType.DONE;
}
-
- @Override
- public void touchDown()
- {
- }
-
- @Override
- public void touchUp()
- {
- }
}
diff --git a/core/src/ch/asynk/rustanddust/game/states/StateBreak.java b/core/src/ch/asynk/rustanddust/game/states/StateBreak.java
index 56e8ba6..45b1937 100644
--- a/core/src/ch/asynk/rustanddust/game/states/StateBreak.java
+++ b/core/src/ch/asynk/rustanddust/game/states/StateBreak.java
@@ -1,6 +1,7 @@
package ch.asynk.rustanddust.game.states;
import ch.asynk.rustanddust.engine.Orientation;
+import ch.asynk.rustanddust.game.Hex;
import ch.asynk.rustanddust.game.Unit;
import ch.asynk.rustanddust.game.hud.ActionButtons.Buttons;
@@ -41,25 +42,20 @@ public class StateBreak extends StateCommon
}
@Override
- public void touchDown()
- {
- }
-
- @Override
- public void touchUp()
+ public void touch(Hex hex)
{
// TODO : cancel preview move before showing rotation
if (activeUnit == null) {
- Unit unit = upHex.getUnit();
+ Unit unit = hex.getUnit();
if (map.unitsBreakThroughContains(unit)) {
activeUnit = unit;
- map.hexMoveShow(upHex);
+ map.hexMoveShow(hex);
map.hexMoveShow(to);
map.hexDirectionsShow(to);
map.unitsBreakThroughHide();
}
} else {
- o = Orientation.fromAdj(to, upHex);
+ o = Orientation.fromAdj(to, hex);
if (o == Orientation.KEEP) return;
diff --git a/core/src/ch/asynk/rustanddust/game/states/StateCommon.java b/core/src/ch/asynk/rustanddust/game/states/StateCommon.java
index 97aecfc..8b6efed 100644
--- a/core/src/ch/asynk/rustanddust/game/states/StateCommon.java
+++ b/core/src/ch/asynk/rustanddust/game/states/StateCommon.java
@@ -16,8 +16,6 @@ public abstract class StateCommon implements State
protected static Map map;
protected static Hex selectedHex = null;
- protected static Hex downHex = null;
- protected static Hex upHex = null;
protected static Hex to = null;
protected boolean isEnemy;
@@ -31,20 +29,6 @@ public abstract class StateCommon implements State
map = game.ctrl.map;
}
- @Override
- public boolean downInMap(float x, float y)
- {
- downHex = map.getHexAt(x, y);
- return (downHex != null);
- }
-
- @Override
- public boolean upInMap(float x, float y)
- {
- upHex = map.getHexAt(x, y);
- return (upHex != null);
- }
-
protected boolean hasUnit()
{
return (selectedUnit != null);
@@ -64,4 +48,7 @@ public abstract class StateCommon implements State
map.unitsTargetHide();
map.unitsMoveableHide();
}
+
+ @Override
+ public void touch(Hex hex) { }
}
diff --git a/core/src/ch/asynk/rustanddust/game/states/StateDeployment.java b/core/src/ch/asynk/rustanddust/game/states/StateDeployment.java
index 14c015e..0afc4ee 100644
--- a/core/src/ch/asynk/rustanddust/game/states/StateDeployment.java
+++ b/core/src/ch/asynk/rustanddust/game/states/StateDeployment.java
@@ -53,26 +53,21 @@ public class StateDeployment extends StateCommon
}
@Override
- public void touchDown()
- {
- }
-
- @Override
- public void touchUp()
+ public void touch(Hex hex)
{
Unit unit = ctrl.hud.playerInfo.unitDock.selectedUnit;
- if (!completed && (unit != null) && (unit != activeUnit)) {
+ if (hex == null) {
showEntryZone(unit);
} else if (selectedUnit != null) {
- deployUnit(Orientation.fromAdj(selectedHex, upHex));
- } else if (!completed && (entryZone != null) && (upHex != null)) {
- if (upHex.isEmpty() && entryZone.contains(upHex)) {
- showUnit(activeUnit, upHex);
+ deployUnit(Orientation.fromAdj(selectedHex, hex));
+ } else if (!completed && (entryZone != null) && (hex != null)) {
+ if (hex.isEmpty() && entryZone.contains(hex)) {
+ showUnit(activeUnit, hex);
}
} else {
- unit = upHex.getUnit();
+ unit = hex.getUnit();
if (deployedUnits.contains(unit))
- showRotation(unit, upHex);
+ showRotation(unit, hex);
}
}
diff --git a/core/src/ch/asynk/rustanddust/game/states/StateEngage.java b/core/src/ch/asynk/rustanddust/game/states/StateEngage.java
index 582e5dd..4bc3287 100644
--- a/core/src/ch/asynk/rustanddust/game/states/StateEngage.java
+++ b/core/src/ch/asynk/rustanddust/game/states/StateEngage.java
@@ -1,5 +1,6 @@
package ch.asynk.rustanddust.game.states;
+import ch.asynk.rustanddust.game.Hex;
import ch.asynk.rustanddust.game.Unit;
import ch.asynk.rustanddust.RustAndDust;
@@ -20,8 +21,7 @@ public class StateEngage extends StateCommon
map.unitsTargetShow();
if (to != null) {
// quick fire -> replay touchUp
- upHex = to;
- touchUp();
+ touch(to);
}
selectedUnit.showAttack();
map.hexSelect(selectedHex);
@@ -67,14 +67,9 @@ public class StateEngage extends StateCommon
}
@Override
- public void touchDown()
+ public void touch(Hex hex)
{
- }
-
- @Override
- public void touchUp()
- {
- Unit unit = upHex.getUnit();
+ Unit unit = hex.getUnit();
// activeUnit is the target, selectedTarget is the engagement leader
if (unit == selectedUnit) {
@@ -82,7 +77,7 @@ public class StateEngage extends StateCommon
} else if ((activeUnit == null) && map.unitsTargetContains(unit)) {
// ctrl.hud.notify("Engage " + unit);
map.unitsTargetHide();
- to = upHex;
+ to = hex;
activeUnit = unit;
activeUnit.showTarget();
map.collectAssists(selectedUnit, activeUnit, ctrl.battle.getPlayer().units);
diff --git a/core/src/ch/asynk/rustanddust/game/states/StateMove.java b/core/src/ch/asynk/rustanddust/game/states/StateMove.java
index 8c3c68e..67fb673 100644
--- a/core/src/ch/asynk/rustanddust/game/states/StateMove.java
+++ b/core/src/ch/asynk/rustanddust/game/states/StateMove.java
@@ -30,8 +30,7 @@ public class StateMove extends StateCommon
map.collectUpdate(activeUnit);
if (to != null) {
// quick move -> replay touchUp
- upHex = to;
- touchUp();
+ touch(to);
} else
checkExit(activeUnit, activeUnit.getHex());
} else {
@@ -92,14 +91,9 @@ public class StateMove extends StateCommon
}
@Override
- public void touchDown()
+ public void touch(Hex hex)
{
- }
-
- @Override
- public void touchUp()
- {
- if (upHex == activeUnit.getHex()) {
+ if (hex == activeUnit.getHex()) {
if (to != null)
map.pathHide(to);
to = null;
@@ -110,19 +104,19 @@ public class StateMove extends StateCommon
int s = map.pathsSize();
- Unit unit = upHex.getUnit();
+ Unit unit = hex.getUnit();
if (map.unitsMoveableContains(unit)) {
if(unit != activeUnit)
changeUnit(unit);
- } else if ((s == 0) && map.movesContains(upHex)) {
- s = collectPaths(upHex);
- } else if (map.pathsContains(upHex)) {
- s = togglePoint(downHex, s);
+ } else if ((s == 0) && map.movesContains(hex)) {
+ s = collectPaths(hex);
+ } else if (map.pathsContains(hex)) {
+ s = togglePoint(hex, s);
}
if (s == 1) {
- if (!checkExit(activeUnit, upHex))
+ if (!checkExit(activeUnit, hex))
ctrl.setState(StateType.ROTATE);
}
}
diff --git a/core/src/ch/asynk/rustanddust/game/states/StatePromote.java b/core/src/ch/asynk/rustanddust/game/states/StatePromote.java
index e80ebec..b991949 100644
--- a/core/src/ch/asynk/rustanddust/game/states/StatePromote.java
+++ b/core/src/ch/asynk/rustanddust/game/states/StatePromote.java
@@ -27,14 +27,4 @@ public class StatePromote extends StateCommon
{
return StateType.DONE;
}
-
- @Override
- public void touchDown()
- {
- }
-
- @Override
- public void touchUp()
- {
- }
}
diff --git a/core/src/ch/asynk/rustanddust/game/states/StateReinforcement.java b/core/src/ch/asynk/rustanddust/game/states/StateReinforcement.java
index 304e2b5..8c89f3b 100644
--- a/core/src/ch/asynk/rustanddust/game/states/StateReinforcement.java
+++ b/core/src/ch/asynk/rustanddust/game/states/StateReinforcement.java
@@ -42,18 +42,13 @@ public class StateReinforcement extends StateCommon
}
@Override
- public void touchDown()
- {
- }
-
- @Override
- public void touchUp()
+ public void touch(Hex hex)
{
Unit unit = ctrl.hud.playerInfo.unitDock.selectedUnit;
- if ((unit != null) && (unit != activeUnit))
+ if (hex == null)
changeUnit(unit);
- else if ((entryZone != null) && upHex.isEmpty() && entryZone.contains(upHex))
- unitEnter(activeUnit);
+ else if ((entryZone != null) && hex.isEmpty() && entryZone.contains(hex))
+ unitEnter(activeUnit, hex);
else
ctrl.setState(StateType.SELECT);
}
diff --git a/core/src/ch/asynk/rustanddust/game/states/StateRotate.java b/core/src/ch/asynk/rustanddust/game/states/StateRotate.java
index 2e9b520..0331cdb 100644
--- a/core/src/ch/asynk/rustanddust/game/states/StateRotate.java
+++ b/core/src/ch/asynk/rustanddust/game/states/StateRotate.java
@@ -2,6 +2,8 @@ package ch.asynk.rustanddust.game.states;
import ch.asynk.rustanddust.engine.Orientation;
+import ch.asynk.rustanddust.game.Hex;
+
import ch.asynk.rustanddust.RustAndDust;
public class StateRotate extends StateCommon
@@ -77,16 +79,11 @@ public class StateRotate extends StateCommon
}
@Override
- public void touchDown()
- {
- }
-
- @Override
- public void touchUp()
+ public void touch(Hex hex)
{
if (rotationSet) return;
- Orientation o = Orientation.fromAdj(to, upHex);
+ Orientation o = Orientation.fromAdj(to, hex);
if (o == Orientation.KEEP) {
ctrl.setState(StateType.ABORT);
return;
diff --git a/core/src/ch/asynk/rustanddust/game/states/StateSelect.java b/core/src/ch/asynk/rustanddust/game/states/StateSelect.java
index e2cfef8..797623c 100644
--- a/core/src/ch/asynk/rustanddust/game/states/StateSelect.java
+++ b/core/src/ch/asynk/rustanddust/game/states/StateSelect.java
@@ -43,23 +43,18 @@ public class StateSelect extends StateCommon
}
@Override
- public void touchDown()
- {
- }
-
- @Override
- public void touchUp()
+ public void touch(Hex hex)
{
if (!isEnemy) {
- if (map.movesContains(upHex)) {
+ if (map.movesContains(hex)) {
// quick move
- to = upHex;
+ to = hex;
ctrl.setState(StateType.MOVE);
return;
}
- if (map.unitsTargetContains(upHex.getUnit())) {
+ if (map.unitsTargetContains(hex.getUnit())) {
// quick fire
- to = upHex;
+ to = hex;
ctrl.setState(StateType.ENGAGE);
return;
}
@@ -69,12 +64,12 @@ public class StateSelect extends StateCommon
map.hexUnselect(selectedHex);
hidePossibilities();
- if (upHex.isOffMap()) {
+ if (hex.isOffMap()) {
selectedUnit = null;
return;
}
- Unit unit = upHex.getUnit();
+ Unit unit = hex.getUnit();
if (unit == null) {
isEnemy = false;
@@ -88,15 +83,15 @@ public class StateSelect extends StateCommon
if (!isEnemy && (unit == selectedUnit) && unit.canMove()) {
if (unit.isHq() && (map.unitsMoveableSize() > 1)) {
ctrl.hud.notify("HQ activation");
- select(upHex, unit, isEnemy);
+ select(hex, unit, isEnemy);
ctrl.setState(StateType.MOVE);
} else {
// quick rotate
- to = upHex;
+ to = hex;
ctrl.setState(StateType.ROTATE);
}
} else {
- select(upHex, unit, isEnemy);
+ select(hex, unit, isEnemy);
ctrl.hud.notify(selectedUnit.toString(), Position.TOP_CENTER);
}
}
diff --git a/core/src/ch/asynk/rustanddust/game/states/StateWithdraw.java b/core/src/ch/asynk/rustanddust/game/states/StateWithdraw.java
index a17f58b..bbdfb4c 100644
--- a/core/src/ch/asynk/rustanddust/game/states/StateWithdraw.java
+++ b/core/src/ch/asynk/rustanddust/game/states/StateWithdraw.java
@@ -33,16 +33,6 @@ public class StateWithdraw extends StateCommon
return StateType.ANIMATION;
}
- @Override
- public void touchDown()
- {
- }
-
- @Override
- public void touchUp()
- {
- }
-
private StateType withdraw(Unit unit)
{
Zone exitZone = ctrl.battle.getExitZone(unit);