Пример #1
0
        public static void ShowTab(NetTabType type, GameObject tabProvider, ElementValue[] elementValues)
        {
            if (tabProvider == null)
            {
                return;
            }

            var openedTab = new NetTabDescriptor(tabProvider, type);

            //try to dig out a hidden tab with matching parameters and enable it:
            if (Instance.HiddenNetTabs.ContainsKey(openedTab))
            {
//				Debug.Log( $"Yay, found an old hidden {openedTab} tab. Unhiding it" );
                Instance.UnhideTab(Instance.HiddenNetTabs[openedTab]);
            }
            if (!Instance.OpenedNetTabs.ContainsKey(openedTab))
            {
                var        rightPanelParent = Instance.transform.GetChild(1);
                NetTab     tabInfo          = openedTab.Spawn(rightPanelParent);
                GameObject tabObject        = tabInfo.gameObject;

                //putting into the right place
                tabObject.transform.localScale = Vector3.one;
                var rect = tabObject.GetComponent <RectTransform>();
                rect.offsetMin = new Vector2(15, 15);
                rect.offsetMax = -new Vector2(15, 50);

                Instance.RefreshTabHeaders();
            }

            NetTab tab = Instance.OpenedNetTabs[openedTab];

            tab.ImportValues(elementValues);
            Instance.SelectTab(tab.gameObject, false);
        }
    /// remove player from NetworkTabInfo, keeping the tab
    public void Remove(NetTabDescriptor tabDescriptor, GameObject player)
    {
        NetTab t = openTabs[tabDescriptor];

        t.RemovePlayer(player);
//		if ( t.Peepers.Count == 0 ) {
//			t.gameObject.SetActive( false );
//		}
    }
    public NetTab Spawn(Transform parent)
    {
        if (provider == null)
        {
            return(null);
        }
        var    tabObject = Object.Instantiate(Resources.Load($"Tab{type}") as GameObject, parent);
        NetTab netTab    = tabObject.GetComponent <NetTab>();

        netTab.Provider = provider.gameObject;
        return(netTab);
    }
Пример #4
0
    /// remove player from NetworkTabInfo, keeping the tab
    public void Remove(NetTabDescriptor tabDescriptor, GameObject player)
    {
        if (!openTabs.ContainsKey(tabDescriptor))
        {
            return;
        }
        NetTab t = openTabs[tabDescriptor];

        t.RemovePlayer(player);
//		if ( t.Peepers.Count == 0 ) {
//			t.gameObject.SetActive( false );
//		}
    }
    ///Create new NetworkTabInfo if it doesn't exist, otherwise add player to it
    public void Add(NetTabDescriptor tabDescriptor, GameObject player)
    {
        if (tabDescriptor.Equals(NetTabDescriptor.Invalid))
        {
            return;
        }

        if (!openTabs.ContainsKey(tabDescriptor))
        {
            //Spawning new one
            openTabs.Add(tabDescriptor, tabDescriptor.Spawn(transform));
        }
        NetTab tab = openTabs[tabDescriptor];

//		tab.gameObject.SetActive( true );
        tab.AddPlayer(player);
    }
Пример #6
0
    public NetTab Spawn(Transform parent)
    {
        if (provider == null)
        {
            return(null);
        }

        GameObject toInstantiate = NetworkTabManager.Instance.NetTabs.GetFromName($"Tab{type}");

        if (toInstantiate == null)
        {
            Logger.LogWarning($"[NetworkTabManager.Spawn] - Couldn't load 'Tab{type}' from the netTab SO", Category.NetUI);
            return(null);
        }

        var    tabObject = Object.Instantiate(toInstantiate, parent);
        NetTab netTab    = tabObject.GetComponent <NetTab>();

        netTab.Provider             = provider.gameObject;
        netTab.ProviderRegisterTile = provider.RegisterTile();
        return(netTab);
    }
Пример #7
0
    public static void ShowTab(NetTabType type, GameObject tabProvider, ElementValue[] elementValues)
    {
        if (tabProvider == null)
        {
            return;
        }

        // Need to spawn a local instance of the NetTab to obtain its isPopOut property first. Parent is changed later.
        var    openedTab = new NetTabDescriptor(tabProvider, type);
        NetTab tabInfo   = openedTab.Spawn(tabProvider.transform);

        //Make use of NetTab's fancy isPopOut bool instead of depending on the NetTabType.
        bool isPopOut = tabInfo.isPopOut;


        if (!Instance.rolledOut && !isPopOut)
        {
            Instance.StartCoroutine(Instance.AnimTabRoll());
        }

        //try to dig out a hidden tab with matching parameters and enable it:
        if (Instance.HiddenNetTabs.ContainsKey(openedTab))
        {
            //				Logger.Log( $"Yay, found an old hidden {openedTab} tab. Unhiding it" );
            Instance.UnhideTab(Instance.HiddenNetTabs[openedTab]);
        }
        if (!Instance.OpenedNetTabs.ContainsKey(openedTab))
        {
            Transform newParent = !isPopOut ? Instance.TabStorage : Instance.TabStoragePopOut;
            tabInfo.transform.SetParent(newParent, false);
            GameObject tabObject = tabInfo.gameObject;

            //putting into the right place
            tabObject.transform.localScale = Vector3.one;
            var rect = tabObject.GetComponent <RectTransform>();

            if (!isPopOut)
            {
                rect.offsetMin = new Vector2(15, 15);
                rect.offsetMax = -new Vector2(15, 50);
            }
            else
            {
                //Center it:
                var localPos = Vector3.zero;
                localPos.y += 20f;
                rect.transform.localPosition = localPos;
                tabInfo.isPopOut             = true;
            }

            Instance.RefreshTabHeaders();
        }

        NetTab tab = Instance.OpenedNetTabs[openedTab];

        tab.ImportValues(elementValues);
        if (!isPopOut)
        {
            Instance.SelectTab(tab.gameObject, false);
        }
    }
Пример #8
0
    public static void ShowTab(NetTabType type, GameObject tabProvider, ElementValue[] elementValues)
    {
        if (tabProvider == null)
        {
            return;
        }

        bool isPopOut = false;

        //Add the popout types here:
        if ((type == NetTabType.Paper) || (type == NetTabType.ChemistryDispenser))
        {
            isPopOut = true;
        }

        if (!Instance.rolledOut && !isPopOut)
        {
            Instance.StartCoroutine(Instance.AnimTabRoll());
        }

        var openedTab = new NetTabDescriptor(tabProvider, type);

        //try to dig out a hidden tab with matching parameters and enable it:
        if (Instance.HiddenNetTabs.ContainsKey(openedTab))
        {
            //				Logger.Log( $"Yay, found an old hidden {openedTab} tab. Unhiding it" );
            Instance.UnhideTab(Instance.HiddenNetTabs[openedTab]);
        }
        if (!Instance.OpenedNetTabs.ContainsKey(openedTab))
        {
            Transform  newParent = !isPopOut ? Instance.TabStorage : Instance.TabStoragePopOut;
            NetTab     tabInfo   = openedTab.Spawn(newParent);
            GameObject tabObject = tabInfo.gameObject;

            //putting into the right place
            tabObject.transform.localScale = Vector3.one;
            var rect = tabObject.GetComponent <RectTransform>();

            if (!isPopOut)
            {
                rect.offsetMin = new Vector2(15, 15);
                rect.offsetMax = -new Vector2(15, 50);
            }
            else
            {
                //Center it:
                var localPos = Vector3.zero;
                localPos.y += 20f;
                rect.transform.localPosition = localPos;
                tabInfo.isPopOut             = true;
            }

            Instance.RefreshTabHeaders();
        }

        NetTab tab = Instance.OpenedNetTabs[openedTab];

        tab.ImportValues(elementValues);
        if (!isPopOut)
        {
            Instance.SelectTab(tab.gameObject, false);
        }
    }
Пример #9
0
 private void DestroyTab(NetTab tab)
 {
     HideTab(tab);
     Destroy(tab.gameObject);
 }