TargetEdited.cs
1.05 KB
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
58
59
60
61
62
63
64
65
66
using UnityEngine;
using System.Collections;
public class TargetEdited : MonoBehaviour
{
public GameObject objWorkingOn;
public TextMesh damage_text;
TextMesh text;
//Used to check if the target has been hit
public bool isHit = false;
public float target_hp;
public int shield;
public int damage;
int count = 30;
bool counting = false;
public int npc_no;
private void Awake()
{
Debug.Log(objWorkingOn.name);
}
private void Update()
{
//If the target is hit
if (isHit == true)
{
target_hp -= damage * (target_hp + shield);
damage_text.text = damage.ToString();
text = Instantiate(damage_text, objWorkingOn.transform.position, new Quaternion(0, 0, 0, 0));
counting = true;
isHit = false;
}
if (counting)
{
count -= 1;
if (count < 1)
{
count = 30;
counting = false;
Destroy(text);
}
}
if (target_hp < 1)
{
Destroy(objWorkingOn);
Destroy(text);
if (npc_no == 1)
{
GameObject.Find("MainFrame").GetComponent<ChangeScene>().ChangeGameMode();
}
}
}
}