summaryrefslogtreecommitdiffstats
path: root/core/src
diff options
context:
space:
mode:
Diffstat (limited to 'core/src')
-rw-r--r--core/src/ch/asynk/tankontank/engine/Pawn.java1
-rw-r--r--core/src/ch/asynk/tankontank/game/Unit.java46
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)
{