diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-12 11:55:52 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-12 11:55:52 +0200 |
commit | 3afc38971c4d7cbbea48128c930f00d5734a529f (patch) | |
tree | a7459a38e5d7bb9eafb739f6e8be2e347bcc99c9 /core/src/ch | |
parent | a745392ca2863e2f5036207e5c4a75e851016737 (diff) | |
download | RustAndDust-3afc38971c4d7cbbea48128c930f00d5734a529f.zip RustAndDust-3afc38971c4d7cbbea48128c930f00d5734a529f.tar.gz |
GameState* -> State
Diffstat (limited to 'core/src/ch')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Ctrl.java | 32 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Hud.java | 6 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/State.java (renamed from core/src/ch/asynk/tankontank/game/GameState.java) | 10 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/states/StateAnimation.java (renamed from core/src/ch/asynk/tankontank/game/states/GameStateAnimation.java) | 8 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/states/StateCommon.java (renamed from core/src/ch/asynk/tankontank/game/states/GameStateCommon.java) | 21 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/states/StateMove.java (renamed from core/src/ch/asynk/tankontank/game/states/GameStateMove.java) | 10 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/states/StateRotate.java (renamed from core/src/ch/asynk/tankontank/game/states/GameStateRotate.java) | 14 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/states/StateSelect.java (renamed from core/src/ch/asynk/tankontank/game/states/GameStateSelect.java) | 10 |
8 files changed, 56 insertions, 55 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Ctrl.java b/core/src/ch/asynk/tankontank/game/Ctrl.java index b2920c2..b6d5966 100644 --- a/core/src/ch/asynk/tankontank/game/Ctrl.java +++ b/core/src/ch/asynk/tankontank/game/Ctrl.java @@ -3,11 +3,11 @@ package ch.asynk.tankontank.game; import com.badlogic.gdx.utils.Disposable; import ch.asynk.tankontank.TankOnTank; -import ch.asynk.tankontank.game.states.GameStateCommon; -import ch.asynk.tankontank.game.states.GameStateSelect; -import ch.asynk.tankontank.game.states.GameStateMove; -import ch.asynk.tankontank.game.states.GameStateRotate; -import ch.asynk.tankontank.game.states.GameStateAnimation; +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.StateAnimation; public class Ctrl implements Disposable { @@ -42,14 +42,14 @@ public class Ctrl implements Disposable public Player usPlayer; public Player currentPlayer; - private GameState selectState; - private GameState pathState; - private GameState rotateState; - private GameState animationState; + private State selectState; + private State pathState; + private State rotateState; + private State animationState; private int animationCount = 0; - private GameState state; + private State state; public Ctrl(final TankOnTank game) { @@ -62,10 +62,10 @@ public class Ctrl implements Disposable this.usPlayer = factory.getPlayer(Army.US); this.gePlayer = factory.getPlayer(Army.GE); - this.selectState = new GameStateSelect(this, map); - this.pathState = new GameStateMove(); - this.rotateState = new GameStateRotate(); - this.animationState = new GameStateAnimation(); + this.selectState = new StateSelect(this, map); + this.pathState = new StateMove(); + this.rotateState = new StateRotate(); + this.animationState = new StateAnimation(); this.state = selectState; this.currentPlayer = factory.fakeSetup(map, gePlayer, usPlayer); @@ -115,12 +115,12 @@ public class Ctrl implements Disposable } - public void setState(GameState.State state) + public void setState(State.StateType state) { setState(state, true); } - public void setState(GameState.State state, boolean normal) + public void setState(State.StateType state, boolean normal) { this.state.leave(state); diff --git a/core/src/ch/asynk/tankontank/game/Hud.java b/core/src/ch/asynk/tankontank/game/Hud.java index 3d5014b..cc9dadc 100644 --- a/core/src/ch/asynk/tankontank/game/Hud.java +++ b/core/src/ch/asynk/tankontank/game/Hud.java @@ -162,11 +162,11 @@ public class Hud implements Disposable if (!buttonsRect.contains(x,y)) return false; if (btn == moveBtn) - ctrl.setState(GameState.State.MOVE); + ctrl.setState(State.StateType.MOVE); else if (btn == rotateBtn) - ctrl.setState(GameState.State.ROTATE); + ctrl.setState(State.StateType.ROTATE); else if (btn == attackBtn) - // TODO ctrl.setState(GameState.State.ATTACK); + // TODO ctrl.setState(StateType.ATTACK); System.err.println(" ATTACK not implemented yet"); else if (btn == checkBtn) ctrl.done(); diff --git a/core/src/ch/asynk/tankontank/game/GameState.java b/core/src/ch/asynk/tankontank/game/State.java index e6741a7..a289edc 100644 --- a/core/src/ch/asynk/tankontank/game/GameState.java +++ b/core/src/ch/asynk/tankontank/game/State.java @@ -1,8 +1,8 @@ package ch.asynk.tankontank.game; -public interface GameState +public interface State { - enum State { + enum StateType { SELECT, MOVE, ROTATE, @@ -11,7 +11,7 @@ public interface GameState public void enter(boolean flag); - public void leave(GameState.State nextState); + public void leave(StateType nextState); public void abort(); @@ -25,7 +25,7 @@ public interface GameState public boolean upInMap(float x, float y); - public GameState.State getNextState(); + public StateType getNextState(); - public void setNextState(GameState.State next); + public void setNextState(StateType next); } diff --git a/core/src/ch/asynk/tankontank/game/states/GameStateAnimation.java b/core/src/ch/asynk/tankontank/game/states/StateAnimation.java index e1b2c08..753cbf8 100644 --- a/core/src/ch/asynk/tankontank/game/states/GameStateAnimation.java +++ b/core/src/ch/asynk/tankontank/game/states/StateAnimation.java @@ -1,8 +1,8 @@ package ch.asynk.tankontank.game.states; -import ch.asynk.tankontank.game.GameState.State; +import ch.asynk.tankontank.game.State.StateType; -public class GameStateAnimation extends GameStateCommon +public class StateAnimation extends StateCommon { @Override public void enter(boolean flag) @@ -10,9 +10,9 @@ public class GameStateAnimation extends GameStateCommon } @Override - public void leave(State nextState) + public void leave(StateType nextState) { - if (nextState != State.SELECT) { + if (nextState != StateType.SELECT) { from.set(-1, -1); to.set(-1, -1); } diff --git a/core/src/ch/asynk/tankontank/game/states/GameStateCommon.java b/core/src/ch/asynk/tankontank/game/states/StateCommon.java index a759dc2..8d7a48d 100644 --- a/core/src/ch/asynk/tankontank/game/states/GameStateCommon.java +++ b/core/src/ch/asynk/tankontank/game/states/StateCommon.java @@ -6,9 +6,10 @@ import ch.asynk.tankontank.engine.Pawn; import ch.asynk.tankontank.game.Map; import ch.asynk.tankontank.game.Hex; import ch.asynk.tankontank.game.Ctrl; -import ch.asynk.tankontank.game.GameState; +import ch.asynk.tankontank.game.State; +import ch.asynk.tankontank.game.State.StateType; -public abstract class GameStateCommon implements GameState +public abstract class StateCommon implements State { protected static Ctrl ctrl; protected static Map map; @@ -23,26 +24,26 @@ public abstract class GameStateCommon implements GameState protected boolean isEnemy; - protected static GameState.State nextState = GameState.State.SELECT; + protected static StateType nextState = StateType.SELECT; - protected GameStateCommon() + protected StateCommon() { } - public GameStateCommon(Ctrl ctrl, Map map) + public StateCommon(Ctrl ctrl, Map map) { this.ctrl = ctrl; this.map = map; } @Override - public GameState.State getNextState() + public StateType getNextState() { return nextState; } @Override - public void setNextState(GameState.State state) + public void setNextState(StateType state) { nextState = state; } @@ -71,9 +72,9 @@ public abstract class GameStateCommon implements GameState private void goToNextState() { ctrl.hud.hide(); - GameState.State next = nextState; - nextState = GameState.State.SELECT; - ctrl.setState(next, (next == GameState.State.SELECT)); + StateType next = nextState; + nextState = StateType.SELECT; + ctrl.setState(next, (next == StateType.SELECT)); } protected static boolean hexInMap(GridPoint2 hex) diff --git a/core/src/ch/asynk/tankontank/game/states/GameStateMove.java b/core/src/ch/asynk/tankontank/game/states/StateMove.java index 56a81a3..2038855 100644 --- a/core/src/ch/asynk/tankontank/game/states/GameStateMove.java +++ b/core/src/ch/asynk/tankontank/game/states/StateMove.java @@ -2,9 +2,9 @@ package ch.asynk.tankontank.game.states; import com.badlogic.gdx.math.GridPoint2; -import ch.asynk.tankontank.game.GameState.State; +import ch.asynk.tankontank.game.State.StateType; -public class GameStateMove extends GameStateCommon +public class StateMove extends StateCommon { @Override public void enter(boolean fromSelect) @@ -36,7 +36,7 @@ public class GameStateMove extends GameStateCommon } @Override - public void leave(State nextState) + public void leave(StateType nextState) { // hide all but assists : want them when in rotation map.showPossibleMoves(false); @@ -46,7 +46,7 @@ public class GameStateMove extends GameStateCommon map.showFinalPath(to, false); } - if (nextState != State.SELECT) { + if (nextState != StateType.SELECT) { if (to.x == -1 ) to.set(from); } @@ -75,7 +75,7 @@ public class GameStateMove extends GameStateCommon // prevent changePawn if (sameHexes(from, selectedHex)) selectedHex.set(to); - ctrl.setState(State.ROTATE, false); + ctrl.setState(StateType.ROTATE, false); } } diff --git a/core/src/ch/asynk/tankontank/game/states/GameStateRotate.java b/core/src/ch/asynk/tankontank/game/states/StateRotate.java index a57ecb3..f692ed0 100644 --- a/core/src/ch/asynk/tankontank/game/states/GameStateRotate.java +++ b/core/src/ch/asynk/tankontank/game/states/StateRotate.java @@ -1,9 +1,9 @@ package ch.asynk.tankontank.game.states; import ch.asynk.tankontank.engine.Orientation; -import ch.asynk.tankontank.game.GameState.State; +import ch.asynk.tankontank.game.State.StateType; -public class GameStateRotate extends GameStateCommon +public class StateRotate extends StateCommon { private boolean rotateOnly; private boolean rotationSet; @@ -38,7 +38,7 @@ public class GameStateRotate extends GameStateCommon } @Override - public void leave(State nextState) + public void leave(StateType nextState) { unselectHex(to); unselectHex(from); @@ -102,13 +102,13 @@ public class GameStateRotate extends GameStateCommon if (rotateOnly) { ctrl.setAnimationCount(1); if (map.rotatePawn(activePawn, from, o) > 0) - setNextState(State.MOVE); - ctrl.setState(State.ANIMATION); + setNextState(StateType.MOVE); + ctrl.setState(StateType.ANIMATION); } else { ctrl.setAnimationCount(1); if (map.movePawn(activePawn, from, o) > 0) - setNextState(State.MOVE); - ctrl.setState(State.ANIMATION); + setNextState(StateType.MOVE); + ctrl.setState(StateType.ANIMATION); } } } diff --git a/core/src/ch/asynk/tankontank/game/states/GameStateSelect.java b/core/src/ch/asynk/tankontank/game/states/StateSelect.java index 711daae..ec1ba42 100644 --- a/core/src/ch/asynk/tankontank/game/states/GameStateSelect.java +++ b/core/src/ch/asynk/tankontank/game/states/StateSelect.java @@ -2,11 +2,11 @@ package ch.asynk.tankontank.game.states; import ch.asynk.tankontank.game.Map; import ch.asynk.tankontank.game.Ctrl; -import ch.asynk.tankontank.game.GameState.State; +import ch.asynk.tankontank.game.State.StateType; -public class GameStateSelect extends GameStateCommon +public class StateSelect extends StateCommon { - public GameStateSelect(Ctrl ctrl, Map map) + public StateSelect(Ctrl ctrl, Map map) { super(ctrl, map); } @@ -19,7 +19,7 @@ public class GameStateSelect extends GameStateCommon } @Override - public void leave(State nextState) + public void leave(StateType nextState) { hidePossibleTargetsMovesAssists(); } @@ -36,7 +36,7 @@ public class GameStateSelect extends GameStateCommon if (!isEnemy && map.isInPossibleMoves(upHex)) { // quick move to.set(upHex); - ctrl.setState(State.MOVE); + ctrl.setState(StateType.MOVE); return; } |