diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-09-24 22:28:28 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-09-24 22:28:28 +0200 |
commit | 86e4d41860b7aaeb37244fb09ccf07a2c2832627 (patch) | |
tree | 72d6265290194f8ca104b179d5b8511cd748dbea /core/src/ch/asynk/tankontank | |
parent | 99c197a15f73c7ab0f4c6c527a3c08265e085ae1 (diff) | |
download | RustAndDust-86e4d41860b7aaeb37244fb09ccf07a2c2832627.zip RustAndDust-86e4d41860b7aaeb37244fb09ccf07a2c2832627.tar.gz |
Pawn,Unit,Army: implement isEnemy(Pawn)
Diffstat (limited to 'core/src/ch/asynk/tankontank')
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Pawn.java | 1 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Army.java | 7 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Unit.java | 6 |
3 files changed, 13 insertions, 1 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Pawn.java b/core/src/ch/asynk/tankontank/engine/Pawn.java index 8da9774..f5304c7 100644 --- a/core/src/ch/asynk/tankontank/engine/Pawn.java +++ b/core/src/ch/asynk/tankontank/engine/Pawn.java @@ -26,6 +26,7 @@ public abstract class Pawn extends Image implements Disposable public abstract int getMvt(); public abstract int roadMarch(); + public abstract boolean isEnemy(Pawn other); public Pawn(TextureRegion region, TextureAtlas atlas) { diff --git a/core/src/ch/asynk/tankontank/game/Army.java b/core/src/ch/asynk/tankontank/game/Army.java index 95b06e9..66c6b4f 100644 --- a/core/src/ch/asynk/tankontank/game/Army.java +++ b/core/src/ch/asynk/tankontank/game/Army.java @@ -2,5 +2,10 @@ package ch.asynk.tankontank.game; public enum Army { - GE, US + GE, US; + + public boolean isEnemy(Army other) + { + return (this != other); + } } diff --git a/core/src/ch/asynk/tankontank/game/Unit.java b/core/src/ch/asynk/tankontank/game/Unit.java index 40fb68d..d9f0789 100644 --- a/core/src/ch/asynk/tankontank/game/Unit.java +++ b/core/src/ch/asynk/tankontank/game/Unit.java @@ -27,6 +27,12 @@ public class Unit extends Pawn return 1; } + @Override + public boolean isEnemy(Pawn other) + { + return army.isEnemy(((Unit) other).army); + } + // hard tager public Unit(Army army, boolean hq, int range, int defense, int movementPoints, TextureRegion region, TextureAtlas atlas) { |