diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2015-06-30 06:21:50 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2015-06-30 06:21:50 +0200 |
commit | d74bcf9bf390418df35d94b54d59df0170033f65 (patch) | |
tree | 2ceae1bd287c42b4f109c47d2360199d6076a156 /core/src/ch/asynk/tankontank/game/states | |
parent | 06868b70f82ed30e46ea3fd012a0befc8380bbad (diff) | |
download | RustAndDust-d74bcf9bf390418df35d94b54d59df0170033f65.zip RustAndDust-d74bcf9bf390418df35d94b54d59df0170033f65.tar.gz |
TankOnTank -> CreepingArmor
Diffstat (limited to 'core/src/ch/asynk/tankontank/game/states')
11 files changed, 0 insertions, 1074 deletions
diff --git a/core/src/ch/asynk/tankontank/game/states/StateAnimation.java b/core/src/ch/asynk/tankontank/game/states/StateAnimation.java deleted file mode 100644 index 2e115a9..0000000 --- a/core/src/ch/asynk/tankontank/game/states/StateAnimation.java +++ /dev/null @@ -1,37 +0,0 @@ -package ch.asynk.tankontank.game.states; - -public class StateAnimation extends StateCommon -{ - @Override - public void enter(StateType prevState) - { - ctrl.hud.actionButtons.hide(); - } - - @Override - public void leave(StateType nextState) - { - } - - @Override - public StateType abort() - { - return StateType.ABORT; - } - - @Override - public StateType execute() - { - return StateType.DONE; - } - - @Override - public void touchDown() - { - } - - @Override - public void touchUp() - { - } -} diff --git a/core/src/ch/asynk/tankontank/game/states/StateBreak.java b/core/src/ch/asynk/tankontank/game/states/StateBreak.java deleted file mode 100644 index 9b87c23..0000000 --- a/core/src/ch/asynk/tankontank/game/states/StateBreak.java +++ /dev/null @@ -1,90 +0,0 @@ -package ch.asynk.tankontank.game.states; - -import ch.asynk.tankontank.engine.Orientation; -import ch.asynk.tankontank.game.Unit; -import ch.asynk.tankontank.game.hud.ActionButtons.Buttons; - -import ch.asynk.tankontank.TankOnTank; - -public class StateBreak extends StateCommon -{ - private Orientation o = Orientation.KEEP; - - @Override - public void enter(StateType prevState) - { - activeUnit = null; - ctrl.hud.actionButtons.show(Buttons.DONE.b); - ctrl.hud.pushNotify("Break move possible"); - map.showBreakUnits(); - } - - @Override - public void leave(StateType nextState) - { - map.hideBreakUnits(); - map.hideMove(to); - map.hideDirections(to); - map.hideOrientation(to); - if (activeUnit != null) map.hideMove(activeUnit.getHex()); - } - - @Override - public StateType abort() - { - return StateType.ABORT; - } - - @Override - public StateType execute() - { - return StateType.DONE; - } - - @Override - public void touchDown() - { - } - - @Override - public void touchUp() - { - // TODO : cancel preview move before showing rotation - if (activeUnit == null) { - Unit unit = upHex.getUnit(); - if (map.breakUnits.contains(unit)) { - activeUnit = unit; - map.showMove(upHex); - map.showMove(to); - map.showDirections(to); - map.hideBreakUnits(); - } - } else { - o = Orientation.fromAdj(to, upHex); - - if (o == Orientation.KEEP) return; - - if (ctrl.cfg.mustValidate) { - map.hideDirections(to); - map.showOrientation(to, o); - ctrl.hud.actionButtons.show(Buttons.DONE.b); - } else { - doRotation(o); - ctrl.setState(StateType.ANIMATION); - } - } - } - - private void doRotation(Orientation o) - { - if (activeUnit == null) return; - - map.pathBuilder.init(activeUnit); - if (map.pathBuilder.build(to) == 1) { - map.pathBuilder.orientation = o; - map.moveUnit(activeUnit); - ctrl.setAfterAnimationState(StateType.DONE); - } else - TankOnTank.debug("That's very wrong there should be only one path"); - } -} diff --git a/core/src/ch/asynk/tankontank/game/states/StateCommon.java b/core/src/ch/asynk/tankontank/game/states/StateCommon.java deleted file mode 100644 index a5cc875..0000000 --- a/core/src/ch/asynk/tankontank/game/states/StateCommon.java +++ /dev/null @@ -1,68 +0,0 @@ -package ch.asynk.tankontank.game.states; - -import ch.asynk.tankontank.game.Map; -import ch.asynk.tankontank.game.Hex; -import ch.asynk.tankontank.game.Unit; -import ch.asynk.tankontank.game.Ctrl; -import ch.asynk.tankontank.game.State; - -import ch.asynk.tankontank.TankOnTank; - -public abstract class StateCommon implements State -{ - protected static Ctrl ctrl; - 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; - protected static Unit activeUnit; - protected static Unit selectedUnit; - - protected StateCommon() - { - } - - public StateCommon(Ctrl ctrl, Map map) - { - this.ctrl = ctrl; - this.map = 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); - } - - protected void showPossibilities(Unit unit) - { - if (ctrl.cfg.showMoves && unit.canMove()) map.showPossibleMoves(); - if (ctrl.cfg.showTargets && unit.canEngage()) map.showPossibleTargets(); - if (ctrl.cfg.showMoveAssists && unit.canMove()) map.showMoveableUnits(); - unit.enableOverlay(Unit.MOVE, false); - } - - protected void hidePossibilities() - { - map.hidePossibleMoves(); - map.hidePossibleTargets(); - map.hideMoveableUnits(); - } -} diff --git a/core/src/ch/asynk/tankontank/game/states/StateDeployment.java b/core/src/ch/asynk/tankontank/game/states/StateDeployment.java deleted file mode 100644 index 91b5bd5..0000000 --- a/core/src/ch/asynk/tankontank/game/states/StateDeployment.java +++ /dev/null @@ -1,138 +0,0 @@ -package ch.asynk.tankontank.game.states; - -import ch.asynk.tankontank.engine.Orientation; -import ch.asynk.tankontank.game.Hex; -import ch.asynk.tankontank.game.Zone; -import ch.asynk.tankontank.game.Unit; -import ch.asynk.tankontank.game.UnitList; -import ch.asynk.tankontank.game.hud.ActionButtons.Buttons; - -import ch.asynk.tankontank.TankOnTank; - -public class StateDeployment extends StateCommon -{ - private boolean completed; - private Zone entryZone; - private UnitList deployedUnits = new UnitList(10); - - @Override - public void enter(StateType prevState) - { - if (selectedHex != null) - map.unselectHex(selectedHex); - completed = false; - entryZone = null; - selectedHex = null; - selectedUnit = null; - ctrl.hud.actionButtons.hide(); - ctrl.hud.playerInfo.unitDock.show(); - } - - @Override - public void leave(StateType nextState) - { - selectedUnit = null; - if (selectedHex != null) - map.unselectHex(selectedHex); - if (entryZone != null) - entryZone.enable(Hex.AREA, false); - ctrl.hud.playerInfo.unitDock.hide(); - } - - @Override - public StateType abort() - { - if (activeUnit != null) - undo(); - return StateType.DEPLOYMENT; - } - - @Override - public StateType execute() - { - deployedUnits.clear(); - return StateType.DONE; - } - - @Override - public void touchDown() - { - } - - @Override - public void touchUp() - { - Unit unit = ctrl.hud.playerInfo.unitDock.selectedUnit; - if (!completed && (unit != null) && (unit != activeUnit)) { - showEntryZone(unit); - } else if (selectedUnit != null) { - doRotation(Orientation.fromAdj(selectedHex, upHex)); - } else if (!completed && (entryZone != null) && (upHex != null)) { - if (upHex.isEmpty() && entryZone.contains(upHex)) - unitEnter(activeUnit); - } else { - unit = downHex.getUnit(); - if (deployedUnits.contains(unit)) { - showRotation(unit, downHex); - activeUnit = unit; - } - } - } - - private void showEntryZone(Unit unit) - { - activeUnit = unit; - if (entryZone != null) entryZone.enable(Hex.AREA, false); - entryZone = ctrl.battle.getEntryZone(activeUnit); - entryZone.enable(Hex.AREA, true); - } - - private void undo() - { - map.unselectHex(selectedHex); - map.hideDirections(selectedHex); - map.revertEnter(activeUnit); - activeUnit = null; - selectedUnit = null; - ctrl.hud.update(); - } - - private void unitEnter(Unit unit) - { - selectedUnit = unit; - selectedHex = upHex; - ctrl.player.reinforcement.remove(unit); - map.showOnBoard(unit, upHex, entryZone.orientation); - deployedUnits.add(unit); - entryZone.enable(Hex.AREA, false); - showRotation(unit, upHex); - ctrl.hud.update(); - } - - private void showRotation(Unit unit, Hex hex) - { - selectedUnit = unit; - selectedHex = hex; - map.selectHex(selectedHex); - map.showDirections(selectedHex); - ctrl.hud.playerInfo.unitDock.hide(); - ctrl.hud.actionButtons.show(Buttons.ABORT.b); - } - - private void doRotation(Orientation o) - { - map.unselectHex(selectedHex); - map.hideDirections(selectedHex); - - if (o != Orientation.KEEP) - map.setOnBoard(selectedUnit, selectedHex, o); - - ctrl.hud.actionButtons.hide(); - ctrl.hud.playerInfo.unitDock.show(); - entryZone = null; - activeUnit = null; - selectedUnit = null; - if (ctrl.checkDeploymentDone()) - completed = true; - } -} diff --git a/core/src/ch/asynk/tankontank/game/states/StateEngage.java b/core/src/ch/asynk/tankontank/game/states/StateEngage.java deleted file mode 100644 index 865907e..0000000 --- a/core/src/ch/asynk/tankontank/game/states/StateEngage.java +++ /dev/null @@ -1,105 +0,0 @@ -package ch.asynk.tankontank.game.states; - -import ch.asynk.tankontank.game.Unit; -import ch.asynk.tankontank.game.hud.ActionButtons.Buttons; - -import ch.asynk.tankontank.TankOnTank; - -public class StateEngage extends StateCommon -{ - @Override - public void enter(StateType prevState) - { - map.possibleTargets.clear(); - 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.hidePossibleTargets(); - map.collectPossibleTargets(selectedUnit, ctrl.opponent.units); - map.showPossibleTargets(); - if (to != null) { - // quick fire -> replay touchUp - upHex = to; - touchUp(); - } - selectedUnit.showAttack(); - map.selectHex(selectedHex); - } else - TankOnTank.debug("should not happen"); - } - - @Override - public void leave(StateType nextState) - { - selectedUnit.hideAttack(); - map.hideAttackAssists(); - map.hidePossibleTargets(); - map.unselectHex(selectedHex); - if (to != null) - map.unselectHex(to); - } - - @Override - public StateType abort() - { - map.activatedUnits.clear(); - return StateType.ABORT; - } - - @Override - public StateType execute() - { - StateType nextState = StateType.DONE; - if (map.engageUnit(selectedUnit, activeUnit)) { - ctrl.player.wonEngagementCount += 1; - ctrl.opponent.casualty(activeUnit); - if (map.breakUnits.size() > 0) { - nextState = StateType.BREAK; - } - } else { - ctrl.player.lostEngagementCount += 1; - } - - activeUnit.showTarget(); - ctrl.setAfterAnimationState(nextState); - return StateType.ANIMATION; - } - - @Override - public void touchDown() - { - } - - @Override - public void touchUp() - { - Unit unit = upHex.getUnit(); - - // activeUnit is the target, selectedTarget is the engagement leader - if (unit == selectedUnit) { - ctrl.setState(StateType.ABORT); - } else if ((activeUnit == null) && map.possibleTargets.contains(unit)) { - // ctrl.hud.notify("Engage " + unit); - map.hidePossibleTargets(); - to = upHex; - activeUnit = unit; - activeUnit.showTarget(); - map.collectAttackAssists(selectedUnit, activeUnit, ctrl.player.units); - map.showAttackAssists(); - 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.engagementAssists.contains(unit)) { - map.toggleAttackAssist(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/StateMove.java b/core/src/ch/asynk/tankontank/game/states/StateMove.java deleted file mode 100644 index 9a8195d..0000000 --- a/core/src/ch/asynk/tankontank/game/states/StateMove.java +++ /dev/null @@ -1,193 +0,0 @@ -package ch.asynk.tankontank.game.states; - -import ch.asynk.tankontank.game.Hex; -import ch.asynk.tankontank.game.Unit; -import ch.asynk.tankontank.game.Zone; -import ch.asynk.tankontank.game.hud.ActionButtons.Buttons; - -public class StateMove extends StateCommon -{ - @Override - public void enter(StateType prevState) - { - ctrl.hud.actionButtons.show( - ((map.activatedUnits.size() > 0) ? Buttons.DONE.b : 0) - | (ctrl.cfg.canCancel ? Buttons.ABORT.b : 0)); - - if (prevState == StateType.WITHDRAW) { - if (map.pathBuilder.size() == 1) - ctrl.setState(StateType.ROTATE); - return; - } - - map.pathBuilder.clear(); - - if (prevState == StateType.SELECT) { - // use selectedHex and selectedUnit - activeUnit = selectedUnit; - activeUnit.showMoveable(); - map.pathBuilder.init(activeUnit); - map.collectAndShowMovesAndAssits(activeUnit); - if (to != null) { - // quick move -> replay touchUp - upHex = to; - touchUp(); - } else - checkExit(activeUnit, activeUnit.getHex()); - } else { - // back from rotation -> chose next Pawn - if (selectedUnit.canMove()) { - changeUnit(selectedUnit); - } else { - changeUnit(map.moveableUnits.get(0)); - } - } - - activeUnit.enableOverlay(Unit.MOVE, false); - } - - @Override - public void leave(StateType nextState) - { - if (nextState == StateType.WITHDRAW) - return; - - // hide all but assists : want them when in rotation - activeUnit.hideMoveable(); - map.hidePossibleMoves(); - map.unselectHex(activeUnit.getHex()); - if (to != null) - map.hidePath(to); - - if (nextState != StateType.SELECT) { - if (to == null) - to = activeUnit.getHex(); - } - } - - @Override - public StateType abort() - { - hideAssists(); - if (activeUnit.justEntered()) { - map.revertEnter(activeUnit); - return StateType.ABORT; - } - int n = map.activatedUnits.size(); - if (n == 0) - return StateType.ABORT; - map.revertMoves(); - return StateType.ANIMATION; - } - - @Override - public StateType execute() - { - hideAssists(); - // be sure that the hq is activated - if (selectedUnit.canMove() && (map.activatedUnits.size() > 0)) - selectedUnit.setMoved(); - - return StateType.DONE; - } - - @Override - public void touchDown() - { - } - - @Override - public void touchUp() - { - if (upHex == activeUnit.getHex()) { - if (to != null) - map.hidePath(to); - to = null; - map.pathBuilder.clear(); - ctrl.setState(StateType.ROTATE); - return; - } - - int s = map.pathBuilder.size(); - - Unit unit = upHex.getUnit(); - - if (map.moveableUnits.contains(unit)) { - if(unit != activeUnit) - changeUnit(unit); - } else if ((s == 0) && map.possibleMoves.contains(upHex)) { - s = collectPaths(upHex); - } else if (map.pathBuilder.contains(upHex)) { - s = togglePoint(downHex, s); - } - - if (s == 1) { - if (!checkExit(activeUnit, upHex)) - ctrl.setState(StateType.ROTATE); - } - } - - private void hideAssists() - { - map.hideMoveableUnits(); - } - - private void changeUnit(Unit unit) - { - if (activeUnit != null ) { - map.unselectHex(activeUnit.getHex()); - if (activeUnit.canMove()) - activeUnit.enableOverlay(Unit.MOVE, true); - } - activeUnit = unit; - Hex hex = activeUnit.getHex(); - map.pathBuilder.init(activeUnit, hex); - activeUnit.showMoveable(); - map.hidePossibleMoves(); - map.collectPossibleMoves(activeUnit); - map.showPossibleMoves(); - map.selectHex(hex); - activeUnit.enableOverlay(Unit.MOVE, false); - ctrl.hud.notify(activeUnit.toString()); - checkExit(activeUnit, hex); - } - - private int collectPaths(Hex hex) - { - to = hex; - int s = map.pathBuilder.build(to); - map.showMove(to); - map.hidePossibleMoves(); - map.showPathBuilder(); - return s; - } - - private int togglePoint(Hex hex, int s) - { - if (hex == activeUnit.getHex()) { - // - } else if (hex == to) { - // - } else { - map.hidePathBuilder(); - map.togglePathOverlay(hex); - s = map.togglePathBuilderHex(hex); - map.showPathBuilder(); - } - - return s; - } - - private boolean checkExit(Unit unit, Hex hex) - { - if ((hex == unit.getHex()) && (unit.justEntered())) - return false; - Zone exitZone = ctrl.battle.getExitZone(unit); - if ((exitZone == null) || !exitZone.contains(hex)) - return false; - if ((unit.getHex() != hex) && !map.pathBuilder.canExit(exitZone.orientation)) - return false; - ctrl.setState(StateType.WITHDRAW); - return true; - } -} diff --git a/core/src/ch/asynk/tankontank/game/states/StatePromote.java b/core/src/ch/asynk/tankontank/game/states/StatePromote.java deleted file mode 100644 index 9f327e7..0000000 --- a/core/src/ch/asynk/tankontank/game/states/StatePromote.java +++ /dev/null @@ -1,42 +0,0 @@ -package ch.asynk.tankontank.game.states; - -import ch.asynk.tankontank.game.Unit; - -public class StatePromote extends StateCommon -{ - @Override - public void enter(StateType prevState) - { - ctrl.setAfterAnimationState(StateType.DONE); - ctrl.setState(StateType.ANIMATION); - map.promoteUnit(selectedUnit); - } - - @Override - public void leave(StateType nextState) - { - map.unselectHex(selectedHex); - } - - @Override - public StateType abort() - { - return StateType.ABORT; - } - - @Override - public StateType execute() - { - return StateType.DONE; - } - - @Override - public void touchDown() - { - } - - @Override - public void touchUp() - { - } -} diff --git a/core/src/ch/asynk/tankontank/game/states/StateReinforcement.java b/core/src/ch/asynk/tankontank/game/states/StateReinforcement.java deleted file mode 100644 index 3ac5c95..0000000 --- a/core/src/ch/asynk/tankontank/game/states/StateReinforcement.java +++ /dev/null @@ -1,87 +0,0 @@ -package ch.asynk.tankontank.game.states; - -import ch.asynk.tankontank.game.Hex; -import ch.asynk.tankontank.game.Zone; -import ch.asynk.tankontank.game.Unit; -import ch.asynk.tankontank.game.hud.ActionButtons.Buttons; - -public class StateReinforcement extends StateCommon -{ - private Zone entryZone; - - @Override - public void enter(StateType prevState) - { - map.clearAll(); - if (selectedHex != null) - map.unselectHex(selectedHex); - entryZone = null; - selectedHex = null; - ctrl.hud.playerInfo.unitDock.show(); - } - - @Override - public void leave(StateType nextState) - { - if (selectedHex != null) - map.unselectHex(selectedHex); - if (entryZone != null) - entryZone.enable(Hex.AREA, false); - ctrl.hud.playerInfo.unitDock.hide(); - } - - @Override - public StateType abort() - { - return StateType.ABORT; - } - - @Override - public StateType execute() - { - return StateType.DONE; - } - - @Override - public void touchDown() - { - } - - @Override - public void touchUp() - { - Unit unit = ctrl.hud.playerInfo.unitDock.selectedUnit; - if ((unit != null) && (unit != activeUnit)) - changeUnit(unit); - else if ((entryZone != null) && upHex.isEmpty() && entryZone.contains(upHex)) - unitEnter(activeUnit); - else - ctrl.setState(StateType.SELECT); - } - - private void changeUnit(Unit unit) - { - activeUnit = unit; - if (entryZone != null) - 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)); - } - - private void unitEnter(Unit unit) - { - selectedUnit = unit; - selectedHex = upHex; - map.selectHex(selectedHex); - entryZone.enable(Hex.AREA, false); - if (map.enterBoard(unit, upHex, entryZone.allowedMoves)) { - if (unit.getMovementPoints() > 0) - ctrl.setState(StateType.MOVE); - else - ctrl.setState(StateType.ROTATE); - } else { - ctrl.hud.notify("Can not enter the map at that position"); - } - } -} diff --git a/core/src/ch/asynk/tankontank/game/states/StateRotate.java b/core/src/ch/asynk/tankontank/game/states/StateRotate.java deleted file mode 100644 index d297840..0000000 --- a/core/src/ch/asynk/tankontank/game/states/StateRotate.java +++ /dev/null @@ -1,111 +0,0 @@ -package ch.asynk.tankontank.game.states; - -import ch.asynk.tankontank.engine.Orientation; -import ch.asynk.tankontank.game.hud.ActionButtons.Buttons; - -import ch.asynk.tankontank.TankOnTank; - -public class StateRotate extends StateCommon -{ - private boolean rotateOnly; - private boolean rotationSet; - - @Override - public void enter(StateType prevState) - { - ctrl.hud.actionButtons.show((ctrl.cfg.canCancel && (map.moveableUnits.size() > 1))? Buttons.ABORT.b : 0); - - if (activeUnit == null) - activeUnit = selectedUnit; - if (to == null) - to = activeUnit.getHex(); - - if (!map.pathBuilder.isSet()) { - map.pathBuilder.init(activeUnit); - map.pathBuilder.build(to); - } - - if (map.pathBuilder.size() != 1) - TankOnTank.debug("ERROR: pathBuilder.size() == " + map.pathBuilder.size()); - - rotateOnly = (to == activeUnit.getHex()); - - if (!rotateOnly) - map.showPath(to); - map.selectHex(activeUnit.getHex()); - map.showDirections(to); - - rotationSet = false; - } - - @Override - public void leave(StateType nextState) - { - map.unselectHex(activeUnit.getHex()); - map.hidePath(to); - map.hideDirections(to); - map.hideOrientation(to); - map.pathBuilder.clear(); - to = null; - } - - @Override - public StateType abort() - { - StateType nextState = StateType.ABORT; - ctrl.hud.actionButtons.hide(); - if (activeUnit.justEntered()) { - map.revertEnter(activeUnit); - nextState = StateType.ABORT; - } else if (map.activatedUnits.size() == 0) { - map.hideMoveableUnits(); - } else { - nextState = StateType.MOVE; - } - return nextState; - } - - @Override - public StateType execute() - { - StateType whenDone = StateType.DONE; - - if (map.moveUnit(activeUnit) > 0) - whenDone = StateType.MOVE; - - ctrl.setAfterAnimationState(whenDone); - return StateType.ANIMATION; - } - - @Override - public void touchDown() - { - } - - @Override - public void touchUp() - { - if (rotationSet) return; - - Orientation o = Orientation.fromAdj(to, upHex); - if (o == Orientation.KEEP) { - ctrl.setState(StateType.ABORT); - return; - } - - if (!activeUnit.justEntered() && rotateOnly && (o == activeUnit.getOrientation())) - return; - - map.pathBuilder.orientation = o; - rotationSet = true; - - if (ctrl.cfg.mustValidate) { - map.hideDirections(to); - map.showOrientation(to, o); - ctrl.hud.actionButtons.show(Buttons.DONE.b | ((ctrl.cfg.canCancel) ? Buttons.ABORT.b : 0)); - } else { - execute(); - ctrl.setState(StateType.ANIMATION); - } - } -} diff --git a/core/src/ch/asynk/tankontank/game/states/StateSelect.java b/core/src/ch/asynk/tankontank/game/states/StateSelect.java deleted file mode 100644 index 387fbb0..0000000 --- a/core/src/ch/asynk/tankontank/game/states/StateSelect.java +++ /dev/null @@ -1,132 +0,0 @@ -package ch.asynk.tankontank.game.states; - -import ch.asynk.tankontank.game.Map; -import ch.asynk.tankontank.game.Hex; -import ch.asynk.tankontank.game.Unit; -import ch.asynk.tankontank.game.Ctrl; -import ch.asynk.tankontank.game.hud.ActionButtons.Buttons; - -import ch.asynk.tankontank.TankOnTank; - -public class StateSelect extends StateCommon -{ - public StateSelect(Ctrl ctrl, Map map) - { - super(ctrl, map); - } - - @Override - public void enter(StateType prevState) - { - to = null; - selectedHex = null; - selectedUnit = null; - activeUnit = null; - map.clearAll(); - ctrl.hud.actionButtons.hide(); - } - - @Override - public void leave(StateType nextState) - { - hidePossibilities(); - } - - @Override - public StateType abort() - { - if (selectedHex != null) - map.unselectHex(selectedHex); - hidePossibilities(); - map.clearAll(); - return StateType.ABORT; - } - - @Override - public StateType execute() - { - return StateType.DONE; - } - - @Override - public void touchDown() - { - } - - @Override - public void touchUp() - { - if (!isEnemy) { - if (map.possibleMoves.contains(upHex)) { - // quick move - to = upHex; - ctrl.setState(StateType.MOVE); - return; - } - if (map.possibleTargets.contains(upHex.getUnit())) { - // quick fire - to = upHex; - ctrl.setState(StateType.ENGAGE); - return; - } - } - - if (selectedHex != null) - map.unselectHex(selectedHex); - - hidePossibilities(); - if (upHex.isOffMap()) { - selectedUnit = null; - return; - } - - Unit unit = upHex.getUnit(); - - if (unit == null) { - isEnemy = false; - ctrl.hud.actionButtons.hide(); - map.clearAll(); - selectedUnit = null; - return; - } - - isEnemy = ctrl.player.isEnemy(unit); - if (!isEnemy && (unit == selectedUnit) && unit.canMove()) { - if (unit.isHq()) { - ctrl.hud.notify("HQ activation"); - select(upHex, unit, isEnemy); - ctrl.setState(StateType.MOVE); - } else { - // quick rotate - to = upHex; - ctrl.setState(StateType.ROTATE); - } - } else { - select(upHex, unit, isEnemy); - ctrl.hud.notify(selectedUnit.toString()); - } - } - - private void select(Hex hex, Unit unit, boolean isEnemy) - { - selectedHex = hex; - selectedUnit = unit; - - if (isEnemy && !ctrl.cfg.showEnemyPossibilities) - return; - - int moves = map.collectPossibleMoves(selectedUnit); - int targets = map.collectPossibleTargets(selectedUnit, (isEnemy ? ctrl.player.units : ctrl.opponent.units)); - - if (moves > 0) - map.collectMoveableUnits(selectedUnit); - - if ((moves > 0) || (targets > 0)) { - map.selectHex(selectedHex); - showPossibilities(selectedUnit); - } - - ctrl.hud.actionButtons.show((ctrl.player.canPromote(selectedUnit)) ? Buttons.PROMOTE.b : 0 ); - TankOnTank.debug("Select", selectedHex.toString() + " " + selectedUnit + (isEnemy ? " enemy " : " friend ")); - } -} diff --git a/core/src/ch/asynk/tankontank/game/states/StateWithdraw.java b/core/src/ch/asynk/tankontank/game/states/StateWithdraw.java deleted file mode 100644 index 87c33b8..0000000 --- a/core/src/ch/asynk/tankontank/game/states/StateWithdraw.java +++ /dev/null @@ -1,71 +0,0 @@ -package ch.asynk.tankontank.game.states; - -import ch.asynk.tankontank.game.Zone; -import ch.asynk.tankontank.game.Hex; -import ch.asynk.tankontank.game.Unit; - -public class StateWithdraw extends StateCommon -{ - @Override - public void enter(StateType prevState) - { - ctrl.hud.askExitBoard(); - } - - @Override - public void leave(StateType nextState) - { - } - - @Override - public StateType abort() - { - return StateType.MOVE; - } - - @Override - public StateType execute() - { - if (activeUnit == null) - activeUnit = selectedUnit; - - ctrl.setAfterAnimationState(withdraw(activeUnit)); - return StateType.ANIMATION; - } - - @Override - public void touchDown() - { - } - - @Override - public void touchUp() - { - } - - private StateType withdraw(Unit unit) - { - Zone exitZone = ctrl.battle.getExitZone(unit); - Hex hex = unit.getHex(); - - // rotation - if (map.pathBuilder.to == null) - map.pathBuilder.build(hex); - - Hex exitHex = (Hex) map.pathBuilder.to; - if (!exitZone.contains(exitHex)) - throw new RuntimeException(String.format("%s not in exitZone", exitHex)); - - map.pathBuilder.setExit(exitZone.orientation); - - unit.hideMoveable(); - if (to != null) - map.hidePath(to); - map.hidePossibleMoves(); - map.unselectHex(hex); - - if (map.exitBoard(unit) > 0) - return StateType.MOVE; - return StateType.DONE; - } -} |