diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2015-02-19 16:52:14 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2015-02-19 16:52:14 +0100 |
commit | cbe4077b975abbceb508c41b33523e1aafac8594 (patch) | |
tree | b13b024f7d79e70acfd684ed0d405b09b05db9b3 /core/src/ch/asynk/tankontank/game | |
parent | e215d5b574be75173d3a2e7082773f6d2853682c (diff) | |
download | RustAndDust-cbe4077b975abbceb508c41b33523e1aafac8594.zip RustAndDust-cbe4077b975abbceb508c41b33523e1aafac8594.tar.gz |
UnitDock: do net select on hit, add Unit select(float, float)
Diffstat (limited to 'core/src/ch/asynk/tankontank/game')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/hud/PlayerInfo.java | 4 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/hud/UnitDock.java | 15 |
2 files changed, 11 insertions, 8 deletions
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() |