From be3948fb249ebe2724f3de160b4d9869d165e4e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 20 Jan 2015 12:34:05 +0100 Subject: StateEscape -> StateExit --- core/src/ch/asynk/tankontank/game/Ctrl.java | 8 +-- .../asynk/tankontank/game/states/StateEscape.java | 73 ---------------------- .../ch/asynk/tankontank/game/states/StateExit.java | 71 +++++++++++++++++++++ 3 files changed, 75 insertions(+), 77 deletions(-) delete mode 100644 core/src/ch/asynk/tankontank/game/states/StateEscape.java create mode 100644 core/src/ch/asynk/tankontank/game/states/StateExit.java diff --git a/core/src/ch/asynk/tankontank/game/Ctrl.java b/core/src/ch/asynk/tankontank/game/Ctrl.java index 0a1c416..4ca116f 100644 --- a/core/src/ch/asynk/tankontank/game/Ctrl.java +++ b/core/src/ch/asynk/tankontank/game/Ctrl.java @@ -16,7 +16,7 @@ import ch.asynk.tankontank.game.states.StateBreak; import ch.asynk.tankontank.game.states.StateAnimation; import ch.asynk.tankontank.game.states.StateReinforcement; import ch.asynk.tankontank.game.states.StateDeployment; -import ch.asynk.tankontank.game.states.StateEscape; +import ch.asynk.tankontank.game.states.StateExit; public class Ctrl implements Disposable { @@ -43,7 +43,7 @@ public class Ctrl implements Disposable private State animationState; private State reinforcementState; private State deploymentState; - private State escapeState; + private State exitState; private int animationCount = 0; @@ -74,7 +74,7 @@ public class Ctrl implements Disposable this.animationState = new StateAnimation(); this.reinforcementState = new StateReinforcement(); this.deploymentState = new StateDeployment(); - this.escapeState = new StateEscape(); + this.exitState = new StateExit(); this.state = selectState; this.stateType = StateType.DONE; @@ -230,7 +230,7 @@ public class Ctrl implements Disposable this.state = breakState; break; case ESCAPE: - this.state = escapeState; + this.state = exitState; break; case ANIMATION: this.blockMap = true; diff --git a/core/src/ch/asynk/tankontank/game/states/StateEscape.java b/core/src/ch/asynk/tankontank/game/states/StateEscape.java deleted file mode 100644 index 98bedd9..0000000 --- a/core/src/ch/asynk/tankontank/game/states/StateEscape.java +++ /dev/null @@ -1,73 +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 StateEscape 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.setAnimationCount(1); - ctrl.setAfterAnimationState(escape(activeUnit)); - return StateType.ANIMATION; - } - - @Override - public void touchDown() - { - } - - @Override - public void touchUp() - { - } - - private StateType escape(Unit unit) - { - // ctrl.hud.notify("Escape " + unit); - - Zone exitZone = ctrl.battle.getExitZone(unit); - Hex hex = unit.getHex(); - - if (selectedHex == hex) - map.possiblePaths.build(hex); - - Hex exitHex = (Hex) map.possiblePaths.to; - if (!exitZone.contains(exitHex)) - throw new RuntimeException(String.format("%s not in exitZone", exitHex)); - - map.possiblePaths.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; - } -} diff --git a/core/src/ch/asynk/tankontank/game/states/StateExit.java b/core/src/ch/asynk/tankontank/game/states/StateExit.java new file mode 100644 index 0000000..f1dadba --- /dev/null +++ b/core/src/ch/asynk/tankontank/game/states/StateExit.java @@ -0,0 +1,71 @@ +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 StateExit 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.setAnimationCount(1); + ctrl.setAfterAnimationState(escape(activeUnit)); + return StateType.ANIMATION; + } + + @Override + public void touchDown() + { + } + + @Override + public void touchUp() + { + } + + private StateType escape(Unit unit) + { + Zone exitZone = ctrl.battle.getExitZone(unit); + Hex hex = unit.getHex(); + + if (selectedHex == hex) + map.possiblePaths.build(hex); + + Hex exitHex = (Hex) map.possiblePaths.to; + if (!exitZone.contains(exitHex)) + throw new RuntimeException(String.format("%s not in exitZone", exitHex)); + + map.possiblePaths.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; + } +} -- cgit v1.1-2-g2b99