Example #1
0
        //		public T GetController<T> (SceneInfo info)  where T  : BaseSceneController
        //		{
        //			if(info == null) return null;
        //			return info.GetSceneController<T>() ;
        //		}
        //
        //		public T GetControllerInPerant<T> () where T : BaseSceneController
        //		{
        //			SceneInfo t = this.Parent;
        //			while (t != null) {
        //				var controller = GetController<T> (t);
        //				if (controller is T) {
        //					return controller as T;
        //				}
        //				t = t.Parent;
        //			}
        //			return null;
        //		}
        //


        protected bool IsChildSceneInfo(SceneInfo info)
        {
            Queue <SceneInfo> queue = new Queue <SceneInfo>();

            foreach (var child in this.childs)
            {
                queue.Enqueue(child);
            }
            while (queue.Count > 0)
            {
                SceneInfo target = queue.Dequeue();
                if (target.Equals(info))
                {
                    return(true);
                }
                var con = target.GetSceneController <BaseSceneController>();
                if (con != null)
                {
                    foreach (var child in con.childs)
                    {
                        queue.Enqueue(child);
                    }
                }
            }
            return(false);
        }
Example #2
0
        public void Additive(string name, Dictionary <string, object> args = null, System.Action <BaseSceneController> onOpen = null, System.Action <BaseSceneController> onClose = null)
        {
            if (MySceneInfo.SceneType == SceneType.Popup)
            {
                Debug.LogWarning("Cannot Additive Scene in Popup Scene ");
                return;
            }
            Root.GetSceneController <BaseSceneController>().eventSystem.enabled = false;
            SceneInfo newScene = new SceneInfo(MySceneInfo, name, LoadSceneMode.Additive, args,
                                               (info) =>
            {
                if (onOpen != null)
                {
                    onOpen(info.GetSceneController <BaseSceneController>());
                }
            },
                                               (info) =>
            {
                if (onClose != null)
                {
                    onClose(info.GetSceneController <BaseSceneController>());
                }
            });

            newScene.OnClose += (obj) =>
            {
                this.childs.Remove(newScene);
            };
            this.childs.Add(newScene);
            GameSceneManager.Instance.LoadScene(newScene, _ =>
            {
                newScene.GetSceneController <BaseSceneController>().eventSystem.enabled = false;
                Root.GetSceneController <BaseSceneController>().eventSystem.enabled     = true;
            });
        }
Example #3
0
 public void PopupUniqueScene(string name, Dictionary <string, object> args = null, System.Action <BaseSceneController> onOpen = null, System.Action <BaseSceneController> onClose = null)
 {
     popupSingleCount++;
     if (currentSinglePopup != null)
     {
         var rootController = Root.GetSceneController <BaseSceneController>();
         rootController.SetEnableCanvas(false);
         Root.GetSceneController <BaseSceneController>().eventSystem.enabled = false;
         SceneInfo newScene = new SceneInfo(name, LoadSceneMode.Additive, args,
                                            (info) =>
         {
             if (onOpen != null)
             {
                 onOpen(info.GetSceneController <BaseSceneController>());
             }
         },
                                            (info) =>
         {
             if (onClose != null)
             {
                 onClose(info.GetSceneController <BaseSceneController>());
             }
         });
         newScene.SceneType = SceneType.Popup;
         newScene.OnClose  += (SceneInfo obj) =>
         {
             popupSingleCount   = 0;
             currentSinglePopup = null;
             rootController.SetEnableCanvas(true);
         };
         currentSinglePopup = newScene;
         GameSceneManager.Instance.LoadScene(newScene, _ =>
         {
             newScene.GetSceneController <BaseSceneController>().eventSystem.enabled = false;
             newScene.GetSceneController <BaseSceneController>().SetSceneCanvasOrder(Root.GetSceneController <BaseSceneController>().GetTopSceneCanvasOrder() + 2);
             Root.GetSceneController <BaseSceneController>().eventSystem.enabled = true;
         });
     }
 }
Example #4
0
        protected void SwitchTabScene(int idx)
        {
            if (currentTapSceneInfo != null && currentTapSceneInfo.Name == tabSceneNames[idx])
            {
                return;
            }


            SceneInfo preScene = currentTapSceneInfo;
            var       info     = this.childs.Find(o => o.Name == tabSceneNames[idx]);

            if (info == null)
            {
                Root.GetSceneController <BaseSceneController>().eventSystem.enabled = false;
                SceneInfo newScene = new SceneInfo(MySceneInfo, tabSceneNames[idx], LoadSceneMode.Additive);
                newScene.OnClose   += (SceneInfo obj) => this.childs.Remove(newScene);
                currentTapSceneInfo = newScene;
                this.childs.Add(newScene);
                GameSceneManager.Instance.LoadScene(newScene, _ => {
                    newScene.GetSceneController <BaseSceneController>().eventSystem.enabled = false;
                    Root.GetSceneController <BaseSceneController>().eventSystem.enabled     = true;
                    if (preScene != null)
                    {
                        preScene.GetSceneController <BaseSceneController>().Deactive();
                    }
                });
            }
            else
            {
                if (preScene != null)
                {
                    preScene.GetSceneController <BaseSceneController>().Deactive();
                }
                info.GetSceneController <BaseSceneController>().Active();
                currentTapSceneInfo = info;
                return;
            }
        }
Example #5
0
        public T GetControllerInParant <T>() where T : class, ISceneController
        {
            SceneInfo t = this.Parent;

            while (t != null)
            {
                var controller = t.GetSceneController <T>();
                if (controller is T)
                {
                    return(controller as T);
                }
                t = t.Parent;
            }
            return(null);
        }
        public void Push(string rootSceneName, Dictionary <string, object> args = null)
        {
            SceneInfo preScene = childs.Count != 0 ? childs[childs.Count - 1] : null;
            SceneInfo newScene = new SceneInfo(MySceneInfo, rootSceneName, LoadSceneMode.Additive, args);

            Root.GetSceneController <BaseSceneController>().eventSystem.enabled = false;
            newScene.OnClose += (SceneInfo obj) =>
            {
                int removeIndex = this.childs.IndexOf(obj);
                if (removeIndex >= 0)
                {
                    this.childs.RemoveAt(removeIndex);
                    var delList = this.childs.GetRange(removeIndex, childs.Count - removeIndex);
                    foreach (var del in delList)
                    {
                        this.childs.Remove(del);
                    }

                    foreach (var del in delList)
                    {
                        GameSceneManager.Instance.CloseScene(del);
                    }
                    if (childs.Count != 0)
                    {
                        childs[childs.Count - 1].GetSceneController <BaseSceneController>().Active();
                    }
                }
            };

            this.childs.Add(newScene);
            GameSceneManager.Instance.LoadScene(newScene, _ =>
            {
                newScene.GetSceneController <BaseSceneController>().eventSystem.enabled = false;
                Root.GetSceneController <BaseSceneController>().eventSystem.enabled     = true;

                if (preScene != null)
                {
                    preScene.GetSceneController <BaseSceneController>().Deactive();
                }
            });
        }
Example #7
0
        public void Popup(string name, Dictionary <string, object> args = null, System.Action <BaseSceneController> onOpen = null, System.Action <BaseSceneController> onClose = null)
        {
            PopupArgs pinfo = new PopupArgs();

            pinfo.name    = name;
            pinfo.args    = args;
            pinfo.onOpen  = onOpen;
            pinfo.onClose = onClose;
            popupQueue.Enqueue(pinfo);
            System.Action DisplayPopup = null;
            DisplayPopup = () =>
            {
                if (popupQueue.Count <= 0)
                {
                    return;
                }
                if (this.currentPopup != null)
                {
                    return;
                }
                var       rootController = Root.GetSceneController <BaseSceneController>();
                PopupArgs popArgs        = popupQueue.Dequeue();
                if (popArgs != null)
                {
                    rootController.SetEnableCanvas(false);
                    Root.GetSceneController <BaseSceneController>().eventSystem.enabled = false;
                    var newScene = new SceneInfo(popArgs.name, LoadSceneMode.Additive, popArgs.args,
                                                 (info) =>
                    {
                        if (popArgs.onOpen != null)
                        {
                            popArgs.onOpen(info.GetSceneController <BaseSceneController>());
                        }
                    },
                                                 (info) =>
                    {
                        if (popArgs.onClose != null)
                        {
                            popArgs.onClose(info.GetSceneController <BaseSceneController>());
                        }
                    });
                    newScene.SceneType = SceneType.Popup;
                    newScene.OnClose  += (SceneInfo obj) =>
                    {
                        this.currentPopup = null;
                        rootController.SetEnableCanvas(true);
                        DisplayPopup();
                    };

                    this.currentPopup = newScene;
                    GameSceneManager.Instance.LoadScene(newScene, _ =>
                    {
                        newScene.GetSceneController <BaseSceneController>().eventSystem.enabled = false;
                        newScene.GetSceneController <BaseSceneController>().SetSceneCanvasOrder(Root.GetSceneController <BaseSceneController>().GetTopSceneCanvasOrder() + 2);
                        Root.GetSceneController <BaseSceneController>().eventSystem.enabled = true;
                    });
                }
                else
                {
                }
            };

            DisplayPopup();
        }