Esempio n. 1
0
 public void CloseCurrentGamePanel()
 {
     if (Current_GamePanel is object)
     {
         StartCoroutine(Current_GamePanel.OnExit());
     }
     Current_GamePanel = null;
 }
Esempio n. 2
0
 public void CloseCurrentGamePanel()
 {
     if (Current_GamePanel is object)
     {
         StartCoroutine(Current_GamePanel.OnExit());
         Current_GamePanel = null;
         MG_SaveManager.Current_GamePanel = -1;
     }
 }
Esempio n. 3
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);
        }
Esempio n. 4
0
        public bool ClosePopPanel(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("Close MG_PopPanel-" + _PanelType + " Error : loadedDic has key , but content is null.");
                    return(false);
                }
                if (Panel_Stack.Contains(loadedPopPanel))
                {
                    while (true)
                    {
                        if (Panel_Stack.Count > 0)
                        {
                            MG_UIBase outPanel = Panel_Stack.Pop();
                            outPanel.OnExit();
                            if (Panel_Stack.Count > 0)
                            {
                                Panel_Stack.Peek().OnResume();
                            }
                            if (outPanel == loadedPopPanel)
                            {
                                break;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                else
                {
                    Debug.LogWarning("Close MG_PopPanel-" + _PanelType + " Error : panel has not show.");
                    return(false);
                }
            }
            else
            {
                Debug.LogWarning("Close MG_PopPanel-" + _PanelType + " Error : panel has not show.");
                return(false);
            }
            return(true);
        }
Esempio n. 5
0
 public bool CloseTopPopPanelAsync()
 {
     if (Panel_Stack.Count > 0)
     {
         MG_UIBase _UIBase = Panel_Stack.Peek();
         if (LoadedPanel_Dic.ContainsValue(_UIBase))
         {
             foreach (var keyValue in LoadedPanel_Dic)
             {
                 if (keyValue.Value == _UIBase)
                 {
                     ClosePopPanelAsync((MG_PopPanelType)keyValue.Key);
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Esempio n. 6
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;
        }
Esempio n. 7
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);
        }