From e90b60de481ffe404c49dc5b3c0716af31866d72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 18 Feb 2015 11:11:45 +0100 Subject: Attack: set (Pawn attacker) constructor parameter --- core/src/ch/asynk/tankontank/engine/Attack.java | 6 +++++- core/src/ch/asynk/tankontank/engine/Pawn.java | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/core/src/ch/asynk/tankontank/engine/Attack.java b/core/src/ch/asynk/tankontank/engine/Attack.java index 6bdc9af..bc99b67 100644 --- a/core/src/ch/asynk/tankontank/engine/Attack.java +++ b/core/src/ch/asynk/tankontank/engine/Attack.java @@ -8,6 +8,11 @@ public class Attack public boolean isClear; public boolean isFlank; + public Attack(Pawn attacker) + { + this.attacker = attacker; + } + public String toString() { return String.format("attack : %s -> %s dist:%d clear:%b flank:%b", attacker, target, distance, isClear, isFlank); @@ -15,7 +20,6 @@ public class Attack public void reset() { - attacker = null; target = null; distance = 0;; isClear = false; diff --git a/core/src/ch/asynk/tankontank/engine/Pawn.java b/core/src/ch/asynk/tankontank/engine/Pawn.java index 00965b3..716b66b 100644 --- a/core/src/ch/asynk/tankontank/engine/Pawn.java +++ b/core/src/ch/asynk/tankontank/engine/Pawn.java @@ -73,8 +73,7 @@ public abstract class Pawn implements Moveable, Disposable this.prevTile = null; this.position = new Vector3(0f, 0f, 0f); this.prevPosition = new Vector3(0f, 0f, 0f); - this.attack = new Attack(); - this.attack.attacker = this; + this.attack = new Attack(this); } public Pawn(Faction faction, String name, TextureAtlas pawns, TextureAtlas overlays) -- cgit v1.1-2-g2b99