summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/rustanddust
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/ch/asynk/rustanddust')
-rw-r--r--core/src/ch/asynk/rustanddust/game/Ctrl.java3
-rw-r--r--core/src/ch/asynk/rustanddust/game/Map.java92
-rw-r--r--core/src/ch/asynk/rustanddust/game/states/StateBreak.java9
-rw-r--r--core/src/ch/asynk/rustanddust/game/states/StateCommon.java9
-rw-r--r--core/src/ch/asynk/rustanddust/game/states/StateEngage.java23
-rw-r--r--core/src/ch/asynk/rustanddust/game/states/StateMove.java13
-rw-r--r--core/src/ch/asynk/rustanddust/game/states/StateRotate.java7
-rw-r--r--core/src/ch/asynk/rustanddust/game/states/StateSelect.java3
8 files changed, 50 insertions, 109 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/Ctrl.java b/core/src/ch/asynk/rustanddust/game/Ctrl.java
index faa2bc7..5bc39a3 100644
--- a/core/src/ch/asynk/rustanddust/game/Ctrl.java
+++ b/core/src/ch/asynk/rustanddust/game/Ctrl.java
@@ -6,7 +6,6 @@ import com.badlogic.gdx.math.Vector3;
import ch.asynk.rustanddust.RustAndDust;
import ch.asynk.rustanddust.ui.Position;
-import ch.asynk.rustanddust.game.Map.UnitType;
import ch.asynk.rustanddust.game.State.StateType;
import ch.asynk.rustanddust.game.states.StateSelect;
import ch.asynk.rustanddust.game.states.StateMove;
@@ -166,7 +165,7 @@ public class Ctrl implements Disposable
if (nextState == StateType.DONE) {
map.actionDone();
- if (map.unitsSize(UnitType.ACTIVATED) > 0) {
+ if (map.unitsActivatedSize() > 0) {
RustAndDust.debug("Ctrl", "burn down 1AP");
hud.notify("1 Action Point burnt", 0.6f, Position.BOTTOM_CENTER, false);
player.burnDownOneAp();
diff --git a/core/src/ch/asynk/rustanddust/game/Map.java b/core/src/ch/asynk/rustanddust/game/Map.java
index ef048c1..5e27a1a 100644
--- a/core/src/ch/asynk/rustanddust/game/Map.java
+++ b/core/src/ch/asynk/rustanddust/game/Map.java
@@ -259,11 +259,11 @@ public abstract class Map extends Board implements MoveToAnimationCb, ObjectiveS
public void collectUpdate(Unit unit)
{
movesHide();
- unitsHide(UnitType.MOVEABLE);
+ unitsMoveableHide();
movesCollect(unit);
collectMoveable(unit);
movesShow();
- unitsShow(UnitType.MOVEABLE);
+ unitsMoveableShow();
activatedUnits.clear();
}
@@ -524,81 +524,29 @@ public abstract class Map extends Board implements MoveToAnimationCb, ObjectiveS
return (e.success ? 1 : 0);
}
- // SHOW / HIDE
+ public Unit unitsMoveableGet(int i) { return moveableUnits.get(i); }
- public enum UnitType
- {
- MOVEABLE,
- TARGETS,
- ASSISTS,
- BREAK_THROUGH,
- ACTIVATED
- };
+ public void unitsTargetClear() { targetUnits.clear(); }
+ public void unitsActivatedClear() { activatedUnits.clear(); }
- public void unitsClear(UnitType unitType)
- {
- getUnitList(unitType).clear();
- }
+ public int unitsActivatedSize() { return activatedUnits.size(); }
+ public int unitsMoveableSize() { return moveableUnits.size(); }
+ public int unitsBreakThroughSize() { return breakthroughUnits.size(); }
- public int unitsSize(UnitType unitType)
- {
- return getUnitList(unitType).size();
- }
+ public boolean unitsTargetContains(Unit unit) { return targetUnits.contains(unit); }
+ public boolean unitsAssistContains(Unit unit) { return assistUnits.contains(unit); }
+ public boolean unitsMoveableContains(Unit unit) { return moveableUnits.contains(unit); }
+ public boolean unitsBreakThroughContains(Unit unit) { return breakthroughUnits.contains(unit); }
- public Unit unitsGet(UnitType unitType, int i)
- {
- return getUnitList(unitType).get(i);
- }
-
- public boolean unitsContains(UnitType unitType, Unit unit)
- {
- return getUnitList(unitType).contains(unit);
- }
-
- private UnitList getUnitList(UnitType unitType)
- {
- UnitList ul = null;
- switch(unitType) {
- case MOVEABLE:
- ul = moveableUnits;
- break;
- case TARGETS:
- ul = targetUnits;
- break;
- case ASSISTS:
- ul = assistUnits;
- break;
- case BREAK_THROUGH:
- ul = breakthroughUnits;
- break;
- case ACTIVATED:
- ul = activatedUnits;
- break;
- }
- return ul;
- }
+ public void unitsTargetShow() { unitsShowOverlay(targetUnits, Unit.TARGET, true); }
+ public void unitsTargetHide() { unitsShowOverlay(targetUnits, Unit.TARGET, false); }
+ public void unitsAssistShow() { unitsShowOverlay(assistUnits, Unit.MAY_FIRE, true); }
+ public void unitsAssistHide() { unitsShowOverlay(assistUnits, Unit.MAY_FIRE, false); unitsShowOverlay(assistUnits, Unit.FIRE, false); }
+ public void unitsMoveableShow() { unitsShowOverlay(moveableUnits, Unit.MOVE, true); }
+ public void unitsMoveableHide() { unitsShowOverlay(moveableUnits, Unit.MOVE, false); }
+ public void unitsBreakThroughShow() { unitsShowOverlay(breakthroughUnits, Unit.MOVE, true); }
+ public void unitsBreakThroughHide() { unitsShowOverlay(breakthroughUnits, Unit.MOVE, false); }
- public void unitsShow(UnitType unitType) { unitsShow(unitType, true); }
- public void unitsHide(UnitType unitType) { unitsShow(unitType, false); }
- private void unitsShow(UnitType unitType, boolean show)
- {
- switch(unitType) {
- case MOVEABLE:
- unitsShowOverlay(moveableUnits, Unit.MOVE, show);
- break;
- case TARGETS:
- unitsShowOverlay(targetUnits, Unit.TARGET, show);
- break;
- case ASSISTS:
- unitsShowOverlay(assistUnits, Unit.MAY_FIRE, show);
- if (!show)
- unitsShowOverlay(assistUnits, Unit.FIRE, show);
- break;
- case BREAK_THROUGH:
- unitsShowOverlay(breakthroughUnits, Unit.MOVE, show);
- break;
- }
- }
private void unitsShowOverlay(UnitList units, int overlay, boolean on)
{
for (Unit unit : units)
diff --git a/core/src/ch/asynk/rustanddust/game/states/StateBreak.java b/core/src/ch/asynk/rustanddust/game/states/StateBreak.java
index 1555f6b..aff63d0 100644
--- a/core/src/ch/asynk/rustanddust/game/states/StateBreak.java
+++ b/core/src/ch/asynk/rustanddust/game/states/StateBreak.java
@@ -2,7 +2,6 @@ package ch.asynk.rustanddust.game.states;
import ch.asynk.rustanddust.engine.Orientation;
import ch.asynk.rustanddust.game.Unit;
-import ch.asynk.rustanddust.game.Map.UnitType;
import ch.asynk.rustanddust.game.hud.ActionButtons.Buttons;
import ch.asynk.rustanddust.RustAndDust;
@@ -17,13 +16,13 @@ public class StateBreak extends StateCommon
activeUnit = null;
ctrl.hud.actionButtons.show(Buttons.DONE.b);
ctrl.hud.pushNotify("Break move possible");
- map.unitsShow(UnitType.BREAK_THROUGH);
+ map.unitsBreakThroughShow();
}
@Override
public void leave(StateType nextState)
{
- map.unitsHide(UnitType.BREAK_THROUGH);
+ map.unitsBreakThroughHide();
map.hexMoveHide(to);
map.hexDirectionsHide(to);
if (activeUnit != null) map.hexMoveHide(activeUnit.getHex());
@@ -52,12 +51,12 @@ public class StateBreak extends StateCommon
// TODO : cancel preview move before showing rotation
if (activeUnit == null) {
Unit unit = upHex.getUnit();
- if (map.unitsContains(UnitType.BREAK_THROUGH, unit)) {
+ if (map.unitsBreakThroughContains(unit)) {
activeUnit = unit;
map.hexMoveShow(upHex);
map.hexMoveShow(to);
map.hexDirectionsShow(to);
- map.unitsHide(UnitType.BREAK_THROUGH);
+ map.unitsBreakThroughHide();
}
} else {
o = Orientation.fromAdj(to, upHex);
diff --git a/core/src/ch/asynk/rustanddust/game/states/StateCommon.java b/core/src/ch/asynk/rustanddust/game/states/StateCommon.java
index a2aa490..f56d3a5 100644
--- a/core/src/ch/asynk/rustanddust/game/states/StateCommon.java
+++ b/core/src/ch/asynk/rustanddust/game/states/StateCommon.java
@@ -1,7 +1,6 @@
package ch.asynk.rustanddust.game.states;
import ch.asynk.rustanddust.game.Map;
-import ch.asynk.rustanddust.game.Map.UnitType;
import ch.asynk.rustanddust.game.Hex;
import ch.asynk.rustanddust.game.Unit;
import ch.asynk.rustanddust.game.Ctrl;
@@ -55,15 +54,15 @@ 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.unitsShow(UnitType.TARGETS);
- if (ctrl.cfg.showMoveAssists && unit.canMove()) map.unitsShow(UnitType.MOVEABLE);
+ if (ctrl.cfg.showTargets && unit.canEngage()) map.unitsTargetShow();
+ if (ctrl.cfg.showMoveAssists && unit.canMove()) map.unitsMoveableShow();
unit.enableOverlay(Unit.MOVE, false);
}
protected void hidePossibilities()
{
map.movesHide();
- map.unitsHide(UnitType.TARGETS);
- map.unitsHide(UnitType.MOVEABLE);
+ map.unitsTargetHide();
+ map.unitsMoveableHide();
}
}
diff --git a/core/src/ch/asynk/rustanddust/game/states/StateEngage.java b/core/src/ch/asynk/rustanddust/game/states/StateEngage.java
index 1ff4c56..5daf1e8 100644
--- a/core/src/ch/asynk/rustanddust/game/states/StateEngage.java
+++ b/core/src/ch/asynk/rustanddust/game/states/StateEngage.java
@@ -1,7 +1,6 @@
package ch.asynk.rustanddust.game.states;
import ch.asynk.rustanddust.game.Unit;
-import ch.asynk.rustanddust.game.Map.UnitType;
import ch.asynk.rustanddust.game.hud.ActionButtons.Buttons;
import ch.asynk.rustanddust.RustAndDust;
@@ -11,16 +10,16 @@ public class StateEngage extends StateCommon
@Override
public void enter(StateType prevState)
{
- map.unitsClear(UnitType.TARGETS);
+ map.unitsTargetClear();
ctrl.hud.actionButtons.show(ctrl.cfg.canCancel ? Buttons.ABORT.b : 0);
// activeUnit is the target
if (prevState == StateType.SELECT) {
activeUnit = null;
// use selectedHex and selectedUnit
- map.unitsHide(UnitType.TARGETS);
+ map.unitsTargetHide();
map.collectTargets(selectedUnit, ctrl.opponent.units);
- map.unitsShow(UnitType.TARGETS);
+ map.unitsTargetShow();
if (to != null) {
// quick fire -> replay touchUp
upHex = to;
@@ -36,8 +35,8 @@ public class StateEngage extends StateCommon
public void leave(StateType nextState)
{
selectedUnit.hideAttack();
- map.unitsHide(UnitType.ASSISTS);
- map.unitsHide(UnitType.TARGETS);
+ map.unitsAssistHide();
+ map.unitsTargetHide();
map.hexUnselect(selectedHex);
if (to != null)
map.hexUnselect(to);
@@ -46,7 +45,7 @@ public class StateEngage extends StateCommon
@Override
public StateType abort()
{
- map.unitsClear(UnitType.ACTIVATED);
+ map.unitsActivatedClear();
return StateType.ABORT;
}
@@ -57,7 +56,7 @@ public class StateEngage extends StateCommon
if (map.engageUnit(selectedUnit, activeUnit)) {
ctrl.player.wonEngagementCount += 1;
ctrl.opponent.casualty(activeUnit);
- if (map.unitsSize(UnitType.BREAK_THROUGH) > 0) {
+ if (map.unitsBreakThroughSize() > 0) {
nextState = StateType.BREAK;
}
} else {
@@ -82,20 +81,20 @@ public class StateEngage extends StateCommon
// activeUnit is the target, selectedTarget is the engagement leader
if (unit == selectedUnit) {
ctrl.setState(StateType.ABORT);
- } else if ((activeUnit == null) && map.unitsContains(UnitType.TARGETS, unit)) {
+ } else if ((activeUnit == null) && map.unitsTargetContains(unit)) {
// ctrl.hud.notify("Engage " + unit);
- map.unitsHide(UnitType.TARGETS);
+ map.unitsTargetHide();
to = upHex;
activeUnit = unit;
activeUnit.showTarget();
map.collectAssists(selectedUnit, activeUnit, ctrl.player.units);
- map.unitsShow(UnitType.ASSISTS);
+ map.unitsAssistShow();
ctrl.hud.actionButtons.show((ctrl.cfg.mustValidate ? Buttons.DONE.b : 0) | (ctrl.cfg.canCancel ? Buttons.ABORT.b : 0));
}
else if (unit == activeUnit) {
ctrl.setState(StateType.DONE);
}
- else if ((activeUnit != null) && map.unitsContains(UnitType.ASSISTS, unit)) {
+ else if ((activeUnit != null) && map.unitsAssistContains(unit)) {
map.toggleAssist(unit);
// if(map.toggleAssist(unit))
// ctrl.hud.notify(unit + " will fire");
diff --git a/core/src/ch/asynk/rustanddust/game/states/StateMove.java b/core/src/ch/asynk/rustanddust/game/states/StateMove.java
index 659b6ab..d601aa6 100644
--- a/core/src/ch/asynk/rustanddust/game/states/StateMove.java
+++ b/core/src/ch/asynk/rustanddust/game/states/StateMove.java
@@ -3,7 +3,6 @@ package ch.asynk.rustanddust.game.states;
import ch.asynk.rustanddust.game.Hex;
import ch.asynk.rustanddust.game.Unit;
import ch.asynk.rustanddust.game.Zone;
-import ch.asynk.rustanddust.game.Map.UnitType;
import ch.asynk.rustanddust.game.hud.ActionButtons.Buttons;
public class StateMove extends StateCommon
@@ -12,7 +11,7 @@ public class StateMove extends StateCommon
public void enter(StateType prevState)
{
ctrl.hud.actionButtons.show(
- ((map.unitsSize(UnitType.ACTIVATED) > 0) ? Buttons.DONE.b : 0)
+ ((map.unitsActivatedSize() > 0) ? Buttons.DONE.b : 0)
| (ctrl.cfg.canCancel ? Buttons.ABORT.b : 0));
if (prevState == StateType.WITHDRAW) {
@@ -40,7 +39,7 @@ public class StateMove extends StateCommon
if (selectedUnit.canMove()) {
changeUnit(selectedUnit);
} else {
- changeUnit(map.unitsGet(UnitType.MOVEABLE, 0));
+ changeUnit(map.unitsMoveableGet(0));
}
}
@@ -74,7 +73,7 @@ public class StateMove extends StateCommon
map.revertEnter(activeUnit);
return StateType.ABORT;
}
- int n = map.unitsSize(UnitType.ACTIVATED);
+ int n = map.unitsActivatedSize();
if (n == 0)
return StateType.ABORT;
map.revertMoves();
@@ -86,7 +85,7 @@ public class StateMove extends StateCommon
{
hideAssists();
// be sure that the hq is activated
- if (selectedUnit.canMove() && (map.unitsSize(UnitType.ACTIVATED) > 0))
+ if (selectedUnit.canMove() && (map.unitsActivatedSize() > 0))
selectedUnit.setMoved();
return StateType.DONE;
@@ -113,7 +112,7 @@ public class StateMove extends StateCommon
Unit unit = upHex.getUnit();
- if (map.unitsContains(UnitType.MOVEABLE, unit)) {
+ if (map.unitsMoveableContains(unit)) {
if(unit != activeUnit)
changeUnit(unit);
} else if ((s == 0) && map.movesContains(upHex)) {
@@ -130,7 +129,7 @@ public class StateMove extends StateCommon
private void hideAssists()
{
- map.unitsHide(UnitType.MOVEABLE);
+ map.unitsMoveableHide();
}
private void changeUnit(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 5c55a9d..5beddcd 100644
--- a/core/src/ch/asynk/rustanddust/game/states/StateRotate.java
+++ b/core/src/ch/asynk/rustanddust/game/states/StateRotate.java
@@ -1,7 +1,6 @@
package ch.asynk.rustanddust.game.states;
import ch.asynk.rustanddust.engine.Orientation;
-import ch.asynk.rustanddust.game.Map.UnitType;
import ch.asynk.rustanddust.game.hud.ActionButtons.Buttons;
import ch.asynk.rustanddust.RustAndDust;
@@ -14,7 +13,7 @@ public class StateRotate extends StateCommon
@Override
public void enter(StateType prevState)
{
- ctrl.hud.actionButtons.show((ctrl.cfg.canCancel && (map.unitsSize(UnitType.MOVEABLE) > 1))? Buttons.ABORT.b : 0);
+ ctrl.hud.actionButtons.show((ctrl.cfg.canCancel && (map.unitsMoveableSize() > 1))? Buttons.ABORT.b : 0);
if (activeUnit == null)
activeUnit = selectedUnit;
@@ -57,8 +56,8 @@ public class StateRotate extends StateCommon
if (activeUnit.justEntered()) {
map.revertEnter(activeUnit);
nextState = StateType.ABORT;
- } else if (map.unitsSize(UnitType.ACTIVATED) == 0) {
- map.unitsHide(UnitType.MOVEABLE);
+ } else if (map.unitsActivatedSize() == 0) {
+ map.unitsMoveableHide();
} else {
nextState = StateType.MOVE;
}
diff --git a/core/src/ch/asynk/rustanddust/game/states/StateSelect.java b/core/src/ch/asynk/rustanddust/game/states/StateSelect.java
index 3ec2274..d7738c4 100644
--- a/core/src/ch/asynk/rustanddust/game/states/StateSelect.java
+++ b/core/src/ch/asynk/rustanddust/game/states/StateSelect.java
@@ -1,7 +1,6 @@
package ch.asynk.rustanddust.game.states;
import ch.asynk.rustanddust.game.Map;
-import ch.asynk.rustanddust.game.Map.UnitType;
import ch.asynk.rustanddust.game.Hex;
import ch.asynk.rustanddust.game.Unit;
import ch.asynk.rustanddust.game.Ctrl;
@@ -64,7 +63,7 @@ public class StateSelect extends StateCommon
ctrl.setState(StateType.MOVE);
return;
}
- if (map.unitsContains(UnitType.TARGETS, upHex.getUnit())) {
+ if (map.unitsTargetContains(upHex.getUnit())) {
// quick fire
to = upHex;
ctrl.setState(StateType.ENGAGE);