diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-09 13:57:59 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-09 13:57:59 +0200 |
commit | d456031068b7fb6df8f1ee1d262b26c9ab42c8d1 (patch) | |
tree | 0d8d79fea1817139479dd95aaf9c46be45bc4a0a /core/src/ch/asynk/tankontank/game | |
parent | 589e590a645a4a1005263bf07147b0e17e644979 (diff) | |
download | RustAndDust-d456031068b7fb6df8f1ee1d262b26c9ab42c8d1.zip RustAndDust-d456031068b7fb6df8f1ee1d262b26c9ab42c8d1.tar.gz |
Paw,Unit: set fire() rotate() move(in), reset()
Diffstat (limited to 'core/src/ch/asynk/tankontank/game')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Unit.java | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Unit.java b/core/src/ch/asynk/tankontank/game/Unit.java index 0a066e0..b5924f3 100644 --- a/core/src/ch/asynk/tankontank/game/Unit.java +++ b/core/src/ch/asynk/tankontank/game/Unit.java @@ -18,6 +18,15 @@ public class Unit extends HeadedPawn public boolean hq; public boolean ht; public Army army; + private boolean hasMoved; + private boolean hasFired; + + public Unit(TextureAtlas atlas, String pawn, String head) + { + super(atlas, pawn, head); + hasMoved = false; + hasFired = false; + } @Override public int getMovementPoints() @@ -63,17 +72,24 @@ public class Unit extends HeadedPawn } @Override + public boolean canRotate() + { + if (ht) return !hasMoved; + return (!hasMoved && !hasFired); + } + + @Override public boolean canMove() { - // TODO - return true; + if (ht) return !hasMoved; + return (!hasMoved && !hasFired); } @Override public boolean canAttack() { - // TODO - return true; + if (ht) return !hasFired; + return (!hasMoved && !hasFired); } @Override @@ -82,6 +98,28 @@ public class Unit extends HeadedPawn return isEnemy(other); } + public void fire() + { + hasFired = true; + } + + public void rotate() + { + hasMoved = true; + } + + public void move(int cost) + { + hasMoved = true; + if (cost > mp) System.err.println("Movement point exceeded: " + cost + "/" + mp); + } + + public void reset() + { + hasFired = false; + hasMoved = false; + } + // hard tager public Unit(Army army, boolean hq, int range, int defense, int movementPoints, TextureAtlas atlas, String unit, String head) { |