From a31850c31c0f2f70e9bd191f6d69f43abd619696 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 17 Nov 2014 16:18:15 +0100 Subject: Tile: add interface TileTerrain, boolean isA(TileTerrain terrain) --- core/src/ch/asynk/tankontank/engine/Tile.java | 5 +++++ core/src/ch/asynk/tankontank/game/Hex.java | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/core/src/ch/asynk/tankontank/engine/Tile.java b/core/src/ch/asynk/tankontank/engine/Tile.java index 4065346..ed861db 100644 --- a/core/src/ch/asynk/tankontank/engine/Tile.java +++ b/core/src/ch/asynk/tankontank/engine/Tile.java @@ -17,6 +17,10 @@ import ch.asynk.tankontank.engine.gfx.StackedImages; public abstract class Tile implements Drawable, Disposable, Iterable { + public interface TileTerrain + { + } + protected int col; protected int row; protected float x; @@ -28,6 +32,7 @@ public abstract class Tile implements Drawable, Disposable, Iterable public abstract int costFrom(Pawn pawn, Orientation side); public abstract boolean isOffMap(); + public abstract boolean isA(TileTerrain terrain); public abstract boolean road(Orientation side); public abstract boolean atLeastOneMove(Pawn pawn); public abstract boolean blockLineOfSightFrom(Tile tile); diff --git a/core/src/ch/asynk/tankontank/game/Hex.java b/core/src/ch/asynk/tankontank/game/Hex.java index 656a1e6..7abf0d3 100644 --- a/core/src/ch/asynk/tankontank/game/Hex.java +++ b/core/src/ch/asynk/tankontank/game/Hex.java @@ -12,7 +12,7 @@ import ch.asynk.tankontank.engine.Orientation; public class Hex extends Tile { - public enum Terrain + public enum Terrain implements TileTerrain { OFFMAP, BLOCKED, @@ -52,6 +52,12 @@ public class Hex extends Tile } @Override + public boolean isA(TileTerrain terrain) + { + return (this.terrain == terrain); + } + + @Override public boolean isOffMap() { return terrain == Terrain.OFFMAP; -- cgit v1.1-2-g2b99