diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-09-30 01:01:10 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-09-30 01:01:10 +0200 |
commit | 26010226c374741a0edf8bdba5e94de2d0d9815c (patch) | |
tree | bc1c1ea60d31dc599c1b4ceb4523c33e7c34d5ca /core/src | |
parent | e97ca62a1857796da612abf6b1255d833abcb8e6 (diff) | |
download | RustAndDust-26010226c374741a0edf8bdba5e94de2d0d9815c.zip RustAndDust-26010226c374741a0edf8bdba5e94de2d0d9815c.tar.gz |
Tile/Hex: add blockLineOfSightFrom(Tile)
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Tile.java | 1 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Hex.java | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Tile.java b/core/src/ch/asynk/tankontank/engine/Tile.java index c366508..c5ca8b1 100644 --- a/core/src/ch/asynk/tankontank/engine/Tile.java +++ b/core/src/ch/asynk/tankontank/engine/Tile.java @@ -22,6 +22,7 @@ public abstract class Tile implements Drawable public abstract int costFrom(Pawn pawn, Board.Orientation side, boolean road); public abstract boolean hasTargetsFor(Pawn pawn); public abstract boolean isOffMap(); + public abstract boolean blockLineOfSightFrom(Tile tile); protected Tile() { diff --git a/core/src/ch/asynk/tankontank/game/Hex.java b/core/src/ch/asynk/tankontank/game/Hex.java index f7b1e23..4e07492 100644 --- a/core/src/ch/asynk/tankontank/game/Hex.java +++ b/core/src/ch/asynk/tankontank/game/Hex.java @@ -42,6 +42,18 @@ public class Hex extends Tile } @Override + public boolean blockLineOfSightFrom(Tile tile) + { + if ((terrain == Terrain.CLEAR) && !occupied()) + return false; + + if ((((Hex) tile).terrain == Terrain.HILLS) && (terrain == Terrain.CLEAR)) + return false; + + return true; + } + + @Override public boolean atLeastOneMove(Pawn pawn) { if (occupied() || (terrain == Terrain.BLOCKED) || (terrain == Terrain.OFFMAP)) |