diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-31 15:45:58 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-31 15:45:58 +0100 |
commit | ea211dc3b942c26874fecf6812d4894a364dfc07 (patch) | |
tree | 18b70d9191ca4e042c57bdf6fab5fa74a9621342 | |
parent | f2b3e093d2602bafa0669ef90a376a75cf4b7489 (diff) | |
download | RustAndDust-ea211dc3b942c26874fecf6812d4894a364dfc07.zip RustAndDust-ea211dc3b942c26874fecf6812d4894a364dfc07.tar.gz |
Map,States: implement infantry move after successfull attack
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Ctrl.java | 6 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Map.java | 12 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/State.java | 1 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/states/StateAttack.java | 7 |
5 files changed, 23 insertions, 5 deletions
@@ -12,8 +12,6 @@ Board: Game: - End Turn button in Select State - - attack - - infantry move after won fight - Ace -> may reroll the dice - add options to hide moves/targets/assists even in action - HUD position left/right diff --git a/core/src/ch/asynk/tankontank/game/Ctrl.java b/core/src/ch/asynk/tankontank/game/Ctrl.java index 3ecb455..bbc18a3 100644 --- a/core/src/ch/asynk/tankontank/game/Ctrl.java +++ b/core/src/ch/asynk/tankontank/game/Ctrl.java @@ -9,6 +9,7 @@ import ch.asynk.tankontank.game.states.StateMove; import ch.asynk.tankontank.game.states.StateRotate; import ch.asynk.tankontank.game.states.StatePromote; import ch.asynk.tankontank.game.states.StateAttack; +import ch.asynk.tankontank.game.states.StateBreak; import ch.asynk.tankontank.game.states.StateAnimation; public class Ctrl implements Disposable @@ -26,6 +27,7 @@ public class Ctrl implements Disposable private State rotateState; private State promoteState; private State attackState; + private State breakState; private State animationState; private int animationCount = 0; @@ -48,6 +50,7 @@ public class Ctrl implements Disposable this.rotateState = new StateRotate(); this.promoteState = new StatePromote(); this.attackState = new StateAttack(); + this.breakState = new StateBreak(); this.animationState = new StateAnimation(); this.state = selectState; @@ -141,6 +144,9 @@ public class Ctrl implements Disposable case ATTACK: this.state = attackState; break; + case BREAK: + this.state = breakState; + break; case ANIMATION: this.state = animationState; break; diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java index f391076..db0f6b6 100644 --- a/core/src/ch/asynk/tankontank/game/Map.java +++ b/core/src/ch/asynk/tankontank/game/Map.java @@ -32,6 +32,7 @@ public abstract class Map extends Board public final Board.PawnCollection possibleTargets; public final Board.PawnCollection attackAssists; public final Board.PawnCollection activatedPawns; + public final Board.PawnCollection breakPawns; private final SpriteAnimation explosion; private final SpriteAnimation explosions; @@ -59,8 +60,8 @@ public abstract class Map extends Board possibleTargets = new PawnSet(this, 10); attackAssists = new PawnSet(this, 6); - activatedPawns = new PawnSet(this, 7); + breakPawns = new PawnSet(this, 4); } @Override @@ -82,6 +83,7 @@ public abstract class Map extends Board moveablePawns.clear(); attackAssists.clear(); activatedPawns.clear(); + breakPawns.clear(); } public Hex getHexAt(float x, float y) @@ -269,8 +271,12 @@ public abstract class Map extends Board } })); - for (Pawn p : activatedPawns) + breakPawns.clear(); + for (Pawn p : activatedPawns) { p.attack(target); + if (p.isA(Unit.UnitType.INFANTRY)) + breakPawns.add(p); + } if ((activatedPawns.size() == 1) && pawn.isA(Unit.UnitType.AT_GUN) && target.isHardTarget()) activatedPawns.clear(); @@ -304,6 +310,8 @@ public abstract class Map extends Board public void showAttackAssists() { attackAssists.enable(Unit.ATTACK_ASSIST, true); } public void hideAttackAssists() { attackAssists.enable(Unit.ATTACK, false); attackAssists.enable(Unit.ATTACK_ASSIST, false); } + public void showBreakPawns() { breakPawns.enable(Unit.MOVE, true); } + public void hideBreakPawns() { breakPawns.enable(Unit.MOVE, false); } public void selectHex(Hex hex) { enableOverlayOn(hex, Hex.SELECT, true); } diff --git a/core/src/ch/asynk/tankontank/game/State.java b/core/src/ch/asynk/tankontank/game/State.java index 8f004c4..d1d64ef 100644 --- a/core/src/ch/asynk/tankontank/game/State.java +++ b/core/src/ch/asynk/tankontank/game/State.java @@ -7,6 +7,7 @@ public interface State MOVE, ROTATE, ATTACK, + BREAK, PROMOTE, ANIMATION }; diff --git a/core/src/ch/asynk/tankontank/game/states/StateAttack.java b/core/src/ch/asynk/tankontank/game/states/StateAttack.java index 84ee3d8..34f7d61 100644 --- a/core/src/ch/asynk/tankontank/game/states/StateAttack.java +++ b/core/src/ch/asynk/tankontank/game/states/StateAttack.java @@ -81,8 +81,13 @@ public class StateAttack extends StateCommon int d1 = ctrl.player.d6(); int d2 = ctrl.player.d6(); System.err.print(" attack (" + selectedHex.getCol() + ";" + selectedHex.getRow() + ") -> (" + to.getCol() + ";" + to.getRow() + ") : 2D6 -> (" + d1 + " + " + d2 + ")"); - if (map.attackPawn(selectedUnit, activeUnit, d1 + d2)) + if (map.attackPawn(selectedUnit, activeUnit, d1 + d2)) { ctrl.player.casualty(activeUnit); + if (map.breakPawns.size() > 0) + setNextState(StateType.BREAK); + } + + activeUnit.showTarget(); ctrl.setState(StateType.ANIMATION); |