diff options
Diffstat (limited to 'core/src/ch/asynk/tankontank')
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Pawn.java | 7 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/SearchBoard.java | 7 |
2 files changed, 12 insertions, 2 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Pawn.java b/core/src/ch/asynk/tankontank/engine/Pawn.java index 716b66b..2986002 100644 --- a/core/src/ch/asynk/tankontank/engine/Pawn.java +++ b/core/src/ch/asynk/tankontank/engine/Pawn.java @@ -143,6 +143,13 @@ public abstract class Pawn implements Moveable, Disposable move(); } + public void setAttack(Pawn target, int distance) + { + attack.reset(); + attack.target = target; + attack.distance = distance; + } + public boolean justEntered() { return ((move != null) && move.isEntry()); diff --git a/core/src/ch/asynk/tankontank/engine/SearchBoard.java b/core/src/ch/asynk/tankontank/engine/SearchBoard.java index 41516ae..199a7a7 100644 --- a/core/src/ch/asynk/tankontank/engine/SearchBoard.java +++ b/core/src/ch/asynk/tankontank/engine/SearchBoard.java @@ -326,9 +326,9 @@ public class SearchBoard Node from = getNode(pawn.getTile()); Node to = getNode(target.getTile()); - int distance = distance(from, to); + pawn.setAttack(target, distance(from, to)); - if (distance > pawn.getEngagementRangeFrom(pawn.getTile())) + if (pawn.attack.distance > pawn.getEngagementRangeFrom(pawn.getTile())) return false; List<Node> los = lineOfSight(from.col, from.row, to.col, to.row, clearVisibility); @@ -339,6 +339,9 @@ public class SearchBoard if (!validatePathAngle(pawn.getAngleOfAttack(), los)) return false; + pawn.attack.isClear = isClearAttack(getTile(from), los); + pawn.attack.isFlank = isFlankAttack(target.getFlankSides(), los); + return true; } |