Skip to content
Snippets Groups Projects
SelectNetwServer_mobile.cs 11.9 KiB
Newer Older
  • Learn to ignore specific revisions
  • using UnityEngine;
    using UnityEngine.UI; //andr
    using static StreamingAssetLoader;
    
    MaZiFAU's avatar
    MaZiFAU committed
    using static UIconfig;
    
    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;
    
        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>
    
    MaZiFAU's avatar
    MaZiFAU committed
    
            UpdateUI_1_f();
            UpdateUI_3_f();
            UpdateUI_4_f();
    
            UpdateUI_5_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
                {
    
    
                    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;
    
                    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;
    
                    Slot1_B_GObj.GetComponentInChildren<Text>().text = "Server 1 \n" + CommunicationEvents.IPslot1;
    
                    //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
                {
    
                    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;
    
                    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;
    
                    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
                {
    
                    //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;
    
                    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;
    
                    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;
        }
    
    
        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;
        }
    
    MaZiFAU's avatar
    MaZiFAU committed