From 8ce0d341aa7aa67cb2223169e9ba3e0cd8b0c97d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Sun, 30 Nov 2014 00:01:47 +0100 Subject: StateDeployment: touch out of orientation complete rotation too, do not show DONE button --- .../tankontank/game/states/StateDeployment.java | 29 ++++++++++------------ 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/core/src/ch/asynk/tankontank/game/states/StateDeployment.java b/core/src/ch/asynk/tankontank/game/states/StateDeployment.java index aad241c..e8e20ae 100644 --- a/core/src/ch/asynk/tankontank/game/states/StateDeployment.java +++ b/core/src/ch/asynk/tankontank/game/states/StateDeployment.java @@ -31,6 +31,7 @@ public class StateDeployment extends StateCommon @Override public void leave(StateType nextState) { + selectedUnit = null; if (selectedHex != null) map.unselectHex(selectedHex); if (entryZone != null) @@ -63,25 +64,20 @@ public class StateDeployment extends StateCommon { Unit unit = ctrl.hud.playerInfo.unitDock.selectedUnit; if (!done && (unit != null) && (unit != activeUnit)) { - changeUnit(unit); + showEntryZone(unit); } else if (selectedUnit != null) { - Orientation o = Orientation.fromAdj(selectedHex, upHex); - if (o != Orientation.KEEP) - doRotation(o); + doRotation(Orientation.fromAdj(selectedHex, upHex)); } else if (!done && (entryZone != null) && (upHex != null)) { if (upHex.isEmpty() && entryZone.contains(upHex)) unitEnter(activeUnit); } else { unit = downHex.getUnit(); - if (deployedUnits.contains(unit)) { - selectedUnit = unit; - selectedHex = downHex; - showRotation(); - } + if (deployedUnits.contains(unit)) + showRotation(unit, downHex); } } - private void changeUnit(Unit unit) + private void showEntryZone(Unit unit) { activeUnit = unit; if (entryZone != null) entryZone.enable(Hex.AREA, false); @@ -108,12 +104,14 @@ public class StateDeployment extends StateCommon map.enterBoard(unit, upHex, entryZone.orientation); deployedUnits.add(unit); entryZone.enable(Hex.AREA, false); - showRotation(); + showRotation(unit, upHex); ctrl.hud.update(); } - private void showRotation() + private void showRotation(Unit unit, Hex hex) { + selectedUnit = unit; + selectedHex = hex; map.selectHex(selectedHex); map.showDirections(selectedHex); ctrl.hud.playerInfo.unitDock.hide(); @@ -124,15 +122,14 @@ public class StateDeployment extends StateCommon { map.unselectHex(selectedHex); map.hideDirections(selectedHex); - selectedUnit.setRotation(o.r()); + if (o != Orientation.KEEP) + selectedUnit.setRotation(o.r()); ctrl.hud.actionButtons.hide(); ctrl.hud.playerInfo.unitDock.show(); entryZone = null; activeUnit = null; selectedUnit = null; - if (ctrl.checkDeploymentDone()) { + if (ctrl.checkDeploymentDone()) done = true; - ctrl.hud.actionButtons.show(Buttons.DONE.b); - } } } -- cgit v1.1-2-g2b99