-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparty_ui_stats.cs
More file actions
215 lines (175 loc) · 7.02 KB
/
party_ui_stats.cs
File metadata and controls
215 lines (175 loc) · 7.02 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class party_ui_stats : MonoBehaviour {
public GameObject gameManager;
public GameObject[] UIparty;
public GameObject[] UIobjects;
public Text[] ui;
Enemy_List elist;
Player_Stats player;
Player_party party;
public Pets_stats[] pet;
public Monster_stats[] mstats;
private bool waitDelay = true;
private bool uistats = false;
/*UIparty 0-4 Name, healthMax, healthCurrent, magicCurrent, magicMax */
// Use this for initialization
void Start () {
gameManager = GameObject.FindGameObjectWithTag("GameManager");
for (int i = 0; i < 28; i++)
{
ui[i] = UIparty[i].GetComponent<Text>();
}
player = gameManager.GetComponent<Player_Stats>();
party = gameManager.GetComponent<Player_party>();
elist = GetComponent<Enemy_List>();
StartCoroutine(TimeDelay(0.5f));
}
// Update is called once per frame
void Update()
{
if (waitDelay == false)
{
if (party.party_clones[0].GetComponent<Pets_stats>() != null)
{
if (pet[0] == null)
pet[0] = party.party_clones[0].GetComponent<Pets_stats>();
}
if (party.party_clones[1].GetComponent<Pets_stats>() != null)
{
if (pet[0] == null)
pet[0] = party.party_clones[1].GetComponent<Pets_stats>();
else
pet[1] = party.party_clones[1].GetComponent<Pets_stats>();
}
if (party.party_clones[2].GetComponent<Pets_stats>() != null)
{
if (pet[1] == null)
pet[1] = party.party_clones[2].GetComponent<Pets_stats>();
else
pet[2] = party.party_clones[2].GetComponent<Pets_stats>();
}
if (party.party_clones[3].GetComponent<Pets_stats>() != null)
{
if (pet[2] == null)
pet[2] = party.party_clones[3].GetComponent<Pets_stats>();
}
if(elist.clones[0] != null)
mstats[0] = elist.clones[0].GetComponent<Monster_stats>();
if(elist.clones[1] != null)
mstats[1] = elist.clones[1].GetComponent<Monster_stats>();
if(elist.clones[2] != null)
mstats[2] = elist.clones[2].GetComponent<Monster_stats>();
if(elist.clones[3] != null)
mstats[3] = elist.clones[3].GetComponent<Monster_stats>();
uistats = true;
waitDelay = true;
}
///////////////////////////////////////*UI*/////////////////////////////////////////////////
/////////////////////////////////////*UPDATES*//////////////////////////////////////////////
/////////////////////////////////////*PLAYER*///////////////////////////////////////////////
if (party.player_party[0] != null)//If the player is alive
{
ui[0].text = player.playername;
ui[1].text = player.healthMax.ToString();
ui[2].text = player.health.ToString();
ui[3].text = player.mana.ToString();
ui[4].text = player.manaMax.ToString();
}
else if (party.player_party[0] == null)//If player doesn't exist
{
Destroy(UIobjects[0]);
}
if (party.player_party[1] != null && uistats == true)//If first slot is filled
{
ui[5].text = pet[0].petname;
ui[6].text = pet[0].healthMax.ToString();
ui[7].text = pet[0].health.ToString();
ui[8].text = pet[0].mana.ToString();
ui[9].text = pet[0].manaMax.ToString();
}
else if (party.player_party[1] == null)//If first slot doesn't exist
{
Destroy(UIobjects[1]);
}
if (party.player_party[2] != null && uistats == true)//If second slot is filled
{
ui[10].text = pet[1].petname;
ui[11].text = pet[1].healthMax.ToString();
ui[12].text = pet[1].health.ToString();
ui[13].text = pet[1].mana.ToString();
ui[14].text = pet[1].manaMax.ToString();
}
else if (party.player_party[2] == null)//If second slot doesn't exist
{
Destroy(UIobjects[2]);
}
if (party.player_party[3] != null && uistats == true)//If third slot is filled
{
ui[15].text = pet[2].petname;
ui[16].text = pet[2].healthMax.ToString();
ui[17].text = pet[2].health.ToString();
ui[18].text = pet[2].mana.ToString();
ui[19].text = pet[2].manaMax.ToString();
}
else if (party.player_party[3] == null)//If third slot is filled
{
Destroy(UIobjects[3]);
}
///////////////////////////////////////*UI*/////////////////////////////////////////////////
/////////////////////////////////////*UPDATES*//////////////////////////////////////////////
//////////////////////////////////////*ENEMY*///////////////////////////////////////////////
if (elist.clones[0] != null && uistats == true)//If the enemy is alive
{
if (elist.clones[0].tag == "boss")
{
UIparty[28].GetComponent<RectTransform>().anchoredPosition3D = new Vector3(275.0f, -45.0f, 0.0f);
UIobjects[4].GetComponent<RectTransform>().anchoredPosition3D = new Vector3(-23.4f, -401.8f, 0.0f);
}
ui[20].text = mstats[0].health.ToString();
ui[21].text = mstats[0].healthMax.ToString();
}
else if (elist.clones[0] == null)//If enemy doesn't exist
{
Destroy(UIobjects[4]);
Destroy(UIparty[28]);
}
if (elist.clones[3] != null && uistats == true)//If the enemy is alive
{
ui[22].text = mstats[3].health.ToString();
ui[23].text = mstats[3].healthMax.ToString();
}
else if (elist.clones[3] == null)//If enemy doesn't exist
{
Destroy(UIobjects[5]);
Destroy(UIparty[30]);
}
if (elist.clones[2] != null && uistats == true)//If the enemy is alive
{
ui[24].text = mstats[2].health.ToString();
ui[25].text = mstats[2].healthMax.ToString();
}
else if (elist.clones[2] == null)//If enemy doesn't exist
{
Destroy(UIobjects[6]);
Destroy(UIparty[29]);
}
if (elist.clones[1] != null && uistats == true)//If the enemy is alive
{
ui[26].text = mstats[1].health.ToString();
ui[27].text = mstats[1].healthMax.ToString();
}
else if (elist.clones[1] == null)//If enemy doesn't exist
{
Destroy(UIobjects[7]);
Destroy(UIparty[31]);
}
}
IEnumerator TimeDelay(float timedelay)
{
waitDelay = true;
yield return new WaitForSeconds(timedelay);
waitDelay = false;
}
}