Newer
Older
using UnityEngine;
using UnityEngine.UI; //andr
using static StreamingAssetLoader;
public class SelectNetwServer_mobile : MonoBehaviour
{
public GameObject LPS_B_GObj;
public GameObject Slot1_B_GObj;
public GameObject Slot2_B_GObj;
public GameObject Slot3_B_GObj;
Stefan Richter
committed
public GameObject Slot4_B_GObj;
public GameObject Slot5_B_GObj;
private Color32 firstColB;
private float transCol;
private ColorBlock tempColB;
void Start()
{
Update();
}
private void Update()
{
UpdateUI_1_f();
UpdateUI_3_f();
UpdateUI_4_f();
UpdateUI_5_f();
Stefan Richter
committed
UpdateUI_7_f();
UpdateUI_8_f();
}
public void SlotLPS()
{
//CommunicationEvents.ServerAdress = "http://" + CommunicationEvents.ServerAddress1;
CommunicationEvents.ServerRunningA[6] = CommunicationEvents.ServerRunningA[1];
CommunicationEvents.selecIP = CommunicationEvents.lastIP;
CommunicationEvents.IPcheckGeneration++;
NetworkJSON_Save();
//SceneManager.LoadScene("Andr_TreeWorld");
}
public void Slot1()
{
//CommunicationEvents.ServerAdress = "http://" + CommunicationEvents.ServerAddress1;
CommunicationEvents.ServerRunningA[6] = CommunicationEvents.ServerRunningA[3];
CommunicationEvents.selecIP = CommunicationEvents.IPslot1;
CommunicationEvents.IPcheckGeneration++;
NetworkJSON_Save();
//SceneManager.LoadScene("Andr_TreeWorld");
}
public void Slot2()
{
//CommunicationEvents.ServerAdress = "http://" + CommunicationEvents.ServerAddress2;
CommunicationEvents.ServerRunningA[6] = CommunicationEvents.ServerRunningA[4];
CommunicationEvents.selecIP = CommunicationEvents.IPslot2;
CommunicationEvents.IPcheckGeneration++;
NetworkJSON_Save();
//SceneManager.LoadScene("Andr_TreeWorld");
}
public void Slot3()
{
//CheckServer ani = new CheckServer();//= obj.AddComponent<CheckServer>();
// ani.StartCheck();
CommunicationEvents.ServerRunningA[6] = CommunicationEvents.ServerRunningA[5];
CommunicationEvents.selecIP = CommunicationEvents.IPslot3;
CommunicationEvents.IPcheckGeneration++;
NetworkJSON_Save();
Stefan Richter
committed
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
}
public void Slot4()
{
//CheckServer ani = new CheckServer();//= obj.AddComponent<CheckServer>();
// ani.StartCheck();
CommunicationEvents.ServerRunningA[6] = CommunicationEvents.ServerRunningA[7];
CommunicationEvents.selecIP = CommunicationEvents.IPslot4;
CommunicationEvents.IPcheckGeneration++;
NetworkJSON_Save();
}
public void Slot5()
{
//CheckServer ani = new CheckServer();//= obj.AddComponent<CheckServer>();
// ani.StartCheck();
CommunicationEvents.ServerRunningA[6] = CommunicationEvents.ServerRunningA[8];
CommunicationEvents.selecIP = CommunicationEvents.IPslot5;
CommunicationEvents.IPcheckGeneration++;
NetworkJSON_Save();
}
void UpdateUI_1_f()
{
tempColB = LPS_B_GObj.GetComponent<Button>().colors;
tempColB.pressedColor = colPressed;
tempColB.selectedColor = colSelect;
if (CommunicationEvents.ServerRunningA[1] == 0)
{
tempColB.normalColor = colOffline;
LPS_B_GObj.GetComponent<Button>().colors = tempColB; // new Color(148, 229, 156);
if (string.IsNullOrEmpty(CommunicationEvents.lastIP))// || CommunicationEvents.lastIP.Length < 4)
{
LPS_B_GObj.GetComponentInChildren<Text>().text = "No game played before";
}
else
{
Stefan Richter
committed
LPS_B_GObj.GetComponentInChildren<Text>().text = "Last played on (offline) \n" + CommunicationEvents.lastIP;
}
}
else
{
if (CommunicationEvents.ServerRunningA[1] == 2)
{
tempColB.normalColor = colOnline;
Stefan Richter
committed
LPS_B_GObj.GetComponentInChildren<Text>().text = "Last played on (online) \n" + CommunicationEvents.lastIP;
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
}
else
{
tempColB.normalColor = colOffline;
LPS_B_GObj.GetComponentInChildren<Text>().text = "No game played before";
}
}
LPS_B_GObj.GetComponent<Button>().colors = tempColB;
}
void UpdateUI_3_f()
{
//------------------------------------------------------------------------
tempColB = Slot1_B_GObj.GetComponent<Button>().colors;
tempColB.pressedColor = colPressed;
tempColB.selectedColor = colSelect;
if (CommunicationEvents.ServerRunningA[3] == 0)
{
tempColB.normalColor = colOffline;
if (string.IsNullOrEmpty(CommunicationEvents.IPslot1))// || CommunicationEvents.IPslot1.Length < 1)
{
Slot1_B_GObj.GetComponentInChildren<Text>().text = "< empty >";
//GameObject.Find("IPSlot1_b").GetComponentInChildren<Text>().text = "OVERWRITE: \n< empty >";
}
else
{
Stefan Richter
committed
Slot1_B_GObj.GetComponentInChildren<Text>().text = "Server 1 (Offline) \n" + CommunicationEvents.IPslot1;
//GameObject.Find("IPSlot1_b").GetComponentInChildren<Text>().text = "OVERWRITE: \nServer " + CommunicationEvents.IPslot1 + " (Offline)";
}
}
else
{
if (CommunicationEvents.ServerRunningA[3] == 2)
{
tempColB.normalColor = colOnline;
Stefan Richter
committed
Slot1_B_GObj.GetComponentInChildren<Text>().text = "Server 1 (Online) \n" + CommunicationEvents.IPslot1;
//GameObject.Find("IPSlot1_b").GetComponentInChildren<Text>().text = "OVERWRITE: \nServer " + CommunicationEvents.IPslot1 + " (Online)";
}
else
{
tempColB.normalColor = colOffline;
Stefan Richter
committed
Slot1_B_GObj.GetComponentInChildren<Text>().text = "Server 1 \n" + CommunicationEvents.IPslot1;
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
//GameObject.Find("IPSlot1_b").GetComponentInChildren<Text>().text = "OVERWRITE: \n< empty >";
}
}
Slot1_B_GObj.GetComponent<Button>().colors = tempColB;
}
void UpdateUI_4_f()
{
//-------------------------------------------------------------------------
tempColB = Slot2_B_GObj.GetComponent<Button>().colors;
tempColB.pressedColor = colPressed;
tempColB.selectedColor = colSelect;
if (CommunicationEvents.ServerRunningA[4] == 0)
{
tempColB.normalColor = colOffline;
if (string.IsNullOrEmpty(CommunicationEvents.IPslot2))// || CommunicationEvents.IPslot2.Length<1)
{
Slot2_B_GObj.GetComponentInChildren<Text>().text = "< empty >";
//GameObject.Find("IPSlot2_b").GetComponentInChildren<Text>().text = "OVERWRITE: \n< empty >";
}
else
{
Stefan Richter
committed
Slot2_B_GObj.GetComponentInChildren<Text>().text = "Server 2 (Offline) \n" + CommunicationEvents.IPslot2;
//GameObject.Find("IPSlot2_b").GetComponentInChildren<Text>().text = "OVERWRITE: \nServer " + CommunicationEvents.IPslot2 + " (Offline)";
}
}
else
{
if (CommunicationEvents.ServerRunningA[4] == 2)
{
tempColB.normalColor = colOnline;
Stefan Richter
committed
Slot2_B_GObj.GetComponentInChildren<Text>().text = "Server 2 (Online) \n" + CommunicationEvents.IPslot2;
//GameObject.Find("IPSlot2_b").GetComponentInChildren<Text>().text = "OVERWRITE: \nServer " + CommunicationEvents.IPslot2 + " (Online)";
}
else
{
tempColB.normalColor = colOffline;
Stefan Richter
committed
Slot2_B_GObj.GetComponentInChildren<Text>().text = "Server 2 \n" + CommunicationEvents.IPslot2;
//GameObject.Find("IPSlot2_b").GetComponentInChildren<Text>().text = "OVERWRITE: \n< empty >";
}
}
Slot2_B_GObj.GetComponent<Button>().colors = tempColB;
}
void UpdateUI_5_f()
{
//---------------------------------------------------------------------------
tempColB = Slot3_B_GObj.GetComponent<Button>().colors;
tempColB.pressedColor = colPressed;
tempColB.selectedColor = colSelect;
if (CommunicationEvents.ServerRunningA[5] == 0)
{
tempColB.normalColor = colOffline;
if (string.IsNullOrEmpty(CommunicationEvents.IPslot3))// || CommunicationEvents.IPslot3.Length < 1)
{
Slot3_B_GObj.GetComponentInChildren<Text>().text = "< empty >";
//GameObject.Find("IPSlot3_b").GetComponentInChildren<Text>().text = "OVERWRITE: \n< empty >";
}
else
{
Stefan Richter
committed
//Slot3_B_GObj.GetComponentInChildren<Text>().text = "Server " + CommunicationEvents.IPslot3 + " (Offline)";
Slot3_B_GObj.GetComponentInChildren<Text>().text = "Server 3 (Offline) \n" + CommunicationEvents.IPslot3;
//GameObject.Find("IPSlot3_b").GetComponentInChildren<Text>().text = "OVERWRITE: \nServer " + CommunicationEvents.IPslot3 + " (Offline)";
}
}
else
{
if (CommunicationEvents.ServerRunningA[5] == 2)
{
tempColB.normalColor = colOnline;
Stefan Richter
committed
Slot3_B_GObj.GetComponentInChildren<Text>().text = "Server 3 (Online) \n" + CommunicationEvents.IPslot3;
//GameObject.Find("IPSlot3_b").GetComponentInChildren<Text>().text = "OVERWRITE: \nServer " + CommunicationEvents.IPslot3 + " (Online)";
}
else
{
tempColB.normalColor = colOffline;
Stefan Richter
committed
Slot3_B_GObj.GetComponentInChildren<Text>().text = "Server 3 \n" + CommunicationEvents.IPslot3;
//GameObject.Find("IPSlot3_b").GetComponentInChildren<Text>().text = "OVERWRITE: \n< empty >";
}
}
Slot3_B_GObj.GetComponent<Button>().colors = tempColB;
}
Stefan Richter
committed
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
void UpdateUI_7_f()
{
//---------------------------------------------------------------------------
tempColB = Slot4_B_GObj.GetComponent<Button>().colors;
tempColB.pressedColor = colPressed;
tempColB.selectedColor = colSelect;
if (CommunicationEvents.ServerRunningA[7] == 0)
{
tempColB.normalColor = colOffline;
if (string.IsNullOrEmpty(CommunicationEvents.IPslot4))// || CommunicationEvents.IPslot3.Length < 1)
{
Slot4_B_GObj.GetComponentInChildren<Text>().text = "< empty >";
//GameObject.Find("IPSlot3_b").GetComponentInChildren<Text>().text = "OVERWRITE: \n< empty >";
}
else
{
Slot4_B_GObj.GetComponentInChildren<Text>().text = "Server 4 (Offline) \n" + CommunicationEvents.IPslot4;
//GameObject.Find("IPSlot3_b").GetComponentInChildren<Text>().text = "OVERWRITE: \nServer " + CommunicationEvents.IPslot3 + " (Offline)";
}
}
else
{
if (CommunicationEvents.ServerRunningA[7] == 2)
{
tempColB.normalColor = colOnline;
Slot4_B_GObj.GetComponentInChildren<Text>().text = "Server 4 (Online) \n" + CommunicationEvents.IPslot4;
//GameObject.Find("IPSlot3_b").GetComponentInChildren<Text>().text = "OVERWRITE: \nServer " + CommunicationEvents.IPslot3 + " (Online)";
}
else
{
tempColB.normalColor = colOffline;
Slot4_B_GObj.GetComponentInChildren<Text>().text = "Server 4 \n" + CommunicationEvents.IPslot4;
//GameObject.Find("IPSlot3_b").GetComponentInChildren<Text>().text = "OVERWRITE: \n< empty >";
}
}
Slot4_B_GObj.GetComponent<Button>().colors = tempColB;
}
void UpdateUI_8_f()
{
//---------------------------------------------------------------------------
tempColB = Slot5_B_GObj.GetComponent<Button>().colors;
tempColB.pressedColor = colPressed;
tempColB.selectedColor = colSelect;
if (CommunicationEvents.ServerRunningA[8] == 0)
{
tempColB.normalColor = colOffline;
if (string.IsNullOrEmpty(CommunicationEvents.IPslot5))// || CommunicationEvents.IPslot3.Length < 1)
{
Slot5_B_GObj.GetComponentInChildren<Text>().text = "< empty >";
//GameObject.Find("IPSlot3_b").GetComponentInChildren<Text>().text = "OVERWRITE: \n< empty >";
}
else
{
Slot5_B_GObj.GetComponentInChildren<Text>().text = "Server 5 (Offline) \n" + CommunicationEvents.IPslot5;
//GameObject.Find("IPSlot3_b").GetComponentInChildren<Text>().text = "OVERWRITE: \nServer " + CommunicationEvents.IPslot3 + " (Offline)";
}
}
else
{
if (CommunicationEvents.ServerRunningA[8] == 2)
{
tempColB.normalColor = colOnline;
Slot5_B_GObj.GetComponentInChildren<Text>().text = "Server 5 (Online) \n" + CommunicationEvents.IPslot5;
//GameObject.Find("IPSlot3_b").GetComponentInChildren<Text>().text = "OVERWRITE: \nServer " + CommunicationEvents.IPslot3 + " (Online)";
}
else
{
tempColB.normalColor = colOffline;
Slot5_B_GObj.GetComponentInChildren<Text>().text = "Server 5 \n" + CommunicationEvents.IPslot5;
//GameObject.Find("IPSlot3_b").GetComponentInChildren<Text>().text = "OVERWRITE: \n< empty >";
}
}
Slot5_B_GObj.GetComponent<Button>().colors = tempColB;
}