-
Notifications
You must be signed in to change notification settings - Fork 0
/
EnemyHealth.cs
57 lines (38 loc) · 1.14 KB
/
EnemyHealth.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyHealth : HealthSystem {
private Projectile projectileCollision;
// Use this for initialization
void Start () {
//*** call initial start
base.Start ();
}
void OnCollisionEnter(Collision collision)
{
foreach (ContactPoint contact in collision.contacts)
{
Debug.DrawRay(contact.point, contact.normal, Color.white);
}
//*** 10 corresponds to the bullet Layer , may need to set a global property
if (collision.gameObject.layer == 10) {
Debug.Log ("Dinosaur was hit !!!!!!");
projectileCollision = collision.gameObject.GetComponent ("Projectile") as Projectile;
//*** Retriece and store damage number
int damage = projectileCollision.ProjectileDamage;
Debug.Log ("Projectile Hit enemy for " + damage + " damage!");
currentHealth = currentHealth - damage;
//*** Check if dead and handle it
if (currentHealth == 0) {
Death ();
} else {
}
}
}
public void Death(){
//*** Mark enemy dead
GameplayManager.instance.EnemyDestroyed();
//*** Kill dionasur character
Destroy (this.gameObject);
}
}