From 25f0e73ec6a9c4479dd68357bf126da73e8e7f7e Mon Sep 17 00:00:00 2001 From: Jérémy Zurcher Date: Tue, 11 Nov 2014 18:24:58 +0100 Subject: Hud,PlayerInfo: simplify touchUp/Down control --- .../ch/asynk/tankontank/game/hud/PlayerInfo.java | 29 +++++++++++----------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'core/src/ch/asynk/tankontank/game/hud') diff --git a/core/src/ch/asynk/tankontank/game/hud/PlayerInfo.java b/core/src/ch/asynk/tankontank/game/hud/PlayerInfo.java index bb4ad933..7e751bfd 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; -- cgit v1.2.3