diff --git a/Assets/Scripts/ArrowDespawner.cs b/Assets/Scripts/ArrowDespawner.cs index 7d492c04478715f91528fc5386539d5036721110..654512f98508433e1376fd5f50999396ea843162 100644 --- a/Assets/Scripts/ArrowDespawner.cs +++ b/Assets/Scripts/ArrowDespawner.cs @@ -1,9 +1,13 @@ -using System.Collections; -using System.Collections.Generic; using UnityEngine; +// Removes all active Arrows from the play field at round end. public class ArrowDespawner : MonoBehaviour, IRoundCallback { + void Start() + { + RoundController.instance.roundCallbacks.Add(this); + } + public void OnRoundEnd(bool won) { ArrowController[] arrows = FindObjectsOfType<ArrowController>(); @@ -15,18 +19,7 @@ public class ArrowDespawner : MonoBehaviour, IRoundCallback public void OnRoundStart() { - - } - - // Start is called before the first frame update - void Start() - { - RoundController.instance.roundCallbacks.Add(this); + // nop } - // Update is called once per frame - void Update() - { - - } } diff --git a/Assets/Scripts/Fighters/Archer.cs b/Assets/Scripts/Fighters/Archer.cs index 665f9198ffcab3e51b07c1ad242d60db1a260ee3..33801f1e9462431e5fd451075e354c5ce6f8272c 100644 --- a/Assets/Scripts/Fighters/Archer.cs +++ b/Assets/Scripts/Fighters/Archer.cs @@ -1,6 +1,9 @@ public class Archer : Enemy { - // Archers don't have any special abilities + public int GetArrowAttackDamage() + { + return GetAttackDamage(); + } } diff --git a/Assets/Scripts/Fighters/ArrowController.cs b/Assets/Scripts/Fighters/ArrowController.cs index 51cabf75ea19b3c3df4cf37c6bdb26426f74407e..a876a64a0d3808c396a1628c1d709b611037eb46 100644 --- a/Assets/Scripts/Fighters/ArrowController.cs +++ b/Assets/Scripts/Fighters/ArrowController.cs @@ -1,13 +1,15 @@ -using System.Collections; -using System.Collections.Generic; using UnityEngine; +// Controls an Arrow shot by an Archer. Moves it across the play field until it hits the AntiPlayer. public class ArrowController : MonoBehaviour { [SerializeField] float speed; [SerializeField] Opponent opponent; + public int direction; + public Archer archer; + Rigidbody2D rb; void Awake() @@ -15,7 +17,6 @@ public class ArrowController : MonoBehaviour rb = GetComponentInChildren<Rigidbody2D>(); } - // Update is called once per frame void Update() { rb.velocity = transform.up * -1 * speed; @@ -25,7 +26,7 @@ public class ArrowController : MonoBehaviour { if (other.CompareTag("AntiPlayer")) { - other.GetComponent<Fighter>().DealDamage(Mathf.RoundToInt(10 * StatsManager.instance.fighterStats[FighterTypes.ENEMY].damageMultiplier)); + other.GetComponent<Fighter>().DealDamage(archer.GetArrowAttackDamage()); Destroy(gameObject); } } diff --git a/Assets/Scripts/Fighters/ArrowSpawner.cs b/Assets/Scripts/Fighters/ArrowSpawner.cs index 4cf29d3749eb564c06409b74f88c1e6da10e27be..77bfad6f4a774a34dd026bbadc22908c6607c7d3 100644 --- a/Assets/Scripts/Fighters/ArrowSpawner.cs +++ b/Assets/Scripts/Fighters/ArrowSpawner.cs @@ -1,9 +1,10 @@ -using System.Collections; -using System.Collections.Generic; using UnityEngine; +// Used by the Animator for the Archer animation in the Shoot state. Fires an +// Arrow once the accoring state is entered/animation is played. public class ArrowSpawner : StateMachineBehaviour { + [SerializeField] GameObject arrowPrefab; GameObject arrow; @@ -18,17 +19,18 @@ public class ArrowSpawner : StateMachineBehaviour } Vector2 spawnPos = animator.gameObject.transform.position; spawnPos += new Vector2(1 * directionArrow, 0); - - arrow = Instantiate(arrowPrefab,spawnPos,Quaternion.identity); - ChangeArrowDirection(arrow,directionArrow); + + arrow = Instantiate(arrowPrefab, spawnPos, Quaternion.identity); + ChangeArrowDirection(arrow, directionArrow); ArrowController arrowController = arrow.GetComponentInChildren<ArrowController>(); arrowController.direction = directionArrow; + arrowController.archer = animator.gameObject.GetComponent<Archer>(); } } void ChangeArrowDirection(GameObject arrow, int directionArrow) { arrow.transform.Rotate(0, 0, 90 * directionArrow); - + } } diff --git a/Assets/Scripts/Fighters/Fighter.cs b/Assets/Scripts/Fighters/Fighter.cs index bdff0944c149c2ed9d7fb5350f0d36f55fa410f3..197eba69f42ba9e21021d794b4bdf1072e223dbe 100644 --- a/Assets/Scripts/Fighters/Fighter.cs +++ b/Assets/Scripts/Fighters/Fighter.cs @@ -153,11 +153,15 @@ public abstract class Fighter : MonoBehaviour, IRoundCallback // If we hit an opponent, deal them damage if (roundRunning && other.CompareTag(opponentTag)) { - var damageToDeal = Mathf.RoundToInt(baseAttackDamage * GetStats().damageMultiplier); - other.GetComponent<Fighter>().DealDamage(damageToDeal); + other.GetComponent<Fighter>().DealDamage(GetAttackDamage()); } } + protected int GetAttackDamage() + { + return Mathf.RoundToInt(baseAttackDamage * GetStats().damageMultiplier); + } + public virtual void OnRoundStart() { roundRunning = true;