diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-31 14:07:39 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-31 14:07:39 +0100 |
commit | 0c56e7f556277cf9518d0fb191539125e2e6adbf (patch) | |
tree | d4f18b3deb000994b9992ab95bc4029afd83a9e4 /core/src/ch/asynk/tankontank/game | |
parent | 8ccb332b71aee3f16b354d015485780698580220 (diff) | |
download | RustAndDust-0c56e7f556277cf9518d0fb191539125e2e6adbf.zip RustAndDust-0c56e7f556277cf9518d0fb191539125e2e6adbf.tar.gz |
use new PossiblePaths class
Diffstat (limited to 'core/src/ch/asynk/tankontank/game')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Map.java | 15 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/states/StateMove.java | 13 |
2 files changed, 14 insertions, 14 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java index e6554e2..296ddbe 100644 --- a/core/src/ch/asynk/tankontank/game/Map.java +++ b/core/src/ch/asynk/tankontank/game/Map.java @@ -14,6 +14,7 @@ import ch.asynk.tankontank.engine.PawnSet; import ch.asynk.tankontank.engine.TileSet; import ch.asynk.tankontank.engine.Board; import ch.asynk.tankontank.engine.Orientation; +import ch.asynk.tankontank.engine.PossiblePaths; import ch.asynk.tankontank.engine.gfx.animations.AnimationSequence; import ch.asynk.tankontank.engine.gfx.animations.SpriteAnimation; import ch.asynk.tankontank.engine.gfx.animations.SoundAnimation; @@ -25,7 +26,7 @@ public abstract class Map extends Board private final Ctrl ctrl; public final Board.TileCollection possibleMoves; - public final Board.TileCollection possiblePaths; + public final PossiblePaths possiblePaths; public final Board.PawnCollection moveablePawns; public final Board.PawnCollection possibleTargets; @@ -53,7 +54,7 @@ public abstract class Map extends Board setup(); possibleMoves = new TileSet(this, 40); - possiblePaths = new TileSet(this, 10); + possiblePaths = new PossiblePaths(this, 10, 20, 5, 10); moveablePawns = new PawnSet(this, 6); possibleTargets = new PawnSet(this, 10); @@ -104,12 +105,12 @@ public abstract class Map extends Board public int collectPossiblePaths(Pawn pawn, Hex to) { - return collectPossiblePaths(pawn, to, possiblePaths); + return possiblePaths.init(pawn, to); } - public int possiblePathsPointToggle(Hex hex) + public int togglePossiblePathHex(Hex hex) { - return possiblePathsFilterToggle(hex, possiblePaths); + return possiblePaths.toggleCtrlTile(hex); } public int collectPossibleTargets(Pawn pawn, Iterator<Pawn> foes) @@ -178,8 +179,8 @@ public abstract class Map extends Board public int movePawn(Pawn pawn, Orientation o) { System.err.println(" movePawn : " + pawn.getTile() + " " + o); - int cost = getPathCost(pawn, 0); - movePawn(pawn, cost, o, notifyDoneAnimation(pawn)); + possiblePaths.setLastOrientation(o); + movePawn(pawn, possiblePaths, notifyDoneAnimation(pawn)); return startMove(pawn); } diff --git a/core/src/ch/asynk/tankontank/game/states/StateMove.java b/core/src/ch/asynk/tankontank/game/states/StateMove.java index bce5baf..89d7535 100644 --- a/core/src/ch/asynk/tankontank/game/states/StateMove.java +++ b/core/src/ch/asynk/tankontank/game/states/StateMove.java @@ -9,7 +9,6 @@ public class StateMove extends StateCommon @Override public void enter(boolean fromSelect) { - map.possiblePaths.clear(); boolean moreThanOne = ((map.moveablePawns.size() + map.activatedPawns.size()) > 1); ctrl.hud.show(false, true, true, false, moreThanOne, ctrl.cfg.canCancel); ctrl.hud.moveBtn.setOn(); @@ -70,7 +69,7 @@ public class StateMove extends StateCommon } else if ((s == 0) && map.possibleMoves.contains(upHex)) { s = collectPaths(); } else if (map.possiblePaths.contains(upHex)) { - s = togglePoint(s); + s = togglePoint(downHex, s); } if (s == 1) { @@ -127,16 +126,16 @@ public class StateMove extends StateCommon return s; } - private int togglePoint(int s) + private int togglePoint(Hex hex, int s) { - if (downHex == activeUnit.getHex()) { + if (hex == activeUnit.getHex()) { // - } else if (downHex == to) { + } else if (hex == to) { // } else { map.hidePossiblePaths(); - map.togglePathOverlay(downHex); - s = map.possiblePathsPointToggle(downHex); + map.togglePathOverlay(hex); + s = map.togglePossiblePathHex(hex); map.showPossiblePaths(); } |