diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-04 12:32:23 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-04 12:32:23 +0100 |
commit | 72831aae700ef45c48e16b58bbee50854b5ad508 (patch) | |
tree | f4ded8df7851b7db6b60cb34a3c44095aefb647d /core/src | |
parent | 6cd982d3dfc98bdf953c5b8a110ccd233af74c33 (diff) | |
download | RustAndDust-72831aae700ef45c48e16b58bbee50854b5ad508.zip RustAndDust-72831aae700ef45c48e16b58bbee50854b5ad508.tar.gz |
Hud: cleanup touchDow/Up logic
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Hud.java | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Hud.java b/core/src/ch/asynk/tankontank/game/Hud.java index 6d0dc09..de58c91 100644 --- a/core/src/ch/asynk/tankontank/game/Hud.java +++ b/core/src/ch/asynk/tankontank/game/Hud.java @@ -205,25 +205,29 @@ public class Hud implements Disposable public boolean touchDown(float x, float y) { - if (reinforcement.hit(x,y) || unitDock.hit(x, y)) return true; - else unitDock.hide(); - if (turns.hit(x,y)) return true; - if (!actionsBg.hit(x,y)) return false; - btn = null; - if (moveBtn.hit(x, y)) - btn = moveBtn; - else if (rotateBtn.hit(x, y)) - btn = rotateBtn; - else if (promoteBtn.hit(x, y)) - btn = promoteBtn; - else if (attackBtn.hit(x, y)) - btn = attackBtn; - else if (checkBtn.hit(x, y)) - btn = checkBtn; - else if (cancelBtn.hit(x, y)) - btn = cancelBtn; + if (turns.hit(x,y)) + return true; + else if (unitDock.hit(x, y)) + return true; + else if (reinforcement.hit(x, y)) + return true; + else if (actionsBg.hit(x,y)) { + if (moveBtn.hit(x, y)) + btn = moveBtn; + else if (rotateBtn.hit(x, y)) + btn = rotateBtn; + else if (promoteBtn.hit(x, y)) + btn = promoteBtn; + else if (attackBtn.hit(x, y)) + btn = attackBtn; + else if (checkBtn.hit(x, y)) + btn = checkBtn; + else if (cancelBtn.hit(x, y)) + btn = cancelBtn; + } else + return false; if (btn != null) btn.setDown(); @@ -233,42 +237,38 @@ public class Hud implements Disposable public boolean touchUp(float x, float y) { - if (btn != null) + if (btn != null) { btn.setOn(); - - if (turns.hit(x, y)) { + if (actionsBg.hit(x, y)) { + if ((btn == moveBtn) && moveBtn.hit(x, y)) + ctrl.setState(State.StateType.MOVE); + else if ((btn == rotateBtn) && rotateBtn.hit(x, y)) + ctrl.setState(State.StateType.ROTATE); + else if ((btn == promoteBtn) && promoteBtn.hit(x, y)) + ctrl.setState(State.StateType.PROMOTE); + else if ((btn == attackBtn) && attackBtn.hit(x, y)) + ctrl.setState(State.StateType.ATTACK); + else if ((btn == checkBtn) && checkBtn.hit(x, y)) + ctrl.done(); + else if ((btn == cancelBtn) && cancelBtn.hit(x, y)) { + notify("Action canceled"); + ctrl.abort(); + } else + btn.setOff(); + } else + btn.setOff(); + btn = null; + } + else if (turns.hit(x, y)) { ctrl.endPlayerTurn(); - return true; } - - if (reinforcement.hit(x, y)) { + else if (reinforcement.hit(x, y)) { unitDock.toggle(); - return true; } - - if (unitDock.hit(x, y)) { + else if (unitDock.hit(x, y)) { System.err.println("TODO unitDock touched"); - return true; - } - - if (!actionsBg.hit(x, y)) return false; - - if (btn == moveBtn) - ctrl.setState(State.StateType.MOVE); - else if (btn == rotateBtn) - ctrl.setState(State.StateType.ROTATE); - else if (btn == promoteBtn) - ctrl.setState(State.StateType.PROMOTE); - else if (btn == attackBtn) - ctrl.setState(State.StateType.ATTACK); - else if (btn == checkBtn) - ctrl.done(); - else if (btn == cancelBtn) { - notify("Action canceled"); - ctrl.abort(); - } - - btn = null; + } else + return false; return true; } |