diff options
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Ctrl.java | 6 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Hud.java | 3 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/State.java | 1 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/states/StateSelect.java | 18 |
4 files changed, 21 insertions, 7 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Ctrl.java b/core/src/ch/asynk/tankontank/game/Ctrl.java index 57f0179..8fae035 100644 --- a/core/src/ch/asynk/tankontank/game/Ctrl.java +++ b/core/src/ch/asynk/tankontank/game/Ctrl.java @@ -7,6 +7,7 @@ import ch.asynk.tankontank.game.states.StateCommon; import ch.asynk.tankontank.game.states.StateSelect; import ch.asynk.tankontank.game.states.StateMove; import ch.asynk.tankontank.game.states.StateRotate; +import ch.asynk.tankontank.game.states.StateAttack; import ch.asynk.tankontank.game.states.StateAnimation; public class Ctrl implements Disposable @@ -24,6 +25,7 @@ public class Ctrl implements Disposable private State selectState; private State pathState; private State rotateState; + private State attackState; private State animationState; private int animationCount = 0; @@ -44,6 +46,7 @@ public class Ctrl implements Disposable this.selectState = new StateSelect(this, map); this.pathState = new StateMove(); this.rotateState = new StateRotate(); + this.attackState = new StateAttack(); this.animationState = new StateAnimation(); this.state = selectState; @@ -117,6 +120,9 @@ public class Ctrl implements Disposable case ROTATE: this.state = rotateState; break; + case ATTACK: + this.state = attackState; + break; case ANIMATION: this.state = animationState; break; diff --git a/core/src/ch/asynk/tankontank/game/Hud.java b/core/src/ch/asynk/tankontank/game/Hud.java index cc9dadc..9a80143 100644 --- a/core/src/ch/asynk/tankontank/game/Hud.java +++ b/core/src/ch/asynk/tankontank/game/Hud.java @@ -166,8 +166,7 @@ public class Hud implements Disposable else if (btn == rotateBtn) ctrl.setState(State.StateType.ROTATE); else if (btn == attackBtn) - // TODO ctrl.setState(StateType.ATTACK); - System.err.println(" ATTACK not implemented yet"); + ctrl.setState(State.StateType.ATTACK); else if (btn == checkBtn) ctrl.done(); else if (btn == cancelBtn) diff --git a/core/src/ch/asynk/tankontank/game/State.java b/core/src/ch/asynk/tankontank/game/State.java index a289edc..6156f8b 100644 --- a/core/src/ch/asynk/tankontank/game/State.java +++ b/core/src/ch/asynk/tankontank/game/State.java @@ -6,6 +6,7 @@ public interface State SELECT, MOVE, ROTATE, + ATTACK, ANIMATION }; diff --git a/core/src/ch/asynk/tankontank/game/states/StateSelect.java b/core/src/ch/asynk/tankontank/game/states/StateSelect.java index ec1ba42..c02c0c7 100644 --- a/core/src/ch/asynk/tankontank/game/states/StateSelect.java +++ b/core/src/ch/asynk/tankontank/game/states/StateSelect.java @@ -33,11 +33,19 @@ public class StateSelect extends StateCommon @Override public void touchUp() { - if (!isEnemy && map.isInPossibleMoves(upHex)) { - // quick move - to.set(upHex); - ctrl.setState(StateType.MOVE); - return; + if (!isEnemy) { + if (map.isInPossibleMoves(upHex)) { + // quick move + to.set(upHex); + ctrl.setState(StateType.MOVE); + return; + } + if (map.isInPossibleTargets(upHex)) { + // quick fire + to.set(upHex); + ctrl.setState(StateType.ATTACK); + return; + } } selectHexAndPawn(upHex); |