summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/rustanddust/engine
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2017-02-23 17:25:15 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2017-02-23 17:25:15 +0100
commitd312cc529f90d025d0a199de7195196424641bed (patch)
tree282edf3c6ab8866d4f3dbc93df2ce967c3906028 /core/src/ch/asynk/rustanddust/engine
parent12345ad46b12497af9912413b2404df7891c63e6 (diff)
downloadRustAndDust-d312cc529f90d025d0a199de7195196424641bed.zip
RustAndDust-d312cc529f90d025d0a199de7195196424641bed.tar.gz
HeadedPawn: add select(), and selectable attribute
Diffstat (limited to 'core/src/ch/asynk/rustanddust/engine')
-rw-r--r--core/src/ch/asynk/rustanddust/engine/HeadedPawn.java20
1 files changed, 15 insertions, 5 deletions
diff --git a/core/src/ch/asynk/rustanddust/engine/HeadedPawn.java b/core/src/ch/asynk/rustanddust/engine/HeadedPawn.java
index 90de097..faac25a 100644
--- a/core/src/ch/asynk/rustanddust/engine/HeadedPawn.java
+++ b/core/src/ch/asynk/rustanddust/engine/HeadedPawn.java
@@ -12,6 +12,8 @@ public abstract class HeadedPawn extends Pawn
private Sprite body;
private float turretR;
private boolean canAim;
+ private boolean selectable;
+ private boolean selected;
protected Orientation orientation;
protected HeadedPawn()
@@ -20,7 +22,7 @@ public abstract class HeadedPawn extends Pawn
this.orientation = Orientation.KEEP;
}
- public HeadedPawn(Faction faction, AtlasRegion chit, AtlasRegion body, AtlasRegion turret, TextureAtlas overlays)
+ public HeadedPawn(Faction faction, AtlasRegion chit, AtlasRegion body, AtlasRegion turret, TextureAtlas overlays, boolean selectable)
{
super(faction, chit, overlays);
this.body = new Sprite(body);
@@ -29,6 +31,14 @@ public abstract class HeadedPawn extends Pawn
this.orientation = Orientation.KEEP;
this.descr += " " + orientation;
this.canAim = (turret != null);
+ this.selectable = selectable;
+ this.selected = !selectable;
+ }
+
+ public void select(boolean s)
+ {
+ if (!selectable) return;
+ this.selected = s;
}
@Override
@@ -110,10 +120,10 @@ public abstract class HeadedPawn extends Pawn
@Override
public void draw(Batch batch)
{
- sprite.draw(batch);
+ if (selected) sprite.draw(batch);
body.draw(batch);
if (canAim) turret.draw(batch);
- overlays.draw(batch);
+ if (selected) overlays.draw(batch);
}
@Override
@@ -121,7 +131,7 @@ public abstract class HeadedPawn extends Pawn
{
float w = sprite.getWidth();
float h = sprite.getHeight();
- debugShapes.rect(sprite.getX(), sprite.getY(), (w / 2f), (h / 2f), w, h, sprite.getScaleX(), sprite.getScaleY(), sprite.getRotation());
+ if (selected) debugShapes.rect(sprite.getX(), sprite.getY(), (w / 2f), (h / 2f), w, h, sprite.getScaleX(), sprite.getScaleY(), sprite.getRotation());
w = body.getWidth();
h = body.getHeight();
debugShapes.rect(body.getX(), body.getY(), (w / 2f), (h / 2f), w, h, body.getScaleX(), body.getScaleY(), body.getRotation());
@@ -130,6 +140,6 @@ public abstract class HeadedPawn extends Pawn
h = turret.getHeight();
debugShapes.rect(turret.getX(), turret.getY(), (w / 2f), (h / 2f), w, h, turret.getScaleX(), turret.getScaleY(), turret.getRotation());
}
- overlays.drawDebug(debugShapes);
+ if (selected) overlays.drawDebug(debugShapes);
}
}