From 987041cdfe8b0726878dd8be57b334acbc45b89e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Sun, 12 Oct 2014 11:41:48 +0200 Subject: rename GameCtrl -> Ctrl --- core/src/ch/asynk/tankontank/game/Ctrl.java | 180 +++++++++++++++++++++ core/src/ch/asynk/tankontank/game/GameCtrl.java | 180 --------------------- core/src/ch/asynk/tankontank/game/GameFactory.java | 2 +- core/src/ch/asynk/tankontank/game/Hud.java | 4 +- core/src/ch/asynk/tankontank/game/Map.java | 4 +- core/src/ch/asynk/tankontank/game/MapA.java | 2 +- core/src/ch/asynk/tankontank/game/MapB.java | 2 +- .../tankontank/game/states/GameStateCommon.java | 6 +- .../tankontank/game/states/GameStateSelect.java | 4 +- .../ch/asynk/tankontank/screens/GameScreen.java | 6 +- 10 files changed, 195 insertions(+), 195 deletions(-) create mode 100644 core/src/ch/asynk/tankontank/game/Ctrl.java delete mode 100644 core/src/ch/asynk/tankontank/game/GameCtrl.java diff --git a/core/src/ch/asynk/tankontank/game/Ctrl.java b/core/src/ch/asynk/tankontank/game/Ctrl.java new file mode 100644 index 0000000..bcf41c9 --- /dev/null +++ b/core/src/ch/asynk/tankontank/game/Ctrl.java @@ -0,0 +1,180 @@ +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; + +public class Ctrl implements Disposable +{ + + public class Config + { + public boolean showMoves; + public boolean showTargets; + public boolean showMoveAssists; + public boolean canCancel; + public boolean mustValidate; + public boolean showEnemyPossibilities; + + public Config() + { + this.showMoves = true; + this.showTargets = true; + this.showMoveAssists = true; + this.canCancel = true; + this.mustValidate = false; + this.showEnemyPossibilities = false; + } + } + + private final TankOnTank game; + + private GameFactory factory; + public Map map; + public Hud hud; + public Config cfg; + public Player gePlayer; + public Player usPlayer; + public Player currentPlayer; + + private GameState selectState; + private GameState pathState; + private GameState rotateState; + private GameState animationState; + + private int animationCount = 0; + + private GameState state; + + public Ctrl(final TankOnTank game) + { + this.game = game; + + this.cfg = new Config(); + + this.factory = new GameFactory(game.manager); + this.map = factory.getMap(this, game.manager, GameFactory.MapType.MAP_A); + 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.state = selectState; + this.currentPlayer = factory.fakeSetup(map, gePlayer, usPlayer); + + this.hud = new Hud(this, game); + } + + @Override + public void dispose() + { + hud.dispose(); + map.dispose(); + factory.dispose(); + } + + public boolean mayProcessTouch() + { + return (state != animationState); + } + + public boolean isInAction() + { + return (state != selectState); + } + + public void setAnimationCount(int count) + { + animationCount = count; + System.err.println(" setAnimationCount(" + count + ")"); + } + + public void animationDone() + { + animationCount -= 1; + if (animationCount == 0) + state.done(); + if (animationCount < 0) + System.err.println("animationCount < 0"); + } + + private void nextPlayer() + { + currentPlayer.turnEnd(); + currentPlayer = ((currentPlayer == usPlayer) ? gePlayer : usPlayer); + currentPlayer.turnStart(); + hud.updatePlayer(); + + } + + public void setState(GameState.State state) + { + setState(state, true); + } + + public void setState(GameState.State state, boolean normal) + { + this.state.leave(state); + + System.err.println("Switch to : " + state + " " + normal); + switch(state) { + case SELECT: + this.state = selectState; + checkTurnEnd(); + break; + case MOVE: + this.state = pathState; + break; + case ROTATE: + this.state = rotateState; + break; + case ANIMATION: + this.state = animationState; + break; + default: + break; + } + + this.state.enter(normal); + } + + private void checkTurnEnd() + { + System.err.println(" current player : " + currentPlayer.toString()); + if (map.activatedPawnsCount() > 0) { + currentPlayer.burnDownOneAp(); + } + if (currentPlayer.apExhausted()) + nextPlayer(); + } + + public void abort() + { + state.abort(); + } + + public void done() + { + state.done(); + } + + public void touchDown(float x, float y) + { + if (state.downInMap(x, y)) + state.touchDown(); + } + + public void touchUp(float x, float y) + { + if (state.upInMap(x, y)) + state.touchUp(); + } +} diff --git a/core/src/ch/asynk/tankontank/game/GameCtrl.java b/core/src/ch/asynk/tankontank/game/GameCtrl.java deleted file mode 100644 index 0073c1c..0000000 --- a/core/src/ch/asynk/tankontank/game/GameCtrl.java +++ /dev/null @@ -1,180 +0,0 @@ -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; - -public class GameCtrl implements Disposable -{ - - public class Config - { - public boolean showMoves; - public boolean showTargets; - public boolean showMoveAssists; - public boolean canCancel; - public boolean mustValidate; - public boolean showEnemyPossibilities; - - public Config() - { - this.showMoves = true; - this.showTargets = true; - this.showMoveAssists = true; - this.canCancel = true; - this.mustValidate = false; - this.showEnemyPossibilities = false; - } - } - - private final TankOnTank game; - - private GameFactory factory; - public Map map; - public Hud hud; - public Config cfg; - public Player gePlayer; - public Player usPlayer; - public Player currentPlayer; - - private GameState selectState; - private GameState pathState; - private GameState rotateState; - private GameState animationState; - - private int animationCount = 0; - - private GameState state; - - public GameCtrl(final TankOnTank game) - { - this.game = game; - - this.cfg = new Config(); - - this.factory = new GameFactory(game.manager); - this.map = factory.getMap(this, game.manager, GameFactory.MapType.MAP_A); - 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.state = selectState; - this.currentPlayer = factory.fakeSetup(map, gePlayer, usPlayer); - - this.hud = new Hud(this, game); - } - - @Override - public void dispose() - { - hud.dispose(); - map.dispose(); - factory.dispose(); - } - - public boolean mayProcessTouch() - { - return (state != animationState); - } - - public boolean isInAction() - { - return (state != selectState); - } - - public void setAnimationCount(int count) - { - animationCount = count; - System.err.println(" setAnimationCount(" + count + ")"); - } - - public void animationDone() - { - animationCount -= 1; - if (animationCount == 0) - state.done(); - if (animationCount < 0) - System.err.println("animationCount < 0"); - } - - private void nextPlayer() - { - currentPlayer.turnEnd(); - currentPlayer = ((currentPlayer == usPlayer) ? gePlayer : usPlayer); - currentPlayer.turnStart(); - hud.updatePlayer(); - - } - - public void setState(GameState.State state) - { - setState(state, true); - } - - public void setState(GameState.State state, boolean normal) - { - this.state.leave(state); - - System.err.println("Switch to : " + state + " " + normal); - switch(state) { - case SELECT: - this.state = selectState; - checkTurnEnd(); - break; - case MOVE: - this.state = pathState; - break; - case ROTATE: - this.state = rotateState; - break; - case ANIMATION: - this.state = animationState; - break; - default: - break; - } - - this.state.enter(normal); - } - - private void checkTurnEnd() - { - System.err.println(" current player : " + currentPlayer.toString()); - if (map.activatedPawnsCount() > 0) { - currentPlayer.burnDownOneAp(); - } - if (currentPlayer.apExhausted()) - nextPlayer(); - } - - public void abort() - { - state.abort(); - } - - public void done() - { - state.done(); - } - - public void touchDown(float x, float y) - { - if (state.downInMap(x, y)) - state.touchDown(); - } - - public void touchUp(float x, float y) - { - if (state.upInMap(x, y)) - state.touchUp(); - } -} diff --git a/core/src/ch/asynk/tankontank/game/GameFactory.java b/core/src/ch/asynk/tankontank/game/GameFactory.java index b84715d..3335b20 100644 --- a/core/src/ch/asynk/tankontank/game/GameFactory.java +++ b/core/src/ch/asynk/tankontank/game/GameFactory.java @@ -123,7 +123,7 @@ public class GameFactory implements Board.TileBuilder, Disposable return cfg; } - public Map getMap(GameCtrl ctrl, AssetManager manager, MapType t) + public Map getMap(Ctrl ctrl, AssetManager manager, MapType t) { Board.Config cfg = config(); diff --git a/core/src/ch/asynk/tankontank/game/Hud.java b/core/src/ch/asynk/tankontank/game/Hud.java index e7da8aa..3d5014b 100644 --- a/core/src/ch/asynk/tankontank/game/Hud.java +++ b/core/src/ch/asynk/tankontank/game/Hud.java @@ -19,7 +19,7 @@ public class Hud implements Disposable private static final float OFFSET = 15f; private final TankOnTank game; - private final GameCtrl ctrl; + private final Ctrl ctrl; private Image flag; @@ -36,7 +36,7 @@ public class Hud implements Disposable private float elapsed; private Vector2 bottomLeft; - public Hud(final GameCtrl ctrl, final TankOnTank game) + public Hud(final Ctrl ctrl, final TankOnTank game) { this.game = game; this.ctrl = ctrl; diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java index bb8ff58..85a4f59 100644 --- a/core/src/ch/asynk/tankontank/game/Map.java +++ b/core/src/ch/asynk/tankontank/game/Map.java @@ -17,7 +17,7 @@ import ch.asynk.tankontank.engine.gfx.animations.RunnableAnimation; public abstract class Map extends Board { - private final GameCtrl ctrl; + private final Ctrl ctrl; private final ArrayList finalPath = new ArrayList(10); private final ArrayList possibleMoves = new ArrayList(40); @@ -30,7 +30,7 @@ public abstract class Map extends Board protected abstract void setup(); - public Map(GameCtrl ctrl, GameFactory factory, Board.Config cfg, Texture texture) + public Map(Ctrl ctrl, GameFactory factory, Board.Config cfg, Texture texture) { super(factory, cfg, texture); this.ctrl = ctrl; diff --git a/core/src/ch/asynk/tankontank/game/MapA.java b/core/src/ch/asynk/tankontank/game/MapA.java index edf4dee..d76192e 100644 --- a/core/src/ch/asynk/tankontank/game/MapA.java +++ b/core/src/ch/asynk/tankontank/game/MapA.java @@ -8,7 +8,7 @@ import ch.asynk.tankontank.engine.Orientation; public class MapA extends Map { - public MapA(GameCtrl ctrl, GameFactory factory, Board.Config cfg, Texture texture) + public MapA(Ctrl ctrl, GameFactory factory, Board.Config cfg, Texture texture) { super(ctrl, factory, cfg, texture); } diff --git a/core/src/ch/asynk/tankontank/game/MapB.java b/core/src/ch/asynk/tankontank/game/MapB.java index 9682482..46927a6 100644 --- a/core/src/ch/asynk/tankontank/game/MapB.java +++ b/core/src/ch/asynk/tankontank/game/MapB.java @@ -8,7 +8,7 @@ import ch.asynk.tankontank.engine.Orientation; public class MapB extends Map { - public MapB(GameCtrl ctrl, GameFactory factory, Board.Config cfg, Texture texture) + public MapB(Ctrl ctrl, GameFactory factory, Board.Config cfg, Texture texture) { super(ctrl, factory, cfg, texture); } diff --git a/core/src/ch/asynk/tankontank/game/states/GameStateCommon.java b/core/src/ch/asynk/tankontank/game/states/GameStateCommon.java index da2d181..a759dc2 100644 --- a/core/src/ch/asynk/tankontank/game/states/GameStateCommon.java +++ b/core/src/ch/asynk/tankontank/game/states/GameStateCommon.java @@ -5,12 +5,12 @@ import com.badlogic.gdx.math.GridPoint2; import ch.asynk.tankontank.engine.Pawn; import ch.asynk.tankontank.game.Map; import ch.asynk.tankontank.game.Hex; -import ch.asynk.tankontank.game.GameCtrl; +import ch.asynk.tankontank.game.Ctrl; import ch.asynk.tankontank.game.GameState; public abstract class GameStateCommon implements GameState { - protected static GameCtrl ctrl; + protected static Ctrl ctrl; protected static Map map; protected static Pawn activePawn; protected static Pawn selectedPawn; @@ -29,7 +29,7 @@ public abstract class GameStateCommon implements GameState { } - public GameStateCommon(GameCtrl ctrl, Map map) + public GameStateCommon(Ctrl ctrl, Map map) { this.ctrl = ctrl; this.map = map; diff --git a/core/src/ch/asynk/tankontank/game/states/GameStateSelect.java b/core/src/ch/asynk/tankontank/game/states/GameStateSelect.java index 309ee50..711daae 100644 --- a/core/src/ch/asynk/tankontank/game/states/GameStateSelect.java +++ b/core/src/ch/asynk/tankontank/game/states/GameStateSelect.java @@ -1,12 +1,12 @@ package ch.asynk.tankontank.game.states; import ch.asynk.tankontank.game.Map; -import ch.asynk.tankontank.game.GameCtrl; +import ch.asynk.tankontank.game.Ctrl; import ch.asynk.tankontank.game.GameState.State; public class GameStateSelect extends GameStateCommon { - public GameStateSelect(GameCtrl ctrl, Map map) + public GameStateSelect(Ctrl ctrl, Map map) { super(ctrl, map); } diff --git a/core/src/ch/asynk/tankontank/screens/GameScreen.java b/core/src/ch/asynk/tankontank/screens/GameScreen.java index 696cfd1..bf965ed 100644 --- a/core/src/ch/asynk/tankontank/screens/GameScreen.java +++ b/core/src/ch/asynk/tankontank/screens/GameScreen.java @@ -25,7 +25,7 @@ import com.badlogic.gdx.utils.viewport.ScreenViewport; import ch.asynk.tankontank.TankOnTank; -import ch.asynk.tankontank.game.GameCtrl; +import ch.asynk.tankontank.game.Ctrl; public class GameScreen implements Screen { @@ -49,7 +49,7 @@ public class GameScreen implements Screen private ShapeRenderer debugShapes = null; private final TankOnTank game; - private GameCtrl ctrl; + private Ctrl ctrl; private Vector2 dragPos = new Vector2(); private Vector3 touchPos = new Vector3(); @@ -59,7 +59,7 @@ public class GameScreen implements Screen { this.game = game; - ctrl = new GameCtrl(game); + ctrl = new Ctrl(game); virtualWidth = ctrl.map.getWidth(); virtualHeight = ctrl.map.getHeight(); -- cgit v1.1-2-g2b99