summaryrefslogtreecommitdiffstats
path: root/core/src/ch
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-10-13 12:02:22 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-10-13 12:02:22 +0200
commita139e8454ac4c9c2b246d758c677cbc02d6740a2 (patch)
treeb56cf8a93ca31693a6306a2a874e16a4653d8d08 /core/src/ch
parentf1b9f389518de4c54ca2198e846fa4f266c44340 (diff)
downloadRustAndDust-a139e8454ac4c9c2b246d758c677cbc02d6740a2.zip
RustAndDust-a139e8454ac4c9c2b246d758c677cbc02d6740a2.tar.gz
Unit: set UnitType, fix getAttackRangeFrom(Tile)
Diffstat (limited to 'core/src/ch')
-rw-r--r--core/src/ch/asynk/tankontank/game/Unit.java26
1 files changed, 17 insertions, 9 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Unit.java b/core/src/ch/asynk/tankontank/game/Unit.java
index df6c093..2d79a5c 100644
--- a/core/src/ch/asynk/tankontank/game/Unit.java
+++ b/core/src/ch/asynk/tankontank/game/Unit.java
@@ -12,12 +12,19 @@ public class Unit extends HeadedPawn
{
public static final int DISABLED = 0;
+ enum UnitType
+ {
+ HARD_TARGET,
+ INFANTRY,
+ AT_GUN
+ }
+
public int rng;
public int def;
public int cdef;
public int mp;
public boolean hq;
- public boolean ht;
+ public UnitType type;
public Army army;
private boolean hasMoved;
private boolean hasFired;
@@ -28,7 +35,7 @@ public class Unit extends HeadedPawn
}
// hard tager
- public Unit(Army army, boolean hq, int range, int defense, int movementPoints, TextureAtlas atlas, String unit, String head)
+ public Unit(Army army, UnitType type, int range, int defense, int movementPoints, TextureAtlas atlas, String unit, String head)
{
super(atlas, unit, head);
this.army = army;
@@ -36,13 +43,13 @@ public class Unit extends HeadedPawn
this.rng = range;
this.def = defense;
this.mp = movementPoints;
- this.ht = true;
+ this.type = type;
this.hasMoved = false;
this.hasFired = false;
}
// soft tager
- public Unit(Army army, boolean hq, int range, int defense, int concealedDefense, int movementPoints, TextureAtlas atlas, String unit, String head)
+ public Unit(Army army, UnitType type, int range, int defense, int concealedDefense, int movementPoints, TextureAtlas atlas, String unit, String head)
{
super(atlas, unit, head);
this.army = army;
@@ -51,7 +58,7 @@ public class Unit extends HeadedPawn
this.def = defense;
this.cdef = concealedDefense;
this.mp = movementPoints;
- this.ht = false;
+ this.type = type;
this.hasMoved = false;
this.hasFired = false;
}
@@ -76,7 +83,8 @@ public class Unit extends HeadedPawn
@Override
public int getAttackRangeFrom(Tile tile)
{
- if (ht && ((Hex) tile).terrain == Hex.Terrain.HILLS) return rng + 1;
+ if ((type != UnitType.INFANTRY) && (((Hex) tile).terrain == Hex.Terrain.HILLS))
+ return rng + 1;
return rng;
}
@@ -107,21 +115,21 @@ public class Unit extends HeadedPawn
@Override
public boolean canRotate()
{
- if (ht) return !hasMoved;
+ if (type == UnitType.HARD_TARGET) return !hasMoved;
return (!hasMoved && !hasFired);
}
@Override
public boolean canMove()
{
- if (ht) return !hasMoved;
+ if (type == UnitType.HARD_TARGET) return !hasMoved;
return (!hasMoved && !hasFired);
}
@Override
public boolean canAttack()
{
- if (ht) return !hasFired;
+ if (type == UnitType.HARD_TARGET) return !hasFired;
return (!hasMoved && !hasFired);
}