diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-06 11:13:31 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-06 11:13:31 +0200 |
commit | 29f2682c2c60b205a7e7fe69909ca338d21e1c41 (patch) | |
tree | 1127a0c6ccf7f37956e4408f9a2d0ed278f04ca3 /core/src/ch/asynk/tankontank | |
parent | 92a60f998d2355e64fed13268987bdb0810355f9 (diff) | |
download | RustAndDust-29f2682c2c60b205a7e7fe69909ca338d21e1c41.zip RustAndDust-29f2682c2c60b205a7e7fe69909ca338d21e1c41.tar.gz |
Hud: add a reference to GameCtrl instance
Diffstat (limited to 'core/src/ch/asynk/tankontank')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/GameCtrl.java | 3 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Hud.java | 12 |
2 files changed, 12 insertions, 3 deletions
diff --git a/core/src/ch/asynk/tankontank/game/GameCtrl.java b/core/src/ch/asynk/tankontank/game/GameCtrl.java index fc4df91..38057d6 100644 --- a/core/src/ch/asynk/tankontank/game/GameCtrl.java +++ b/core/src/ch/asynk/tankontank/game/GameCtrl.java @@ -27,10 +27,9 @@ public class GameCtrl implements Disposable this.game = game; this.factory = new GameFactory(game.manager); + this.hud = new Hud(game, this); this.map = factory.getMap(this, game.manager, GameFactory.MapType.MAP_A); - this.hud = new Hud(game); - this.noneState = new GameStateNone(this, map); this.pathState = new GameStatePath(); this.directionState = new GameStateDirection(); diff --git a/core/src/ch/asynk/tankontank/game/Hud.java b/core/src/ch/asynk/tankontank/game/Hud.java index c9e47ab..866c6a1 100644 --- a/core/src/ch/asynk/tankontank/game/Hud.java +++ b/core/src/ch/asynk/tankontank/game/Hud.java @@ -73,6 +73,7 @@ class ActionBtn implements Disposable public class Hud implements Disposable { private final TankOnTank game; + private final GameCtrl ctrl; private ActionBtn flagAct; private ActionBtn moveAct; @@ -83,9 +84,10 @@ public class Hud implements Disposable private Rectangle rect; private float elapsed; - public Hud(final TankOnTank game) + public Hud(final TankOnTank game, final GameCtrl ctrl) { this.game = game; + this.ctrl = ctrl; TextureAtlas atlas = game.manager.get("data/assets.atlas", TextureAtlas.class); @@ -140,6 +142,7 @@ public class Hud implements Disposable if (!rect.contains(x,y)) return false; if (cancelAct.hit(x, y)) { + ctrl.abort(); cancelAct.toggle(); } @@ -152,11 +155,18 @@ public class Hud implements Disposable if (moveAct.hit(x, y)) { moveAct.setOn(); + ctrl.setState(GameState.State.MOVE, false); } else if (rotateAct.hit(x, y)) { rotateAct.setOn(); + ctrl.setState(GameState.State.ROTATE, false); } else if (attackAct.hit(x, y)) { attackAct.setOn(); + ctrl.setState(GameState.State.ATTACK, false); } else if (cancelAct.hit(x, y)) { + ctrl.abort(); + moveAct.setOff(); + rotateAct.setOff(); + attackAct.setOff(); cancelAct.toggle(); } |