From c54d68e0be7fc93d049c24001363301e4a76c9fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 4 Nov 2014 16:20:52 +0100 Subject: UnitDock: add selected pawn Image --- core/src/ch/asynk/tankontank/game/Hud.java | 2 +- core/src/ch/asynk/tankontank/game/hud/UnitDock.java | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/core/src/ch/asynk/tankontank/game/Hud.java b/core/src/ch/asynk/tankontank/game/Hud.java index 32c8d03..9a38cfe 100644 --- a/core/src/ch/asynk/tankontank/game/Hud.java +++ b/core/src/ch/asynk/tankontank/game/Hud.java @@ -73,7 +73,7 @@ public class Hud implements Disposable turns = new TextImage(atlas.findRegion("turns"), game.skin.getFont("default-font"), "0"); aps = new TextImage(atlas.findRegion("aps"), game.skin.getFont("default-font"), "0"); reinforcement = new TextImage(atlas.findRegion("reinforcement"), game.skin.getFont("default-font"), "0"); - unitDock = new UnitDock(ctrl, atlas.findRegion("disabled")); + unitDock = new UnitDock(ctrl, atlas.findRegion("disabled"), atlas.findRegion("reinforcement-selected")); float x = OFFSET; float y = (Gdx.graphics.getHeight() - OFFSET); diff --git a/core/src/ch/asynk/tankontank/game/hud/UnitDock.java b/core/src/ch/asynk/tankontank/game/hud/UnitDock.java index 49189f2..e298742 100644 --- a/core/src/ch/asynk/tankontank/game/hud/UnitDock.java +++ b/core/src/ch/asynk/tankontank/game/hud/UnitDock.java @@ -8,6 +8,7 @@ import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.math.Matrix4; import com.badlogic.gdx.math.Rectangle; +import ch.asynk.tankontank.engine.gfx.Image; import ch.asynk.tankontank.engine.Pawn; import ch.asynk.tankontank.engine.Orientation; import ch.asynk.tankontank.game.Ctrl; @@ -26,15 +27,16 @@ public class UnitDock extends Bg public boolean show; public boolean done; public Pawn selectedPawn; + private Image selected; private List pawns; private Vector3 point; private Matrix4 saved; private Matrix4 transform; protected Rectangle scaledRect; - public UnitDock(Ctrl ctrl, TextureRegion region) + public UnitDock(Ctrl ctrl, TextureRegion bg, TextureRegion selected) { - super(region); + super(bg); this.ctrl = ctrl; this.visible = false; this.done = true; @@ -42,6 +44,8 @@ public class UnitDock extends Bg this.saved = new Matrix4(); this.transform = new Matrix4(); this.scaledRect = new Rectangle(); + this.selected = new Image(selected); + this.selected.visible = false; } public void setTopLeft(float x, float y) @@ -54,6 +58,7 @@ public class UnitDock extends Bg public void dispose() { super.dispose(); + selected.dispose(); } public void toggle() @@ -147,8 +152,15 @@ public class UnitDock extends Bg batch.setTransformMatrix(transform); super.draw(batch); - for (Pawn pawn : pawns) + selected.visible = false; + for (Pawn pawn : pawns) { pawn.draw(batch); + if (pawn == selectedPawn) { + selected.visible = true; + selected.centerOn((pawn.getX() + (pawn.getWidth() / 2)), (pawn.getY() + (pawn.getHeight() / 2))); + selected.draw(batch); + } + } batch.setTransformMatrix(saved); } -- cgit v1.1-2-g2b99