From 115f77bda0246a00f6e17469685c67746bdbd29d Mon Sep 17 00:00:00 2001 From: nirav Date: Sat, 12 Dec 2020 07:18:36 +0000 Subject: Initial commit --- Assets/Scripts/Enemy3/Enemy3HealthScript.cs | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 Assets/Scripts/Enemy3/Enemy3HealthScript.cs (limited to 'Assets/Scripts/Enemy3/Enemy3HealthScript.cs') diff --git a/Assets/Scripts/Enemy3/Enemy3HealthScript.cs b/Assets/Scripts/Enemy3/Enemy3HealthScript.cs new file mode 100755 index 0000000..b2d8308 --- /dev/null +++ b/Assets/Scripts/Enemy3/Enemy3HealthScript.cs @@ -0,0 +1,34 @@ +using UnityEngine; +using System.Collections; + +public class Enemy3HealthScript : MonoBehaviour { + + public int Health = 100; + + public GameObject DestroyAnimation; + GameObject DestroyAudio; + + void Start() + { + DestroyAudio = GameObject.FindGameObjectWithTag("EnemyDestroyAudio"); + } + + + void Update() + { + + } + + public void TakeDamage(int damage) + { + Health -= damage; + if (Health <= 0) + { + var animation = Instantiate(DestroyAnimation, transform.position, Quaternion.identity); + DestroyAudio.GetComponent().Play(); + Destroy(animation, 1f); + Destroy(transform.parent.gameObject); + } + + } +} -- cgit v1.2.3