From b10253415d85866db1305bce381874163146062b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 17 Oct 2014 09:46:06 +0200 Subject: Player: attributes becom public, add getX/Y/Width/Height --- core/src/ch/asynk/tankontank/game/Player.java | 48 +++++++++++++++++++-------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/core/src/ch/asynk/tankontank/game/Player.java b/core/src/ch/asynk/tankontank/game/Player.java index 0194cc7..12c9c13 100644 --- a/core/src/ch/asynk/tankontank/game/Player.java +++ b/core/src/ch/asynk/tankontank/game/Player.java @@ -20,21 +20,21 @@ public class Player implements Drawable, Disposable private static Random rand = new Random(); - private Army army; - private Image flag; - private ArrayList units; - private ArrayList casualties; - private ArrayList reinforcement; - private int actionPoints; + public Army army; + public Image flag; + public ArrayList units; + public ArrayList casualties; + public ArrayList reinforcement; + public int actionPoints; public Player(Army army, TextureAtlas atlas, String name, int size) { this.army = army; + this.actionPoints = 0; this.flag = new Image(atlas.findRegion(name)); this.units = new ArrayList(size); this.casualties = new ArrayList(size); this.reinforcement = new ArrayList(size); - this.actionPoints = 0; } public String toString() @@ -61,11 +61,6 @@ public class Player implements Drawable, Disposable System.err.println(" casualty : " + pawn); } - public Image getFlag() - { - return flag; - } - public boolean apExhausted() { return (actionPoints <= 0); @@ -87,7 +82,7 @@ public class Player implements Drawable, Disposable { for (Pawn pawn : units) pawn.reset(); - setActionPoints(); + computeActionPoints(); System.err.println("TurnStart " + toString()); } @@ -96,7 +91,7 @@ public class Player implements Drawable, Disposable return rand.nextInt(6) + 1; } - private void setActionPoints() + private void computeActionPoints() { this.actionPoints = 2; if (d6() > 2) { @@ -133,11 +128,36 @@ public class Player implements Drawable, Disposable return null; } + public boolean contains(float x, float y) + { + return flag.contains(x, y); + } + public void setPosition(float x, float y) { flag.setPosition(x, y); } + public float getX() + { + return flag.getX(); + } + + public float getY() + { + return flag.getY(); + } + + public float getWidth() + { + return flag.getWidth(); + } + + public float getHeight() + { + return flag.getHeight(); + } + public Iterator unitIterator() { return units.iterator(); -- cgit v1.1-2-g2b99