From 9ed71f01974aefe888e54b7c099852ecd8323bb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 18 Feb 2015 11:32:44 +0100 Subject: Pawn: add int attackDistance(), and use it in Map --- core/src/ch/asynk/tankontank/engine/Pawn.java | 5 +++++ core/src/ch/asynk/tankontank/game/Map.java | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/ch/asynk/tankontank/engine/Pawn.java b/core/src/ch/asynk/tankontank/engine/Pawn.java index 2986002..7e0f9da 100644 --- a/core/src/ch/asynk/tankontank/engine/Pawn.java +++ b/core/src/ch/asynk/tankontank/engine/Pawn.java @@ -175,6 +175,11 @@ public abstract class Pawn implements Moveable, Disposable return (attack.isClear && attack.isFlank); } + public int attackDistance() + { + return attack.distance; + } + public Tile getTile() { return tile; diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java index c19ee62..2ef7749 100644 --- a/core/src/ch/asynk/tankontank/game/Map.java +++ b/core/src/ch/asynk/tankontank/game/Map.java @@ -489,9 +489,8 @@ public abstract class Map extends Board implements MoveToAnimationCb, ObjectiveS if (assist.isA(Unit.UnitType.INFANTRY)) terrainBonus = false; if (night) { - int d = distance(assist.getTile(), target.getTile()); - if (d > distance) - distance = d; + if (distance < assist.attackDistance()) + distance = assist.attackDistance(); } } -- cgit v1.1-2-g2b99