summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-11-04 16:20:52 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-11-04 16:20:52 +0100
commitc54d68e0be7fc93d049c24001363301e4a76c9fe (patch)
tree45ac0caabe6b720073435ecf1bdc64f0b4617dc5 /core
parentbb23047d69124762a7b0c15d2fac09622241ea7e (diff)
downloadRustAndDust-c54d68e0be7fc93d049c24001363301e4a76c9fe.zip
RustAndDust-c54d68e0be7fc93d049c24001363301e4a76c9fe.tar.gz
UnitDock: add selected pawn Image
Diffstat (limited to 'core')
-rw-r--r--core/src/ch/asynk/tankontank/game/Hud.java2
-rw-r--r--core/src/ch/asynk/tankontank/game/hud/UnitDock.java18
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<Pawn> 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);
}