Exemplo n.º 1
0
        public bool ShowGamePanel(MG_GamePanelType _PanelType)
        {
            int panelIndex = (int)_PanelType;

            MG_SaveManager.Current_GamePanel = panelIndex;
            if (LoadedPanel_Dic.TryGetValue(panelIndex, out MG_UIBase loadedGamePanel))
            {
                if (loadedGamePanel is null)
                {
                    Debug.LogWarning("Show MG_GamePanel-" + _PanelType + " Error : loadedDic has key , but content is null.");
                    return(false);
                }
                if (Current_GamePanel == loadedGamePanel)
                {
                    //Debug.LogWarning("Show MG_GamePanel-" + _PanelType + " Error : panel has show.");
                    return(false);
                }
                if (Current_GamePanel is object)
                {
                    StartCoroutine(Current_GamePanel.OnExit());
                }
                StartCoroutine(loadedGamePanel.OnEnter());
                Current_GamePanel = loadedGamePanel;
            }
            else
            {
                if (Type_Path_Dic.TryGetValue(panelIndex, out string panelPath))
                {
                    if (string.IsNullOrEmpty(panelPath))
                    {
                        Debug.LogWarning("Show MG_GamePanel-" + _PanelType + " Error : panelPathDic content is null or empty.");
                        return(false);
                    }
                    MG_UIBase nextShowPanel = Instantiate(Resources.Load <GameObject>(panelPath), GamePanelRoot).GetComponent <MG_UIBase>();
                    if (Current_GamePanel is object)
                    {
                        StartCoroutine(Current_GamePanel.OnExit());
                    }
                    nextShowPanel.transform.SetAsLastSibling();
                    StartCoroutine(nextShowPanel.OnEnter());
                    LoadedPanel_Dic.Add(panelIndex, nextShowPanel);
                    Current_GamePanel = nextShowPanel;
                }
                else
                {
                    Debug.LogWarning("Show MG_GamePanel-" + _PanelType + " Error : panelPathDic content is null or empty.");
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 2
0
        IEnumerator ExcuteTask()
        {
            MG_Manager.Instance.canBackGame = false;
            while (Queue_PopPanel.Count > 0)
            {
                PanelTask nextTask   = Queue_PopPanel.Dequeue();
                int       panelIndex = (int)nextTask.t_panelType;
                bool      open       = nextTask.t_open;
                if (LoadedPanel_Dic.TryGetValue(panelIndex, out MG_UIBase loadedPopPanel))
                {
                    if (loadedPopPanel is null)
                    {
                        Debug.LogWarning((open ? "Show" : "Close") + " MG_PopPanel-" + nextTask.t_panelType + " Error : loadedDic has key , but content is null.");
                        continue;
                    }
                    else
                    {
                        if (Panel_Stack.Contains(loadedPopPanel))
                        {
                            if (open)
                            {
                                Debug.LogWarning("Show MG_PopPanel-" + nextTask.t_panelType + " Error : panel has showed.");
                                continue;
                            }
                            else
                            {
                                while (true)
                                {
                                    if (Panel_Stack.Count > 0)
                                    {
                                        MG_UIBase outPanel = Panel_Stack.Pop();
                                        yield return(outPanel.OnExit());

                                        if (MG_Manager.Instance.next_GuidType != MG_Guid_Type.Null)
                                        {
                                            MG_Manager.Instance.isGuid = true;
                                        }
                                        if (Panel_Stack.Count > 0)
                                        {
                                            Panel_Stack.Peek().OnResume();
                                        }
                                        else if (MenuPanel is object && nextTask.t_panelType != MG_PopPanelType.ShopPanel)
                                        {
                                            MenuPanel.OnResume();
                                        }
                                        if (outPanel == loadedPopPanel)
                                        {
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (open)
                            {
                                while (true)
                                {
                                    if (MG_Manager.Instance.isGuid == false)
                                    {
                                        break;
                                    }
                                    yield return(null);
                                }
                                if (Panel_Stack.Count > 0)
                                {
                                    Panel_Stack.Peek().OnPause();
                                }
                                else if (MenuPanel is object && nextTask.t_panelType != MG_PopPanelType.ShopPanel)
                                {
                                    MenuPanel.OnPause();
                                }
                                loadedPopPanel.transform.SetAsLastSibling();
                                Panel_Stack.Push(loadedPopPanel);
                                yield return(loadedPopPanel.OnEnter());
                            }
                            else
                            {
                                Debug.LogWarning("Close MG_PopPanel-" + nextTask.t_panelType + " Error : panel has not show.");
                                continue;
                            }
                        }
                    }
                }
                else
                {
                    if (open)
                    {
                        if (Type_Path_Dic.TryGetValue(panelIndex, out string panelPath))
                        {
                            if (string.IsNullOrEmpty(panelPath))
                            {
                                Debug.LogWarning("Show MG_PopPanel-" + nextTask.t_panelType + " Error : panelPathDic content is null or empty.");
                                continue;
                            }
                            else
                            {
                                while (true)
                                {
                                    if (MG_Manager.Instance.isGuid == false)
                                    {
                                        break;
                                    }
                                    yield return(null);
                                }
                                if (Panel_Stack.Count > 0)
                                {
                                    Panel_Stack.Peek().OnPause();
                                }
                                else if (MenuPanel is object && nextTask.t_panelType != MG_PopPanelType.ShopPanel)
                                {
                                    MenuPanel.OnPause();
                                }
                                bool      isGamePanel   = panelIndex == 0 || panelIndex == 1 || panelIndex == 2 || panelIndex == 3;
                                MG_UIBase nextShowPanel = Instantiate(Resources.Load <GameObject>(panelPath), isGamePanel ? GamePanelRoot : PopPanelRoot).GetComponent <MG_UIBase>();
                                nextShowPanel.transform.SetAsLastSibling();
                                Panel_Stack.Push(nextShowPanel);
                                LoadedPanel_Dic.Add(panelIndex, nextShowPanel);
                                yield return(nextShowPanel.OnEnter());
                            }
                        }
                        else
                        {
                            Debug.LogWarning("Show MG_PopPanel-" + nextTask.t_panelType + " Error : panelPathDic content is null or empty.");
                            continue;
                        }
                    }
                    else
                    {
                        Debug.LogWarning("Close MG_PopPanel-" + nextTask.t_panelType + " Error : panel has not loaded or show.");
                        continue;
                    }
                }
            }
            MG_Manager.Instance.canBackGame = true;
            Cor_PopPanelTask = null;
        }
Exemplo n.º 3
0
        public bool ShowPopPanel(MG_PopPanelType _PanelType)
        {
            int panelIndex = (int)_PanelType;

            if (LoadedPanel_Dic.TryGetValue(panelIndex, out MG_UIBase loadedPopPanel))
            {
                if (loadedPopPanel is null)
                {
                    LoadedPanel_Dic.Remove(panelIndex);
                    Debug.LogWarning("Show MG_PopPanel-" + _PanelType + " Error : loadedDic has key , but content is null.");
                    return(false);
                }
                else
                {
                    if (Panel_Stack.Contains(loadedPopPanel))
                    {
                        Debug.LogWarning("Show MG_PopPanel-" + _PanelType + " Error : panel has showed.");
                        return(false);
                    }
                    else
                    {
                        if (Panel_Stack.Count > 0)
                        {
                            Panel_Stack.Peek().OnPause();
                        }
                        loadedPopPanel.transform.SetAsLastSibling();
                        Panel_Stack.Push(loadedPopPanel);
                        loadedPopPanel.OnEnter();
                    }
                }
            }
            else
            {
                if (Type_Path_Dic.TryGetValue(panelIndex, out string panelPath))
                {
                    if (string.IsNullOrEmpty(panelPath))
                    {
                        Debug.LogWarning("Show MG_PopPanel-" + _PanelType + " Error : panelPathDic content is null or empty.");
                        return(false);
                    }
                    else
                    {
                        MG_UIBase nextShowPanel = Instantiate(Resources.Load <GameObject>(panelPath), PopPanelRoot).GetComponent <MG_UIBase>();
                        if (Panel_Stack.Count > 0)
                        {
                            Panel_Stack.Peek().OnPause();
                        }
                        nextShowPanel.transform.SetAsLastSibling();
                        Panel_Stack.Push(nextShowPanel);
                        LoadedPanel_Dic.Add(panelIndex, nextShowPanel);
                        nextShowPanel.OnEnter();
                    }
                }
                else
                {
                    Debug.LogWarning("Show MG_PopPanel-" + _PanelType + " Error : panelPathDic content is null or empty.");
                    return(false);
                }
            }
            return(true);
        }