summaryrefslogtreecommitdiffstats
path: root/core/src/ch
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/ch')
-rw-r--r--core/src/ch/asynk/rustanddust/game/Ctrl.java4
-rw-r--r--core/src/ch/asynk/rustanddust/game/states/StateBreak.java2
-rw-r--r--core/src/ch/asynk/rustanddust/game/states/StateCommon.java19
-rw-r--r--core/src/ch/asynk/rustanddust/game/states/StateEngage.java4
-rw-r--r--core/src/ch/asynk/rustanddust/game/states/StateMove.java2
-rw-r--r--core/src/ch/asynk/rustanddust/game/states/StateReinforcement.java2
-rw-r--r--core/src/ch/asynk/rustanddust/game/states/StateRotate.java6
-rw-r--r--core/src/ch/asynk/rustanddust/game/states/StateSelect.java7
8 files changed, 21 insertions, 25 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/Ctrl.java b/core/src/ch/asynk/rustanddust/game/Ctrl.java
index dd45423..5a11f5a 100644
--- a/core/src/ch/asynk/rustanddust/game/Ctrl.java
+++ b/core/src/ch/asynk/rustanddust/game/Ctrl.java
@@ -7,6 +7,7 @@ import com.badlogic.gdx.math.Vector3;
import ch.asynk.rustanddust.RustAndDust;
import ch.asynk.rustanddust.ui.Position;
import ch.asynk.rustanddust.game.State.StateType;
+import ch.asynk.rustanddust.game.states.StateCommon;
import ch.asynk.rustanddust.game.states.StateSelect;
import ch.asynk.rustanddust.game.states.StateMove;
import ch.asynk.rustanddust.game.states.StateRotate;
@@ -62,7 +63,7 @@ public class Ctrl implements Disposable
battle.setup(this, map);
this.map.init();
- this.selectState = new StateSelect(this, map);
+ this.selectState = new StateSelect();
this.pathState = new StateMove();
this.rotateState = new StateRotate();
this.promoteState = new StatePromote();
@@ -75,6 +76,7 @@ public class Ctrl implements Disposable
this.state = selectState;
this.stateType = StateType.DONE;
+ StateCommon.set(game);
this.hud = new Hud(this, game);
this.blockMap = false;
diff --git a/core/src/ch/asynk/rustanddust/game/states/StateBreak.java b/core/src/ch/asynk/rustanddust/game/states/StateBreak.java
index aff63d0..575903c 100644
--- a/core/src/ch/asynk/rustanddust/game/states/StateBreak.java
+++ b/core/src/ch/asynk/rustanddust/game/states/StateBreak.java
@@ -63,7 +63,7 @@ public class StateBreak extends StateCommon
if (o == Orientation.KEEP) return;
- if (ctrl.cfg.mustValidate) {
+ if (cfg.mustValidate) {
map.hexDirectionsHide(to);
ctrl.hud.actionButtons.show(Buttons.DONE.b);
} else {
diff --git a/core/src/ch/asynk/rustanddust/game/states/StateCommon.java b/core/src/ch/asynk/rustanddust/game/states/StateCommon.java
index f56d3a5..fdb797c 100644
--- a/core/src/ch/asynk/rustanddust/game/states/StateCommon.java
+++ b/core/src/ch/asynk/rustanddust/game/states/StateCommon.java
@@ -5,11 +5,13 @@ import ch.asynk.rustanddust.game.Hex;
import ch.asynk.rustanddust.game.Unit;
import ch.asynk.rustanddust.game.Ctrl;
import ch.asynk.rustanddust.game.State;
+import ch.asynk.rustanddust.game.Config;
import ch.asynk.rustanddust.RustAndDust;
public abstract class StateCommon implements State
{
+ protected static Config cfg;
protected static Ctrl ctrl;
protected static Map map;
@@ -22,14 +24,11 @@ public abstract class StateCommon implements State
protected static Unit activeUnit;
protected static Unit selectedUnit;
- protected StateCommon()
+ public static void set(RustAndDust game)
{
- }
-
- public StateCommon(Ctrl ctrl, Map map)
- {
- this.ctrl = ctrl;
- this.map = map;
+ ctrl = game.ctrl;
+ cfg = game.config;
+ map = game.ctrl.map;
}
@Override
@@ -53,9 +52,9 @@ public abstract class StateCommon implements State
protected void showPossibilities(Unit unit)
{
- if (ctrl.cfg.showMoves && unit.canMove()) map.movesShow();
- if (ctrl.cfg.showTargets && unit.canEngage()) map.unitsTargetShow();
- if (ctrl.cfg.showMoveAssists && unit.canMove()) map.unitsMoveableShow();
+ if (cfg.showMoves && unit.canMove()) map.movesShow();
+ if (cfg.showTargets && unit.canEngage()) map.unitsTargetShow();
+ if (cfg.showMoveAssists && unit.canMove()) map.unitsMoveableShow();
unit.enableOverlay(Unit.MOVE, false);
}
diff --git a/core/src/ch/asynk/rustanddust/game/states/StateEngage.java b/core/src/ch/asynk/rustanddust/game/states/StateEngage.java
index ab7a126..065f468 100644
--- a/core/src/ch/asynk/rustanddust/game/states/StateEngage.java
+++ b/core/src/ch/asynk/rustanddust/game/states/StateEngage.java
@@ -11,7 +11,7 @@ public class StateEngage extends StateCommon
public void enter(StateType prevState)
{
map.unitsTargetClear();
- ctrl.hud.actionButtons.show(ctrl.cfg.canCancel ? Buttons.ABORT.b : 0);
+ ctrl.hud.actionButtons.show(cfg.canCancel ? Buttons.ABORT.b : 0);
// activeUnit is the target
if (prevState == StateType.SELECT) {
@@ -89,7 +89,7 @@ public class StateEngage extends StateCommon
activeUnit.showTarget();
map.collectAssists(selectedUnit, activeUnit, ctrl.battle.getPlayer().units);
map.unitsAssistShow();
- ctrl.hud.actionButtons.show((ctrl.cfg.mustValidate ? Buttons.DONE.b : 0) | (ctrl.cfg.canCancel ? Buttons.ABORT.b : 0));
+ ctrl.hud.actionButtons.show((cfg.mustValidate ? Buttons.DONE.b : 0) | (cfg.canCancel ? Buttons.ABORT.b : 0));
}
else if (unit == activeUnit) {
ctrl.setState(StateType.DONE);
diff --git a/core/src/ch/asynk/rustanddust/game/states/StateMove.java b/core/src/ch/asynk/rustanddust/game/states/StateMove.java
index d601aa6..7955037 100644
--- a/core/src/ch/asynk/rustanddust/game/states/StateMove.java
+++ b/core/src/ch/asynk/rustanddust/game/states/StateMove.java
@@ -12,7 +12,7 @@ public class StateMove extends StateCommon
{
ctrl.hud.actionButtons.show(
((map.unitsActivatedSize() > 0) ? Buttons.DONE.b : 0)
- | (ctrl.cfg.canCancel ? Buttons.ABORT.b : 0));
+ | (cfg.canCancel ? Buttons.ABORT.b : 0));
if (prevState == StateType.WITHDRAW) {
if (map.pathsSize() == 1)
diff --git a/core/src/ch/asynk/rustanddust/game/states/StateReinforcement.java b/core/src/ch/asynk/rustanddust/game/states/StateReinforcement.java
index a4c1bf5..00ae3e1 100644
--- a/core/src/ch/asynk/rustanddust/game/states/StateReinforcement.java
+++ b/core/src/ch/asynk/rustanddust/game/states/StateReinforcement.java
@@ -66,7 +66,7 @@ public class StateReinforcement extends StateCommon
entryZone.enable(Hex.AREA, false);
entryZone = ctrl.battle.getEntryZone(activeUnit);
entryZone.enable(Hex.AREA, true);
- ctrl.hud.actionButtons.show(((ctrl.cfg.canCancel) ? Buttons.ABORT.b : 0));
+ ctrl.hud.actionButtons.show(((cfg.canCancel) ? Buttons.ABORT.b : 0));
}
private void unitEnter(Unit unit)
diff --git a/core/src/ch/asynk/rustanddust/game/states/StateRotate.java b/core/src/ch/asynk/rustanddust/game/states/StateRotate.java
index 5beddcd..8203725 100644
--- a/core/src/ch/asynk/rustanddust/game/states/StateRotate.java
+++ b/core/src/ch/asynk/rustanddust/game/states/StateRotate.java
@@ -13,7 +13,7 @@ public class StateRotate extends StateCommon
@Override
public void enter(StateType prevState)
{
- ctrl.hud.actionButtons.show((ctrl.cfg.canCancel && (map.unitsMoveableSize() > 1))? Buttons.ABORT.b : 0);
+ ctrl.hud.actionButtons.show((cfg.canCancel && (map.unitsMoveableSize() > 1))? Buttons.ABORT.b : 0);
if (activeUnit == null)
activeUnit = selectedUnit;
@@ -98,9 +98,9 @@ public class StateRotate extends StateCommon
map.pathsSetOrientation(o);
rotationSet = true;
- if (ctrl.cfg.mustValidate) {
+ if (cfg.mustValidate) {
map.hexDirectionsHide(to);
- ctrl.hud.actionButtons.show(Buttons.DONE.b | ((ctrl.cfg.canCancel) ? Buttons.ABORT.b : 0));
+ ctrl.hud.actionButtons.show(Buttons.DONE.b | ((cfg.canCancel) ? Buttons.ABORT.b : 0));
} else {
execute();
ctrl.setState(StateType.ANIMATION);
diff --git a/core/src/ch/asynk/rustanddust/game/states/StateSelect.java b/core/src/ch/asynk/rustanddust/game/states/StateSelect.java
index 2d97e40..1a7dce2 100644
--- a/core/src/ch/asynk/rustanddust/game/states/StateSelect.java
+++ b/core/src/ch/asynk/rustanddust/game/states/StateSelect.java
@@ -10,11 +10,6 @@ import ch.asynk.rustanddust.RustAndDust;
public class StateSelect extends StateCommon
{
- public StateSelect(Ctrl ctrl, Map map)
- {
- super(ctrl, map);
- }
-
@Override
public void enter(StateType prevState)
{
@@ -112,7 +107,7 @@ public class StateSelect extends StateCommon
selectedHex = hex;
selectedUnit = unit;
- if (isEnemy && !ctrl.cfg.showEnemyPossibilities)
+ if (isEnemy && !cfg.showEnemyPossibilities)
return;
int moves = map.movesCollect(selectedUnit);