summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank/game
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-11-05 12:13:57 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-11-05 12:13:57 +0100
commit3fdaaa05538525e828067e0eb4b91e7758ba023c (patch)
treefd99a160502a3f981a14de6db4cb050efd095731 /core/src/ch/asynk/tankontank/game
parentfbed4659a16b7e28ab960e28f11d11b841ed1d86 (diff)
downloadRustAndDust-3fdaaa05538525e828067e0eb4b91e7758ba023c.zip
RustAndDust-3fdaaa05538525e828067e0eb4b91e7758ba023c.tar.gz
PossiblePaths: first call init(Pawn, Tile from) then build(Tile to)
Diffstat (limited to 'core/src/ch/asynk/tankontank/game')
-rw-r--r--core/src/ch/asynk/tankontank/game/Map.java5
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateBreak.java3
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateMove.java12
3 files changed, 9 insertions, 11 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java
index 64d3329..6e6d959 100644
--- a/core/src/ch/asynk/tankontank/game/Map.java
+++ b/core/src/ch/asynk/tankontank/game/Map.java
@@ -105,11 +105,6 @@ public abstract class Map extends Board
return collectPossibleMoves(pawn, possibleMoves);
}
- public int collectPossiblePaths(Pawn pawn, Hex to)
- {
- return possiblePaths.init(pawn, to);
- }
-
public int togglePossiblePathHex(Hex hex)
{
return possiblePaths.toggleCtrlTile(hex);
diff --git a/core/src/ch/asynk/tankontank/game/states/StateBreak.java b/core/src/ch/asynk/tankontank/game/states/StateBreak.java
index 820ad97..1a40f08 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateBreak.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateBreak.java
@@ -76,7 +76,8 @@ public class StateBreak extends StateCommon
if (done || (activeUnit == null)) return;
done = true;
- if (map.collectPossiblePaths(activeUnit, to) == 1) {
+ map.possiblePaths.init(activeUnit);
+ if (map.possiblePaths.build(to) == 1) {
map.possiblePaths.orientation = o;
map.movePawn(activeUnit, o);
ctrl.setAnimationCount(1);
diff --git a/core/src/ch/asynk/tankontank/game/states/StateMove.java b/core/src/ch/asynk/tankontank/game/states/StateMove.java
index e279564..cbacef5 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateMove.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateMove.java
@@ -11,12 +11,12 @@ public class StateMove extends StateCommon
boolean moreThanOne = ((map.moveablePawns.size() + map.activatedPawns.size()) > 1);
ctrl.hud.show(false, true, true, false, moreThanOne, ctrl.cfg.canCancel);
ctrl.hud.moveBtn.setOn();
- map.possiblePaths.clear();
if (fromSelect) {
// use selectedHex and selectedUnit
activeUnit = selectedUnit;
activeUnit.showMoveable();
+ map.possiblePaths.init(activeUnit);
map.collectAndShowMovesAndAssits(activeUnit);
if (to != null) {
// quick move -> replay touchUp
@@ -40,6 +40,7 @@ public class StateMove extends StateCommon
activeUnit.hideMoveable();
map.hidePossibleMoves();
map.unselectHex(activeUnit.getHex());
+ map.possiblePaths.clear();
if (to != null) {
map.hideFinalPath(to);
}
@@ -66,7 +67,7 @@ public class StateMove extends StateCommon
if(unit != activeUnit)
changeUnit(unit);
} else if ((s == 0) && map.possibleMoves.contains(upHex)) {
- s = collectPaths();
+ s = collectPaths(upHex);
} else if (map.possiblePaths.contains(upHex)) {
s = togglePoint(downHex, s);
}
@@ -106,6 +107,7 @@ public class StateMove extends StateCommon
map.unselectHex(activeUnit.getHex());
activeUnit = unit;
Hex hex = activeUnit.getHex();
+ map.possiblePaths.init(activeUnit, hex);
map.selectHex(hex);
activeUnit.showMoveable();
map.hidePossibleMoves();
@@ -113,10 +115,10 @@ public class StateMove extends StateCommon
map.showPossibleMoves();
}
- private int collectPaths()
+ private int collectPaths(Hex hex)
{
- to = upHex;
- int s = map.collectPossiblePaths(activeUnit, to);
+ to = hex;
+ int s = map.possiblePaths.build(to);
map.showMove(to);
map.hidePossibleMoves();
map.showPossiblePaths();