summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/ch/asynk/tankontank')
-rw-r--r--core/src/ch/asynk/tankontank/game/Hud.java2
-rw-r--r--core/src/ch/asynk/tankontank/game/hud/UnitDock.java33
2 files changed, 20 insertions, 15 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Hud.java b/core/src/ch/asynk/tankontank/game/Hud.java
index f441931..48ccafe 100644
--- a/core/src/ch/asynk/tankontank/game/Hud.java
+++ b/core/src/ch/asynk/tankontank/game/Hud.java
@@ -89,7 +89,7 @@ public class Hud implements Disposable
aps.setLabelPosition(Position.TOP_RIGHT);
reinforcement.setPosition(x, usFlag.getY() - reinforcement.getHeight() - 0);
reinforcement.setLabelPosition(Position.TOP_LEFT);
- unitDock.setTopLeft(OFFSET, reinforcement.getY() - 5);
+ unitDock.setPosition(Position.TOP_LEFT, reinforcement.getY() - 5);
}
@Override
diff --git a/core/src/ch/asynk/tankontank/game/hud/UnitDock.java b/core/src/ch/asynk/tankontank/game/hud/UnitDock.java
index 4e75690..5bd2a6d 100644
--- a/core/src/ch/asynk/tankontank/game/hud/UnitDock.java
+++ b/core/src/ch/asynk/tankontank/game/hud/UnitDock.java
@@ -21,19 +21,20 @@ public class UnitDock extends Bg
private final Ctrl ctrl;
private float padding;
- public float x;
- public float y;
- public float to;
+ private float y;
+ private float to;
private float dx;
- public boolean show;
- public boolean done;
+ private float step;
+ private Position position;
+ private boolean show;
+ private boolean done;
public Pawn selectedPawn;
private Sprite selected;
private List<Pawn> pawns;
private Vector3 point;
private Matrix4 saved;
private Matrix4 transform;
- protected Rectangle scaledRect;
+ private Rectangle scaledRect;
public UnitDock(Ctrl ctrl, TextureRegion bg, TextureRegion selected, float padding)
{
@@ -49,10 +50,13 @@ public class UnitDock extends Bg
this.visible = false;
}
- public void setTopLeft(float x, float y)
+ public void setPosition(Position position, float y)
{
- this.x = x;
+ this.position = position;
this.y = y;
+ this.step = (position.isLeft() ? STEP : -STEP);
+ this.done = true;
+ this.visible = false;
}
@Override
@@ -70,7 +74,7 @@ public class UnitDock extends Bg
public void hide()
{
if (!visible) return;
- to = - (rect.width * SCALE);
+ to = rect.x;
show = false;
done = false;
}
@@ -89,11 +93,12 @@ public class UnitDock extends Bg
public void show()
{
+ float x = position.getX(rect.width * SCALE);
if (done) {
pawns = ctrl.player.getReinforcement();
rect.width = pawns.get(0).getWidth() + (2 * padding);
rect.height = ((pawns.get(0).getHeight() * pawns.size()) + ((pawns.size() + 1) * padding));
- rect.x = - (rect.width * SCALE);
+ rect.x = (position.isLeft() ? (0 - (rect.width * SCALE)) : (x + (rect.width * SCALE)));
rect.y = y - rect.height;
// position units here
float px = rect.x;
@@ -122,15 +127,15 @@ public class UnitDock extends Bg
float x = (rect.x + dx);
if (show) {
- if (x < to)
- dx += STEP;
+ if ((position.isLeft() && (x < to)) || (!position.isLeft() && x > to))
+ dx += step;
else {
dx = (to - rect.x);
done = true;
}
} else {
- if (x > to)
- dx -= STEP;
+ if ((position.isLeft() && (x > to)) || (!position.isLeft() && x < to))
+ dx -= step;
else {
dx = (to - rect.x);
done = true;