From 1f677a6d9dc629048a2fea532500ee5d1c32d094 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 7 Nov 2014 16:58:18 +0100 Subject: Hud: add dialog end turn ?? --- core/src/ch/asynk/tankontank/game/Hud.java | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/core/src/ch/asynk/tankontank/game/Hud.java b/core/src/ch/asynk/tankontank/game/Hud.java index 6482077..f1de5eb 100644 --- a/core/src/ch/asynk/tankontank/game/Hud.java +++ b/core/src/ch/asynk/tankontank/game/Hud.java @@ -16,6 +16,7 @@ import ch.asynk.tankontank.game.hud.Bg; import ch.asynk.tankontank.game.hud.Button; import ch.asynk.tankontank.game.hud.TextImage; import ch.asynk.tankontank.game.hud.UnitDock; +import ch.asynk.tankontank.game.hud.Dialog; import ch.asynk.tankontank.game.hud.Position; import ch.asynk.tankontank.TankOnTank; @@ -47,6 +48,7 @@ public class Hud implements Disposable private TextImage aps; private TextImage reinforcement; private UnitDock unitDock; + public Dialog dialog; private Vector2 corner; @@ -75,6 +77,8 @@ public class Hud implements Disposable reinforcement = new TextImage(atlas.findRegion("reinforcement"), game.skin.getFont("default-font"), "0"); unitDock = new UnitDock(ctrl, atlas.findRegion("disabled"), atlas.findRegion("reinforcement-selected")); + dialog = new Dialog(game.skin.getFont("default-font"), atlas.findRegion("disabled"), atlas); + float x = OFFSET; float y = (Gdx.graphics.getHeight() - OFFSET); usFlag.setPosition(x, (y - usFlag.getHeight())); @@ -158,6 +162,7 @@ public class Hud implements Disposable checkBtn.draw(batch); cancelBtn.draw(batch); msg.draw(batch); + dialog.draw(batch); } public Unit getDockUnit() @@ -237,6 +242,8 @@ public class Hud implements Disposable hit = unitDock; else if (reinforcement.hit(x, y)) hit = reinforcement; + else if (dialog.hit(x, y)) + hit = dialog; else if (actionsBg.hit(x,y)) { if (moveBtn.hit(x, y)) btn = moveBtn; @@ -283,15 +290,31 @@ public class Hud implements Disposable btn = null; } else if (hit != null) { if ((hit == turns) && turns.hit(x, y)) - ctrl.endPlayerTurn(); + askEndTurn(); else if ((hit == reinforcement) && reinforcement.hit(x, y)) unitDock.toggle(); else if ((hit == unitDock) && unitDock.hit(x, y)) ctrl.setState(StateType.ENTRY); + else if ((hit == dialog) && dialog.hit(x, y)) + leaveEndTurn(); hit = null; } else return false; return true; } + + private void askEndTurn() + { + ctrl.blockMap = true; + dialog.show("You still have Action Points left. End your Turn ?", Position.MIDDLE_CENTER); + } + + private void leaveEndTurn() + { + dialog.visible = false; + ctrl.blockMap = false; + if (dialog.ok) + ctrl.endPlayerTurn(); + } } -- cgit v1.1-2-g2b99