diff options
| author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-11 18:24:58 +0100 | 
|---|---|---|
| committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-11 18:24:58 +0100 | 
| commit | 25f0e73ec6a9c4479dd68357bf126da73e8e7f7e (patch) | |
| tree | 2f810e602dc51654d8d6425c735d4aa3b8f98bcb /core/src/ch/asynk | |
| parent | e297e981cdb8e4136911339f1f99a742eafa4ae5 (diff) | |
| download | RustAndDust-25f0e73ec6a9c4479dd68357bf126da73e8e7f7e.zip RustAndDust-25f0e73ec6a9c4479dd68357bf126da73e8e7f7e.tar.gz | |
Hud,PlayerInfo: simplify touchUp/Down control
Diffstat (limited to 'core/src/ch/asynk')
| -rw-r--r-- | core/src/ch/asynk/tankontank/game/Hud.java | 28 | ||||
| -rw-r--r-- | core/src/ch/asynk/tankontank/game/hud/PlayerInfo.java | 29 | 
2 files changed, 31 insertions, 26 deletions
| diff --git a/core/src/ch/asynk/tankontank/game/Hud.java b/core/src/ch/asynk/tankontank/game/Hud.java index 3afd2dc..f39a1e7 100644 --- a/core/src/ch/asynk/tankontank/game/Hud.java +++ b/core/src/ch/asynk/tankontank/game/Hud.java @@ -119,18 +119,16 @@ public class Hud implements Disposable      {          hit = null; -        if (playerInfo.touchDown(x, y)) -            hit = playerInfo; -        else if (actionButtons.touchDown(x, y)) +        if (actionButtons.touchDown(x, y))              hit = actionButtons; +        else if (playerInfo.touchDown(x, y)) +            hit = playerInfo;          else if (okCancel.hit(x, y))              hit = okCancel;          else if (stats.hit(x, y))              hit = stats; -        else -            return false; -        return true; +        return (hit != null);      }      public boolean touchUp(float x, float y) @@ -138,14 +136,20 @@ public class Hud implements Disposable          if (hit == null)              return false; -        if (hit == actionButtons) +        if (hit == actionButtons) {              actionButtons.touchUp(x, y); -        else if (hit == playerInfo) +        } +        else if (hit == playerInfo) {              playerInfo.touchUp(x, y); -        else if ((hit == okCancel) && okCancel.hit(x, y)) -            closeDialog(); -        else if ((hit == stats) && stats.hit(x, y)) -            closeDialog(); +        } +        else if (hit == okCancel) { +            if (okCancel.hit(x, y)) +                closeDialog(); +        } +        else if (hit == stats) { +            if (stats.hit(x, y)) +                closeDialog(); +        }          hit = null; diff --git a/core/src/ch/asynk/tankontank/game/hud/PlayerInfo.java b/core/src/ch/asynk/tankontank/game/hud/PlayerInfo.java index bb4ad93..7e751bf 100644 --- a/core/src/ch/asynk/tankontank/game/hud/PlayerInfo.java +++ b/core/src/ch/asynk/tankontank/game/hud/PlayerInfo.java @@ -135,15 +135,10 @@ public class PlayerInfo implements Disposable, Drawable              hit = reinforcement;          else if (unitDock.hit(x, y))              hit = unitDock; -        else { -            hideUnitDock(); -            if (turns.hit(x,y)) -                hit = turns; -            else -                return false; -        } +        else if (turns.hit(x,y)) +            hit = turns; -        return true; +        return (hit != null);      }      public boolean touchUp(float x, float y) @@ -151,12 +146,18 @@ public class PlayerInfo implements Disposable, Drawable          if (hit == null)              return false; -        if ((hit == turns) && turns.hit(x, y)) -            ctrl.hud.askEndTurn(); -        else if ((hit == reinforcement) && reinforcement.hit(x, y)) -            unitDock.toggle(); -        else if ((hit == unitDock) && unitDock.hit(x, y)) -            ctrl.setState(StateType.ENTRY); +        if (hit == turns) { +            if (turns.hit(x, y)) +                ctrl.hud.askEndTurn(); +        } +        else if (hit == reinforcement) { +            if (reinforcement.hit(x, y)) +                ctrl.toggleState(StateType.ENTRY, StateType.SELECT); +        } +        else if (hit == unitDock) { +            if (unitDock.hit(x, y)) +                ctrl.stateTouchUp(); +        }          hit = null; | 
