diff options
Diffstat (limited to 'core/src/ch/asynk/tankontank/engine')
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Army.java | 22 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/HeadedPawn.java | 4 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Pawn.java | 15 |
3 files changed, 37 insertions, 4 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Army.java b/core/src/ch/asynk/tankontank/engine/Army.java new file mode 100644 index 0000000..878fe89 --- /dev/null +++ b/core/src/ch/asynk/tankontank/engine/Army.java @@ -0,0 +1,22 @@ +package ch.asynk.tankontank.engine; + +public enum Army +{ + GE("German"), + US("US"), + USSR("Soviet"), + EN("English"); + + private String s; + Army(String s) { this.s = s; } + + public boolean isEnemy(Army other) + { + return (this != other); + } + + public String toString() + { + return 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); |