forked from GCSShatteredSpace/Week-2-Code-Reading
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdamageGlobe.cs
39 lines (29 loc) · 861 Bytes
/
damageGlobe.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
using UnityEngine;
using System.Collections;
public class damageGlobe : MonoBehaviour {
public weaponProperties stats;
public Renderer rend;
public GameObject origin;
public GameObject action;
public actionController actrl;
public float t;
void Start () {
action = GameObject.Find("actionController");
actrl = action.GetComponent<actionController> ();
stats = this.GetComponent<weaponProperties> ();
rend = GetComponent<Renderer> ();
if (stats.damage <0) {
rend.material.color = Color.green;
} else {
rend.material.color = Color.red;
}
t = actrl.time;
}
void Update () {
if (this.gameObject.tag=="damage"&&(actrl.time >= t + stats.lifeTime||actrl.time==-1)) { //if this is a gernerated instance as a damage globe, blow up after lifetime
if(origin.tag == "player"){
}
Destroy(this.gameObject);
}
}
}