From cbe4077b975abbceb508c41b33523e1aafac8594 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 19 Feb 2015 16:52:14 +0100 Subject: UnitDock: do net select on hit, add Unit select(float, float) --- TODO | 1 - core/src/ch/asynk/tankontank/game/hud/PlayerInfo.java | 4 +++- core/src/ch/asynk/tankontank/game/hud/UnitDock.java | 15 ++++++++------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/TODO b/TODO index c6a9cf4..2c1df25 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,4 @@ BUGS: - - unitDock click issues TODO: - GameModeMenu diff --git a/core/src/ch/asynk/tankontank/game/hud/PlayerInfo.java b/core/src/ch/asynk/tankontank/game/hud/PlayerInfo.java index 24f07b8..45ee5dc 100644 --- a/core/src/ch/asynk/tankontank/game/hud/PlayerInfo.java +++ b/core/src/ch/asynk/tankontank/game/hud/PlayerInfo.java @@ -162,8 +162,10 @@ public class PlayerInfo implements Disposable, Drawable, Animation ctrl.reinforcementHit(); } else if (hit == unitDock) { - if (unitDock.hit(x, y)) + if (unitDock.hit(x, y)) { + ctrl.hud.notify(unitDock.select(x, y).toString()); ctrl.stateTouchUp(); + } } hit = null; diff --git a/core/src/ch/asynk/tankontank/game/hud/UnitDock.java b/core/src/ch/asynk/tankontank/game/hud/UnitDock.java index 39041cc..05824e0 100644 --- a/core/src/ch/asynk/tankontank/game/hud/UnitDock.java +++ b/core/src/ch/asynk/tankontank/game/hud/UnitDock.java @@ -92,13 +92,14 @@ public class UnitDock extends Bg implements Animation @Override public boolean hit(float x, float y) { - if (visible && scaledRect.contains(x, y)) { - int i = (int) ((scaledRect.y + scaledRect.height - y) / (scaledRect.height / units.size())); - selectedUnit = units.get(i); - ctrl.hud.notify(selectedUnit.toString()); - return true; - } - return false; + return (visible && scaledRect.contains(x, y)); + } + + public Unit select(float x, float y) + { + int i = (int) ((scaledRect.y + scaledRect.height - y) / (scaledRect.height / units.size())); + selectedUnit = units.get(i); + return selectedUnit; } public void hide() -- cgit v1.1-2-g2b99