summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2015-01-18 22:50:18 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2015-01-18 22:50:18 +0100
commit05cd151256d038f838f69bec4d1935f213ad3544 (patch)
treeae188e26d66a40d45443fc6fc48410ecf3699f4b
parent5fec5d6c036198472c92f468e216256562b05e0b (diff)
downloadRustAndDust-05cd151256d038f838f69bec4d1935f213ad3544.zip
RustAndDust-05cd151256d038f838f69bec4d1935f213ad3544.tar.gz
Map: exitBoard() does move the unit, add revertEnter(Unit)
-rw-r--r--core/src/ch/asynk/tankontank/game/Map.java28
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateDeployment.java3
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateEscape.java3
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateMove.java3
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateRotate.java3
5 files changed, 24 insertions, 16 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java
index 066de97..ca1fffd 100644
--- a/core/src/ch/asynk/tankontank/game/Map.java
+++ b/core/src/ch/asynk/tankontank/game/Map.java
@@ -293,15 +293,19 @@ public abstract class Map extends Board
return true;
}
- public void exitBoard(Unit unit)
+ public int exitBoard(Unit unit)
{
- Hex hex = unit.getHex();
- if (unit.justEntered()) {
- objectives.revert();
- unit.reset();
- }
- removePawn(unit);
- activatedUnits.add(unit);
+ // if (unit.justEntered()) {
+ // objectives.revert();
+ // unit.reset();
+ // }
+
+ Move move = possiblePaths.getMove();
+ move.setExit();
+
+ movePawn(unit, move, notifyDoneAnimation(unit), objectives);
+
+ return startMove(unit);
}
public void promoteUnit(final Player player, final Unit unit)
@@ -338,6 +342,14 @@ public abstract class Map extends Board
objectives.revert();
}
+ public void revertEnter(Unit unit)
+ {
+ unit.reset();
+ removePawn(unit);
+ objectives.revert();
+ ctrl.player.revertUnitEntry(unit);
+ }
+
private int startMove(Unit unit)
{
moveableUnits.remove(unit);
diff --git a/core/src/ch/asynk/tankontank/game/states/StateDeployment.java b/core/src/ch/asynk/tankontank/game/states/StateDeployment.java
index 24e8b12..ee8d684 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateDeployment.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateDeployment.java
@@ -89,8 +89,7 @@ public class StateDeployment extends StateCommon
{
map.unselectHex(selectedHex);
map.hideDirections(selectedHex);
- map.exitBoard(selectedUnit);
- ctrl.player.revertUnitEntry(selectedUnit);
+ map.revertEnter(activeUnit);
activeUnit = null;
selectedUnit = null;
ctrl.hud.update();
diff --git a/core/src/ch/asynk/tankontank/game/states/StateEscape.java b/core/src/ch/asynk/tankontank/game/states/StateEscape.java
index c6a0cf4..98e4a8b 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateEscape.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateEscape.java
@@ -60,10 +60,9 @@ public class StateEscape extends StateCommon
map.hidePossibleMoves();
map.unselectHex(unit.getHex());
- map.exitBoard(unit);
ctrl.player.unitEscape(unit);
- if (map.moveUnit(activeUnit) > 0)
+ if (map.exitBoard(unit) > 0)
return StateType.MOVE;
return StateType.DONE;
}
diff --git a/core/src/ch/asynk/tankontank/game/states/StateMove.java b/core/src/ch/asynk/tankontank/game/states/StateMove.java
index c56971c..7f2767b 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateMove.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateMove.java
@@ -70,8 +70,7 @@ public class StateMove extends StateCommon
{
hideAssists();
if (activeUnit.justEntered()) {
- map.exitBoard(activeUnit);
- ctrl.player.revertUnitEntry(activeUnit);
+ map.revertEnter(activeUnit);
return StateType.ABORT;
}
int n = map.activatedUnits.size();
diff --git a/core/src/ch/asynk/tankontank/game/states/StateRotate.java b/core/src/ch/asynk/tankontank/game/states/StateRotate.java
index c282733..4331d3d 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateRotate.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateRotate.java
@@ -55,8 +55,7 @@ public class StateRotate extends StateCommon
StateType nextState = StateType.ABORT;
ctrl.hud.actionButtons.hide();
if (activeUnit.justEntered()) {
- map.exitBoard(activeUnit);
- ctrl.player.revertUnitEntry(activeUnit);
+ map.revertEnter(activeUnit);
nextState = StateType.ABORT;
} else if (map.activatedUnits.size() == 0) {
map.hideMoveableUnits();