diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2018-09-13 16:12:03 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2018-09-13 16:12:03 +0200 |
commit | fa8345b7c6c7c22620117f34ef9fbd63f1004b41 (patch) | |
tree | 9e69ebc092f194c261cc73203957c3e48783dd54 /core/src/ch/asynk/zproject/GameScreen.java | |
parent | 43147c8440ca5bc0b81e01d14f487811f18d093b (diff) | |
download | gdx-boardgame-fa8345b7c6c7c22620117f34ef9fbd63f1004b41.zip gdx-boardgame-fa8345b7c6c7c22620117f34ef9fbd63f1004b41.tar.gz |
Game : add a State, drive board and hud with it
Diffstat (limited to 'core/src/ch/asynk/zproject/GameScreen.java')
-rw-r--r-- | core/src/ch/asynk/zproject/GameScreen.java | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/core/src/ch/asynk/zproject/GameScreen.java b/core/src/ch/asynk/zproject/GameScreen.java index 47c8e5e..02b7db5 100644 --- a/core/src/ch/asynk/zproject/GameScreen.java +++ b/core/src/ch/asynk/zproject/GameScreen.java @@ -38,10 +38,29 @@ public class GameScreen implements Screen private float inputDelay; private boolean inputBlocked; + public enum State + { + UI, HEX_V, HEX_H; + public State next() + { + switch(this) { + case UI: + return HEX_V; + case HEX_V: + return HEX_H; + case HEX_H: + return UI; + default: + return UI; + } + } + } + private State state; + public GameScreen(final ZProject zproject) { this.zproject = zproject; - this.hud = new GameHud(zproject.assets); + this.hud = new GameHud(zproject.assets, State.UI, () -> nextState()); this.board = new GameBoard(zproject.assets); this.batch = new SpriteBatch(); this.camera = new Camera(10, board.getWidth(), board.getHeight(), 1.0f, 0.3f, false); @@ -49,9 +68,19 @@ public class GameScreen implements Screen this.paused = false; this.inputDelay = 0f; this.inputBlocked = false; + this.state = State.UI; if (DEBUG) this.debugShapes = new ShapeRenderer(); } + public State nextState() + { + this.state = this.state.next(); + this.board.setState(this.state); + this.camera.setDimension(board.getWidth(), board.getHeight()); + zoom(1); + return this.state; + } + @Override public void render(float delta) { if (paused) return; @@ -150,8 +179,10 @@ public class GameScreen implements Screen dragPos.set(x, y); camera.unproject(x, y, boardTouch); camera.unprojectHud(x, y, hudTouch); - if(!hud.touch(hudTouch.x, hudTouch.y)) - board.touch(boardTouch.x, boardTouch.y); + if (!hud.touch(hudTouch.x, hudTouch.y)) { + if (state != State.UI) + board.touch(boardTouch.x, boardTouch.y); + } } return true; } |