Newer
Older
using UnityEngine;
using UnityEngine.UI; //andr
using static StreamingAssetLoader;
using static CommunicationEvents;
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();
}
/// <summary>
/// All of this could be way more generic now using <see cref="CommunicationEvents.ServerSlots"/> and friends.
/// </summary>
private void Update()
{
UpdateUI_1_f();
UpdateUI_3_f();
UpdateUI_4_f();
UpdateUI_5_f();
Stefan Richter
committed
UpdateUI_7_f();
UpdateUI_8_f();
}
/// <summary>
/// There once was a version for every slot here. Since they were all unused I collapsed them
/// into this generic form. Sould you need this, consider turning
/// <see cref="ServerSlot.selecIP"/> into a <see cref="ServerSlot"/> variable instead.
/// </summary>
public void Slot(ServerSlotComponent slot)
ServerSlots[ServerSlot.selecIP] = ServerSlots[slot.serverSlot];
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
{
LPS_B_GObj.GetComponentInChildren<Text>().text = "Last played on (offline) \n" + CommunicationEvents.LastIP;
}
}
else
{
if (CommunicationEvents.ServerRunningA[1] == 2)
{
tempColB.normalColor = colOnline;
LPS_B_GObj.GetComponentInChildren<Text>().text = "Last played on (online) \n" + CommunicationEvents.LastIP;
}
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;
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
//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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
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;
}