diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-18 20:01:32 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-18 20:01:32 +0100 |
commit | 2b0b92f2b3135fd06a809be3ee94ec8e103ab51a (patch) | |
tree | 7dac1a8b71e17953807da5d2ca9c21dc9303f597 /core/src/ch/asynk/tankontank/game/states | |
parent | c2d604c40fcd9ae8c587a68071fc8e3d4d9a3ce3 (diff) | |
download | RustAndDust-2b0b92f2b3135fd06a809be3ee94ec8e103ab51a.zip RustAndDust-2b0b92f2b3135fd06a809be3ee94ec8e103ab51a.tar.gz |
add StateEscape and Hud.askExitBoard()
Diffstat (limited to 'core/src/ch/asynk/tankontank/game/states')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/states/StateEscape.java | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/core/src/ch/asynk/tankontank/game/states/StateEscape.java b/core/src/ch/asynk/tankontank/game/states/StateEscape.java new file mode 100644 index 0000000..7ff9fa8 --- /dev/null +++ b/core/src/ch/asynk/tankontank/game/states/StateEscape.java @@ -0,0 +1,68 @@ +package ch.asynk.tankontank.game.states; + +import ch.asynk.tankontank.engine.Zone; +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 done() + { + 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); + + if (map.possiblePaths.size() == 1) + map.possiblePaths.setExit(exitZone.orientation); + else + map.possiblePaths.build(map.getAdjTileAt(unit.getTile(), exitZone.orientation)); + + unit.hideMoveable(); + map.hidePossibleMoves(); + map.unselectHex(unit.getHex()); + + map.leaveBoard(unit); + ctrl.player.unitEscape(unit); + + if (map.movePawn(activeUnit, exitZone.orientation) > 0) + return StateType.MOVE; + return StateType.DONE; + } +} |