diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-03-23 09:47:22 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-03-23 09:47:22 +0100 |
commit | 4970de4c506c469cf2afb24c1b20b8cd6b1218f7 (patch) | |
tree | 3d983eb46240e330bf36f73ca2cea9168dc94e16 | |
parent | 2cf0c9e8f96c38d86a22cd21955bc7e8444bc316 (diff) | |
download | RustAndDust-4970de4c506c469cf2afb24c1b20b8cd6b1218f7.zip RustAndDust-4970de4c506c469cf2afb24c1b20b8cd6b1218f7.tar.gz |
Map: moveableUnits,assistUnits,breakthroughUnits -> activableUnits
9 files changed, 36 insertions, 46 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/map/Map1Units.java b/core/src/ch/asynk/rustanddust/game/map/Map1Units.java index 156f1f0..c018d56 100644 --- a/core/src/ch/asynk/rustanddust/game/map/Map1Units.java +++ b/core/src/ch/asynk/rustanddust/game/map/Map1Units.java @@ -9,20 +9,16 @@ import ch.asynk.rustanddust.game.UnitList; public abstract class Map1Units extends Map0Hex { - protected final UnitList moveableUnits; protected final UnitList targetUnits; - protected final UnitList assistUnits; - protected final UnitList breakthroughUnits; + protected final UnitList activableUnits; protected final UnitList activatedUnits; public Map1Units(final RustAndDust game, Texture map, SelectedTile hex) { super(game, map, hex); - moveableUnits = new UnitList(6); targetUnits = new UnitList(10); - assistUnits = new UnitList(6); - breakthroughUnits = new UnitList(4); + activableUnits = new UnitList(6); activatedUnits = new UnitList(7); } @@ -35,24 +31,22 @@ public abstract class Map1Units extends Map0Hex public void clearUnits() { - moveableUnits.clear(); targetUnits.clear(); - assistUnits.clear(); - breakthroughUnits.clear(); + activableUnits.clear(); activatedUnits.clear(); } public int collectMoveable(Unit unit) { if (unit.canHQMove()) - collectMoveAssists(unit, moveableUnits.asPawns()); + collectMoveAssists(unit, activableUnits.asPawns()); else - moveableUnits.clear(); + activableUnits.clear(); if (unit.canMove()) - moveableUnits.add(unit); + activableUnits.add(unit); - return moveableUnits.size(); + return activableUnits.size(); } public int collectTargets(Unit unit, UnitList foes) @@ -66,7 +60,7 @@ public abstract class Map1Units extends Map0Hex public int collectAssists(Unit unit, Unit target, UnitList units) { - int s = collectAttackAssists(unit, target, units.asPawns(), assistUnits.asPawns()); + int s = collectAttackAssists(unit, target, units.asPawns(), activableUnits.asPawns()); activatedUnits.add(unit); return s; } @@ -86,28 +80,23 @@ public abstract class Map1Units extends Map0Hex } } - public Unit unitsMoveableGet(int i) { return moveableUnits.get(i); } + public Unit unitsMoveableGet(int i) { return activableUnits.get(i); } public void unitsTargetClear() { targetUnits.clear(); } public void unitsActivatedClear() { activatedUnits.clear(); } public int unitsActivatedSize() { return activatedUnits.size(); } - public int unitsMoveableSize() { return moveableUnits.size(); } - public int unitsBreakThroughSize() { return breakthroughUnits.size(); } + public int unitsActivableSize() { return activableUnits.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 boolean unitsActivableContains(Unit unit) { return activableUnits.contains(unit); } 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.ACTIVEABLE, true); } - public void unitsMoveableHide() { unitsShowOverlay(moveableUnits, Unit.ACTIVEABLE, false); } - public void unitsBreakThroughShow() { unitsShowOverlay(breakthroughUnits, Unit.ACTIVEABLE, true); } - public void unitsBreakThroughHide() { unitsShowOverlay(breakthroughUnits, Unit.ACTIVEABLE, false); } + public void unitsAssistShow() { unitsShowOverlay(activableUnits, Unit.MAY_FIRE, true); } + public void unitsAssistHide() { unitsShowOverlay(activableUnits, Unit.MAY_FIRE, false); unitsShowOverlay(activableUnits, Unit.FIRE, false); } + public void unitsActivableShow() { unitsShowOverlay(activableUnits, Unit.ACTIVEABLE, true); } + public void unitsActivableHide() { unitsShowOverlay(activableUnits, Unit.ACTIVEABLE, false); } private void unitsShowOverlay(UnitList units, int overlay, boolean on) { diff --git a/core/src/ch/asynk/rustanddust/game/map/Map2Moves.java b/core/src/ch/asynk/rustanddust/game/map/Map2Moves.java index 5750320..4f87971 100644 --- a/core/src/ch/asynk/rustanddust/game/map/Map2Moves.java +++ b/core/src/ch/asynk/rustanddust/game/map/Map2Moves.java @@ -55,11 +55,11 @@ public abstract class Map2Moves extends Map1Units public void collectUpdate(Unit unit) { movesHide(); - unitsMoveableHide(); + unitsActivableHide(); movesCollect(unit); collectMoveable(unit); movesShow(); - unitsMoveableShow(); + unitsActivableShow(); activatedUnits.clear(); } diff --git a/core/src/ch/asynk/rustanddust/game/map/Map4Orders.java b/core/src/ch/asynk/rustanddust/game/map/Map4Orders.java index e8ad751..3eb4d19 100644 --- a/core/src/ch/asynk/rustanddust/game/map/Map4Orders.java +++ b/core/src/ch/asynk/rustanddust/game/map/Map4Orders.java @@ -121,7 +121,7 @@ public abstract class Map4Orders extends Map3Animations private void initMove(Unit unit) { - moveableUnits.remove(unit); + activableUnits.remove(unit); activatedUnits.add(unit); playMoveSound(unit); } @@ -178,13 +178,13 @@ public abstract class Map4Orders extends Map3Animations case REGULAR: initMove(unit); movePawn(unit, move, this); - r = moveableUnits.size(); + r = activableUnits.size(); break; case EXIT: initMove(unit); movePawn(unit, move, this); battle.getPlayer().unitWithdraw(unit); - r = moveableUnits.size(); + r = activableUnits.size(); break; case SET: setPawnOnto(unit, move); @@ -209,7 +209,7 @@ public abstract class Map4Orders extends Map3Animations { resolveEngagement(e); - breakthroughUnits.clear(); + activableUnits.clear(); activatedUnits.clear(); activatedUnits.add(e.attacker); @@ -219,7 +219,7 @@ public abstract class Map4Orders extends Map3Animations for (Unit u : activatedUnits) { u.engage(); if (u.canBreak()) - breakthroughUnits.add(u); + activableUnits.add(u); } if (e.success) { diff --git a/core/src/ch/asynk/rustanddust/game/states/StateBreak.java b/core/src/ch/asynk/rustanddust/game/states/StateBreak.java index f94dfe6..317051d 100644 --- a/core/src/ch/asynk/rustanddust/game/states/StateBreak.java +++ b/core/src/ch/asynk/rustanddust/game/states/StateBreak.java @@ -15,13 +15,13 @@ public class StateBreak extends StateCommon activeUnit = null; ctrl.hud.actionButtons.show(Buttons.DONE.b); ctrl.hud.notify("Break Through possible"); - map.unitsBreakThroughShow(); + map.unitsActivableShow(); } @Override public void leave(StateType nextState) { - map.unitsBreakThroughHide(); + map.unitsActivableHide(); map.hexMoveHide(to); map.hexDirectionsHide(to); if (activeUnit != null) map.hexMoveHide(activeUnit.getHex()); @@ -45,12 +45,12 @@ public class StateBreak extends StateCommon // TODO : cancel preview move before showing rotation if (activeUnit == null) { Unit unit = hex.getUnit(); - if (map.unitsBreakThroughContains(unit)) { + if (map.unitsActivableContains(unit)) { activeUnit = unit; map.hexMoveShow(hex); map.hexMoveShow(to); map.hexDirectionsShow(to); - map.unitsBreakThroughHide(); + map.unitsActivableHide(); } } else { o = Orientation.fromAdj(to, hex); diff --git a/core/src/ch/asynk/rustanddust/game/states/StateCommon.java b/core/src/ch/asynk/rustanddust/game/states/StateCommon.java index 3d5ef9a..b894c0f 100644 --- a/core/src/ch/asynk/rustanddust/game/states/StateCommon.java +++ b/core/src/ch/asynk/rustanddust/game/states/StateCommon.java @@ -37,7 +37,7 @@ public abstract class StateCommon implements State { if (cfg.showMoves && unit.canMove()) map.movesShow(); if (cfg.showTargets && unit.canEngage()) map.unitsTargetShow(); - if (cfg.showMoveAssists && unit.canMove()) map.unitsMoveableShow(); + if (cfg.showMoveAssists && unit.canMove()) map.unitsActivableShow(); unit.hideActiveable(); } @@ -45,7 +45,7 @@ public abstract class StateCommon implements State { map.movesHide(); map.unitsTargetHide(); - map.unitsMoveableHide(); + map.unitsActivableHide(); } @Override diff --git a/core/src/ch/asynk/rustanddust/game/states/StateEngage.java b/core/src/ch/asynk/rustanddust/game/states/StateEngage.java index 37fed6c..c45acb6 100644 --- a/core/src/ch/asynk/rustanddust/game/states/StateEngage.java +++ b/core/src/ch/asynk/rustanddust/game/states/StateEngage.java @@ -49,11 +49,12 @@ public class StateEngage extends StateCommon @Override public StateType execute() { + map.unitsAssistHide(); StateType nextState = StateType.DONE; if (map.engageUnit(selectedUnit, activeUnit)) { ctrl.battle.getPlayer().engagementWon += 1; ctrl.battle.getOpponent().casualty(activeUnit); - if (map.unitsBreakThroughSize() > 0) { + if (map.unitsActivableSize() > 0) { nextState = StateType.BREAK; } } else { @@ -85,7 +86,7 @@ public class StateEngage extends StateCommon else if (unit == activeUnit) { ctrl.setState(StateType.DONE); } - else if ((activeUnit != null) && map.unitsAssistContains(unit)) { + else if ((activeUnit != null) && map.unitsActivableContains(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 16d5dd3..5e11f85 100644 --- a/core/src/ch/asynk/rustanddust/game/states/StateMove.java +++ b/core/src/ch/asynk/rustanddust/game/states/StateMove.java @@ -104,7 +104,7 @@ public class StateMove extends StateCommon Unit unit = hex.getUnit(); - if (map.unitsMoveableContains(unit)) { + if (map.unitsActivableContains(unit)) { if (unit != activeUnit) changeUnit(unit); } else if ((s == 0) && map.movesContains(hex)) { @@ -116,7 +116,7 @@ public class StateMove extends StateCommon private void hideAssists() { - map.unitsMoveableHide(); + map.unitsActivableHide(); } 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 c2a96e8..7408472 100644 --- a/core/src/ch/asynk/rustanddust/game/states/StateRotate.java +++ b/core/src/ch/asynk/rustanddust/game/states/StateRotate.java @@ -12,7 +12,7 @@ public class StateRotate extends StateCommon @Override public void enter(StateType prevState) { - if (!cfg.showMoveAssists) map.unitsMoveableHide(); + if (!cfg.showMoveAssists) map.unitsActivableHide(); if (activeUnit == null) activeUnit = selectedUnit; @@ -56,7 +56,7 @@ public class StateRotate extends StateCommon map.revertEnter(activeUnit); nextState = StateType.ABORT; } else if (map.unitsActivatedSize() == 0) { - map.unitsMoveableHide(); + map.unitsActivableHide(); } 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 53c68ff..d6fb021 100644 --- a/core/src/ch/asynk/rustanddust/game/states/StateSelect.java +++ b/core/src/ch/asynk/rustanddust/game/states/StateSelect.java @@ -80,7 +80,7 @@ public class StateSelect extends StateCommon isEnemy = ctrl.battle.getPlayer().isEnemy(unit); if (!isEnemy && (unit == selectedUnit) && unit.canMove()) { - if (unit.isHq() && (map.unitsMoveableSize() > 1)) { + if (unit.isHq() && (map.unitsActivableSize() > 1)) { ctrl.hud.notify("HQ activation"); select(hex, unit, isEnemy); ctrl.setState(StateType.MOVE); |