diff options
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Army.java (renamed from core/src/ch/asynk/tankontank/game/Army.java) | 8 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/HeadedPawn.java | 4 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Pawn.java | 15 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Ctrl.java | 1 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Factory.java | 1 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Player.java | 3 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Unit.java | 23 |
7 files changed, 30 insertions, 25 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Army.java b/core/src/ch/asynk/tankontank/engine/Army.java index 852dbe9..878fe89 100644 --- a/core/src/ch/asynk/tankontank/game/Army.java +++ b/core/src/ch/asynk/tankontank/engine/Army.java @@ -1,8 +1,12 @@ -package ch.asynk.tankontank.game; +package ch.asynk.tankontank.engine; public enum Army { - GE("German"), US("US"); + GE("German"), + US("US"), + USSR("Soviet"), + EN("English"); + private String s; Army(String s) { this.s = s; } diff --git a/core/src/ch/asynk/tankontank/engine/HeadedPawn.java b/core/src/ch/asynk/tankontank/engine/HeadedPawn.java index a42f699..8965a6e 100644 --- a/core/src/ch/asynk/tankontank/engine/HeadedPawn.java +++ b/core/src/ch/asynk/tankontank/engine/HeadedPawn.java @@ -14,9 +14,9 @@ public abstract class HeadedPawn extends Pawn private Image head; protected Orientation orientation; - public HeadedPawn(TextureAtlas atlas, String pawn, String head) + public HeadedPawn(Army army, TextureAtlas atlas, String pawn, String head) { - super(atlas, pawn); + super(army, atlas, pawn); this.head = new Image(atlas.findRegion(head)); this.orientation = Orientation.KEEP; this.descr += " " + orientation; diff --git a/core/src/ch/asynk/tankontank/engine/Pawn.java b/core/src/ch/asynk/tankontank/engine/Pawn.java index 197fde4..f7bb830 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 Moveable, Disposable private Vector3 position = new Vector3(0f, 0f, 0f); private Vector3 prevPosition = new Vector3(0f, 0f, 0f); + protected Army army; protected String descr; private Image image; private StackedImages overlays; @@ -48,7 +49,6 @@ public abstract class Pawn implements Moveable, Disposable public abstract boolean isHq(); public abstract boolean isHqOf(Pawn other); public abstract boolean isUnit(); - public abstract boolean isEnemy(Pawn other); public abstract boolean canMove(); public abstract boolean canRotate(); @@ -67,8 +67,9 @@ public abstract class Pawn implements Moveable, Disposable { } - public Pawn(TextureAtlas atlas, String name) + public Pawn(Army army, TextureAtlas atlas, String name) { + this.army = army; this.descr = descr; this.image = new Image(atlas.findRegion(name)); this.overlays = new StackedImages(atlas); @@ -86,6 +87,16 @@ public abstract class Pawn implements Moveable, Disposable image.dispose(); } + public boolean isEnemy(Army other) + { + return army.isEnemy(other); + } + + public boolean isEnemy(Pawn other) + { + return army.isEnemy(other.army); + } + public boolean isFlankAttack() { return (attack.isClear && attack.isFlank); diff --git a/core/src/ch/asynk/tankontank/game/Ctrl.java b/core/src/ch/asynk/tankontank/game/Ctrl.java index ca2ca64..2a8c99a 100644 --- a/core/src/ch/asynk/tankontank/game/Ctrl.java +++ b/core/src/ch/asynk/tankontank/game/Ctrl.java @@ -3,6 +3,7 @@ package ch.asynk.tankontank.game; import com.badlogic.gdx.utils.Disposable; import ch.asynk.tankontank.TankOnTank; +import ch.asynk.tankontank.engine.Army; import ch.asynk.tankontank.game.states.StateCommon; import ch.asynk.tankontank.game.states.StateSelect; import ch.asynk.tankontank.game.states.StateMove; diff --git a/core/src/ch/asynk/tankontank/game/Factory.java b/core/src/ch/asynk/tankontank/game/Factory.java index 86db346..fe0ffaa 100644 --- a/core/src/ch/asynk/tankontank/game/Factory.java +++ b/core/src/ch/asynk/tankontank/game/Factory.java @@ -9,6 +9,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.math.GridPoint2; import ch.asynk.tankontank.TankOnTank; +import ch.asynk.tankontank.engine.Army; import ch.asynk.tankontank.engine.Board; import ch.asynk.tankontank.engine.Orientation; import ch.asynk.tankontank.game.Unit.UnitId; diff --git a/core/src/ch/asynk/tankontank/game/Player.java b/core/src/ch/asynk/tankontank/game/Player.java index 2dbc1b6..b9bba70 100644 --- a/core/src/ch/asynk/tankontank/game/Player.java +++ b/core/src/ch/asynk/tankontank/game/Player.java @@ -12,6 +12,7 @@ import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import ch.asynk.tankontank.TankOnTank; +import ch.asynk.tankontank.engine.Army; import ch.asynk.tankontank.engine.Pawn; import ch.asynk.tankontank.engine.gfx.Image; import ch.asynk.tankontank.engine.gfx.Drawable; @@ -122,7 +123,7 @@ public class Player implements Drawable, Disposable public boolean isEnemy(Pawn pawn) { - return ((Unit) pawn).isEnemy(army); + return pawn.isEnemy(army); } public boolean canPromote(Pawn pawn) diff --git a/core/src/ch/asynk/tankontank/game/Unit.java b/core/src/ch/asynk/tankontank/game/Unit.java index c33e721..ce652b2 100644 --- a/core/src/ch/asynk/tankontank/game/Unit.java +++ b/core/src/ch/asynk/tankontank/game/Unit.java @@ -3,6 +3,7 @@ package ch.asynk.tankontank.game; import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.g2d.TextureAtlas; +import ch.asynk.tankontank.engine.Army; import ch.asynk.tankontank.engine.Pawn; import ch.asynk.tankontank.engine.Tile; import ch.asynk.tankontank.engine.HeadedPawn; @@ -51,20 +52,18 @@ public class Unit extends HeadedPawn public int mp; public UnitType type; public UnitId id; - public Army army; private boolean hasMoved; private boolean hasFired; - protected Unit(TextureAtlas atlas, String pawn, String head) + protected Unit(Army army, TextureAtlas atlas, String pawn, String head) { - super(atlas, pawn, head); + super(army, atlas, pawn, head); } // hard tager public Unit(Army army, UnitId id, UnitType type, int range, int defense, int movementPoints, TextureAtlas atlas, String unit, String head) { - super(atlas, unit, head); - this.army = army; + super(army, atlas, unit, head); this.rng = range; this.def = defense; this.mp = movementPoints; @@ -78,8 +77,7 @@ public class Unit extends HeadedPawn // soft tager public Unit(Army army, UnitId id, UnitType type, int range, int defense, int concealedDefense, int movementPoints, TextureAtlas atlas, String unit, String head) { - super(atlas, unit, head); - this.army = army; + super(army, atlas, unit, head); this.rng = range; this.def = defense; this.cdef = concealedDefense; @@ -91,11 +89,6 @@ public class Unit extends HeadedPawn this.descr = id.toString() + " (" + rng + "-" + def + "/" + cdef + "-" + mp + ")"; } - public boolean isEnemy(Army other) - { - return army.isEnemy(other); - } - @Override public int getMovementPoints() { @@ -150,12 +143,6 @@ public class Unit extends HeadedPawn } @Override - public boolean isEnemy(Pawn other) - { - return army.isEnemy(((Unit) other).army); - } - - @Override public boolean canRotate() { if (type == UnitType.HARD_TARGET) return !hasMoved; |