summaryrefslogtreecommitdiff
path: root/Assets/Scripts/Enemy3/Enemy3HealthScript.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/Scripts/Enemy3/Enemy3HealthScript.cs')
-rwxr-xr-xAssets/Scripts/Enemy3/Enemy3HealthScript.cs34
1 files changed, 34 insertions, 0 deletions
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<AudioSource>().Play();
+ Destroy(animation, 1f);
+ Destroy(transform.parent.gameObject);
+ }
+
+ }
+}