From 12f21516ffd7caacfec259d6771677769384ffe8 Mon Sep 17 00:00:00 2001 From: Mikkel Bybjerg Date: Sat, 27 Apr 2019 11:14:45 +0200 Subject: enemy collision and health --- nGJ2019/Assets/Scripts/DragonMovement.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'nGJ2019/Assets/Scripts/DragonMovement.cs') diff --git a/nGJ2019/Assets/Scripts/DragonMovement.cs b/nGJ2019/Assets/Scripts/DragonMovement.cs index 04f1c3a..4ba179d 100644 --- a/nGJ2019/Assets/Scripts/DragonMovement.cs +++ b/nGJ2019/Assets/Scripts/DragonMovement.cs @@ -12,6 +12,8 @@ public class DragonMovement : MonoBehaviour public float horizontalBound = 6f; public float verticalBound = 4f; + public HealthBar healthBar; + private SwarmSystem swarm; private enum State {normal, swirl, slim, spread}; @@ -198,4 +200,14 @@ public class DragonMovement : MonoBehaviour Gizmos.DrawWireCube(Vector3.zero, new Vector3(2*horizontalBound, 2*verticalBound, 0)); } + void OnTriggerEnter(Collider other) + { + EnemyCollider enemy = other.gameObject.GetComponent(); + if(enemy != null) + { + Debug.Log(enemy.type == ObstacleType.alfa ? "alfa hit" : "beta hit"); + healthBar.health--; + } + } + } \ No newline at end of file -- cgit v1.2.3