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 | |
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')
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Pawn.java | 1 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Unit.java | 46 |
2 files changed, 43 insertions, 4 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Pawn.java b/core/src/ch/asynk/tankontank/engine/Pawn.java index 949803e..6243cf6 100644 --- a/core/src/ch/asynk/tankontank/engine/Pawn.java +++ b/core/src/ch/asynk/tankontank/engine/Pawn.java @@ -34,6 +34,7 @@ public abstract class Pawn implements Drawable, Disposable public abstract boolean isUnit(); public abstract boolean isEnemy(Pawn other); public abstract boolean canMove(); + public abstract boolean canRotate(); public abstract boolean canAttack(); public abstract boolean canAttack(Pawn other); public abstract int getAngleOfAttack(); 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) { |