diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-05 17:20:34 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-05 17:20:34 +0100 |
commit | ce6ad7da0c330dd839a68dd9b42fcf0a04b0f09e (patch) | |
tree | 60362fe858a658b9e60a7850d34be851df6117b8 /core/src/ch/asynk | |
parent | 0694ea23fcd9c51b79717975ec4ec6467739ad52 (diff) | |
download | RustAndDust-ce6ad7da0c330dd839a68dd9b42fcf0a04b0f09e.zip RustAndDust-ce6ad7da0c330dd839a68dd9b42fcf0a04b0f09e.tar.gz |
add game/states/StateEntry
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Ctrl.java | 8 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Hud.java | 12 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/State.java | 3 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/states/StateEntry.java | 69 |
4 files changed, 89 insertions, 3 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Ctrl.java b/core/src/ch/asynk/tankontank/game/Ctrl.java index c9941f2..cc724fb 100644 --- a/core/src/ch/asynk/tankontank/game/Ctrl.java +++ b/core/src/ch/asynk/tankontank/game/Ctrl.java @@ -11,11 +11,12 @@ import ch.asynk.tankontank.game.states.StatePromote; import ch.asynk.tankontank.game.states.StateAttack; import ch.asynk.tankontank.game.states.StateBreak; import ch.asynk.tankontank.game.states.StateAnimation; +import ch.asynk.tankontank.game.states.StateEntry; public class Ctrl implements Disposable { private final TankOnTank game; - private final Battle battle; + public final Battle battle; public Map map; public Hud hud; @@ -30,6 +31,7 @@ public class Ctrl implements Disposable private State attackState; private State breakState; private State animationState; + private State entryState; private int animationCount = 0; @@ -55,6 +57,7 @@ public class Ctrl implements Disposable this.attackState = new StateAttack(); this.breakState = new StateBreak(); this.animationState = new StateAnimation(); + this.entryState = new StateEntry(); this.state = selectState; this.stateType = State.StateType.SELECT; @@ -161,6 +164,9 @@ public class Ctrl implements Disposable case ANIMATION: this.state = animationState; break; + case ENTRY: + this.state = entryState; + break; default: break; } diff --git a/core/src/ch/asynk/tankontank/game/Hud.java b/core/src/ch/asynk/tankontank/game/Hud.java index a84d361..329505c 100644 --- a/core/src/ch/asynk/tankontank/game/Hud.java +++ b/core/src/ch/asynk/tankontank/game/Hud.java @@ -152,6 +152,11 @@ public class Hud implements Disposable msg.draw(batch); } + public Unit getDockUnit() + { + return (Unit) unitDock.selectedPawn; + } + public void pushNotify(String s) { notify(s, 1, Position.MIDDLE_CENTER, true); @@ -208,6 +213,11 @@ public class Hud implements Disposable actionsBg.set(0, 0, 0, 0); } + public void hideUnitDock() + { + unitDock.hide(); + } + public boolean touchDown(float x, float y) { btn = null; @@ -269,7 +279,7 @@ public class Hud implements Disposable else if ((hit == reinforcement) && reinforcement.hit(x, y)) unitDock.toggle(); else if ((hit == unitDock) && unitDock.hit(x, y)) - System.err.println("TODO : unitDock hit"); + ctrl.setState(StateType.ENTRY); hit = null; } else return false; diff --git a/core/src/ch/asynk/tankontank/game/State.java b/core/src/ch/asynk/tankontank/game/State.java index d1d64ef..329e721 100644 --- a/core/src/ch/asynk/tankontank/game/State.java +++ b/core/src/ch/asynk/tankontank/game/State.java @@ -9,7 +9,8 @@ public interface State ATTACK, BREAK, PROMOTE, - ANIMATION + ANIMATION, + ENTRY }; public void enter(boolean flag); diff --git a/core/src/ch/asynk/tankontank/game/states/StateEntry.java b/core/src/ch/asynk/tankontank/game/states/StateEntry.java new file mode 100644 index 0000000..dc4acc9 --- /dev/null +++ b/core/src/ch/asynk/tankontank/game/states/StateEntry.java @@ -0,0 +1,69 @@ +package ch.asynk.tankontank.game.states; + +import com.badlogic.gdx.math.Vector3; + +import ch.asynk.tankontank.engine.TileSet; +import ch.asynk.tankontank.engine.Orientation; +import ch.asynk.tankontank.game.Hex; + +public class StateEntry extends StateCommon +{ + private float x; + private float y; + private float z; + private TileSet entryPoint; + + @Override + public void enter(boolean fromSelect) + { + activeUnit = ctrl.hud.getDockUnit(); + entryPoint = ctrl.battle.getEntryPoint(activeUnit); + entryPoint.enable(Hex.AREA, true); + ctrl.hud.show(false, false, false, false, false, ctrl.cfg.canCancel); + x = activeUnit.getPosition().x; + y = activeUnit.getPosition().x; + z = activeUnit.getPosition().y; + } + + @Override + public void leave(StateType nextState) + { + entryPoint.enable(Hex.AREA, false); + ctrl.hud.hideUnitDock(); + } + + @Override + public void touchDown() + { + } + + @Override + public void touchUp() + { + if (upHex.isEmpty() && entryPoint.contains(upHex)) { + selectedUnit = activeUnit; + selectedHex = upHex; + map.selectHex(selectedHex); + entryPoint.enable(Hex.AREA, false); + ctrl.player.unitEntry(activeUnit); + map.enterBoard(activeUnit, upHex, ctrl.battle.getEntryOrientation(ctrl.player)); + if (activeUnit.getMovementPoints() > 0) + ctrl.setState(StateType.MOVE, true); + else + ctrl.setState(StateType.ROTATE, true); + } + } + + @Override + public void abort() + { + activeUnit.setPosition(x, y, z); + super.abort(); + } + + @Override + public void done() + { + super.done(); + } +} |