Ejemplo n.º 1
0
        private void ExecuteNavigationLogic(UIWindowBase baseWindow, ShowWindowData showData)
        {
            WindowCoreData windowData = baseWindow.windowData;

            if (baseWindow.RefreshBackSeqData)
            {
                RefreshBackSequenceData(baseWindow, showData);
            }
            else if (windowData.showMode == UIWindowShowMode.HideOtherWindow)
            {
                HideAllShownWindow();
            }

            // If target window is mark as force clear all the navigation sequence data
            // Show data need force clear the back seq data
            if (baseWindow.windowData.forceClearNavigation || (showData != null && showData.forceClearBackSeqData))
            {
                Debug.Log("<color=#2a5caa>## [Enter the start window, reset the backSequenceData for the navigation system.]##</color>");
                ClearBackSequence();
            }
            else
            {
                if ((showData != null && showData.checkNavigation))
                {
                    CheckBackSequenceData(baseWindow);
                }
            }
        }
Ejemplo n.º 2
0
        protected virtual void RealShowWindow(UIWindowBase baseWindow, WindowID id, ShowWindowData showData = null)
        {
            BaseWindowContextData contextData = showData == null ? null : showData.contextData;

            baseWindow.ReadyToShowWindow(contextData);
            dicShownWindows[id] = baseWindow;
            if (baseWindow.windowData.navigationMode == UIWindowNavigationMode.NormalNavigation)
            {
                lastNavigationWindow = curNavigationWindow;
                curNavigationWindow  = baseWindow;
                Debug.Log("<color=magenta>### current Navigation window </color>" + baseWindow.ID.ToString());
            }
        }
Ejemplo n.º 3
0
        public override UIWindowBase ShowWindow(WindowID id, ShowWindowData showData = null)
        {
            UIWindowBase baseWindow = ReadyToShowBaseWindow(id, showData);

            if (baseWindow != null)
            {
                RealShowWindow(baseWindow, id, showData);
            }
            else
            {
                baseWindow = GetGameWindow(id);
                if (baseWindow != null)
                {
                    BaseWindowContextData contextData = showData == null ? null : showData.contextData;
                    baseWindow.ReadyToShowWindow(contextData);
                }
            }
            return(baseWindow);
        }
Ejemplo n.º 4
0
 protected void ShowWindowForOtherWindowManager(WindowID id, ShowWindowData showData)
 {
     if (!IsWindowInControl(id))
     {
         Debug.Log("UIRankManager has no control power of " + id.ToString());
         return;
     }
     if (dicShownWindows.ContainsKey(id))
     {
         return;
     }
     if (dicAllWindows.ContainsKey(id))
     {
         UIWindowBase baseWindow = dicAllWindows[id];
         if (baseWindow.ID != id)
         {
             Debug.LogError(string.Format("[UIRankManager BaseWindowId :{0} != shownWindowId :{1}]", baseWindow.ID, id));
             return;
         }
         this.RealShowWindow(baseWindow, baseWindow.ID, showData);
     }
 }
Ejemplo n.º 5
0
        protected bool RealPopNavigationWindow()
        {
            if (backSequence.Count == 0)
            {
                if (curNavigationWindow == null)
                {
                    return(false);
                }
                if (PopUpWindowManager(curNavigationWindow))
                {
                    return(true);
                }

                // if curNavigationWindow BackSequenceData is null
                // Check window's preWindowId
                // if preWindowId defined just move to target Window(preWindowId)
                WindowID preWindowId = curNavigationWindow.PreWindowID;
                if (preWindowId != WindowID.Invaild)
                {
                    Debug.LogWarning(string.Format(string.Format("## Current nav window {0} need show pre window {1}.", curNavigationWindow.ID.ToString(), preWindowId.ToString())));
                    switch (curNavigationWindow.windowData.closeModel)
                    {
                    case UIWindowCloseModel.Hide:
                    {
                        HideWindow(curNavigationWindow.ID, delegate
                            {
                                ShowWindowData showData  = new ShowWindowData();
                                showData.executeNavLogic = false;
                                ShowWindow(preWindowId, showData);
                            });
                    }
                    break;

                    case UIWindowCloseModel.Destory:
                    {
                        DestroyWindow(curNavigationWindow.ID, delegate
                            {
                                ShowWindowData showData  = new ShowWindowData();
                                showData.executeNavLogic = false;
                                ShowWindow(preWindowId, showData);
                            });
                    }
                    break;
                    }
                }
                else
                {
                    Debug.LogWarning("## CurrentShownWindow " + curNavigationWindow.ID + " preWindowId is " + WindowID.Invaild);
                }
                return(false);
            }
            NavigationData backData = backSequence.Peek();

            if (backData != null)
            {
                // check the current navigation data
                WindowID curId = this.GetCurrentShownWindow();
                if (curId != backData.CloseTargetWindow.ID)
                {
                    Debug.Log("<color=red>Can't PopUp seq data [backData.hideTargetWindow.ID != this.curShownWindowId]</color>");
                    return(false);
                }

                if (PopUpWindowManager(backData.CloseTargetWindow))
                {
                    return(true);
                }

                WindowID closeId = backData.CloseTargetWindow.ID;
                if (!dicShownWindows.ContainsKey(closeId))
                {
                    ExectuteBackSeqData(backData);
                }
                else
                {
                    switch (backData.CloseTargetWindow.windowData.closeModel)
                    {
                    case UIWindowCloseModel.Hide:
                    {
                        HideWindow(closeId, delegate
                            {
                                ExectuteBackSeqData(backData);
                            });
                    }
                    break;

                    case UIWindowCloseModel.Destory:
                    {
                        CheckDirectlyDestroyWIndow(closeId, delegate
                            {
                                ExectuteBackSeqData(backData);
                            });
                    }
                    break;
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 6
0
 protected virtual UIWindowBase ReadyToShowBaseWindow(WindowID id, ShowWindowData showData = null)
 {
     return(null);
 }
Ejemplo n.º 7
0
        private IEnumerator _ShowWindowDelay(float delayTime, WindowID id, ShowWindowData showData = null)
        {
            yield return(new WaitForSeconds(delayTime));

            ShowWindow(id, showData);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Delay to show target window
 /// </summary>
 /// <param name="delayTime"> delayTime</param>
 /// <param name="id"> WindowId</param>
 /// <param name="showData">show window data</param>
 public virtual void ShowWindowDelay(float delayTime, WindowID id, ShowWindowData showData = null)
 {
     StopAllCoroutines();
     StartCoroutine(_ShowWindowDelay(delayTime, id, showData));
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Show target Window
 /// </summary>
 public abstract UIWindowBase ShowWindow(WindowID id, ShowWindowData data = null);
Ejemplo n.º 10
0
        protected override UIWindowBase ReadyToShowBaseWindow(WindowID id, ShowWindowData showData = null)
        {
            // Check the window control state
            if (!this.IsWindowInControl(id))
            {
                Debug.Log("## UIManager has no control power of " + id.ToString());
                return(null);
            }

            // If the window in shown list just return
            if (dicShownWindows.ContainsKey(id))
            {
                return(null);
            }

            UIWindowBase baseWindow = GetGameWindow(id);

            // If window not in scene start Instantiate new window to scene
            bool newAdded = false;

            if (!baseWindow)
            {
                newAdded = true;
                if (UIResourceDefine.windowPrefabPath.ContainsKey(id))
                {
                    GameObject prefab = Resources.Load <GameObject>(UIResourceDefine.windowPrefabPath[id]);
                    if (prefab != null)
                    {
                        GameObject uiObject = (GameObject)GameObject.Instantiate(prefab);
                        //// NGUITools.SetActive(uiObject, true);
                        //// NOTE: You can add component to the window in the inspector
                        //// Or just AddComponent<UIxxxxWindow>() to the target
                        baseWindow = uiObject.GetComponent <UIWindowBase>();
                        if (baseWindow.ID != id)
                        {
                            Debug.LogError(string.Format("<color=#2a5caa>[BaseWindowId :{0} != shownWindowId :{1}]</color>", baseWindow.ID, id));
                            return(null);
                        }

                        // Get the window target root parent
                        Transform targetRoot = GetTargetRoot(baseWindow.windowData.windowType);
                        Transform t          = uiObject.transform;
                        t.SetParent(targetRoot.transform);
                        t.localPosition = Vector3.zero;
                        t.localRotation = Quaternion.identity;
                        t.localScale    = Vector3.one;
                        uiObject.layer  = targetRoot.gameObject.layer;
                        RectTransform _targetRectTransform = uiObject.GetComponent <RectTransform>();
                        if (_targetRectTransform.anchorMax == Vector2.one && _targetRectTransform.anchorMin == Vector2.zero)
                        {
                            //如果是拉伸就吧边角设置成0
                            UGUITools.SetRectTransformOffset(uiObject, Vector2.zero, Vector2.zero);
                        }
                        UGUITools.SetRectTransformAnchoredPosition(uiObject, Vector2.zero);
                        //  baseWindow = UGUITools.AddChild(targetRoot.gameObject, prefab).GetComponent<UIWindowBase>();
                        if (baseWindow.ID != id)
                        {
                            Debug.LogError(string.Format("<color=#2a5caa>[BaseWindowId :{0} != shownWindowId :{1}]</color>", baseWindow.ID, id));
                            return(null);
                        }
                        dicAllWindows[id] = baseWindow;
                        prefab            = null;
                    }
                }
            }

            if (baseWindow == null)
            {
                Debug.LogError("[window instance is null.]" + id.ToString());
            }

            // Call reset window when first load new window
            // Or get forceResetWindow param
            if (newAdded || (showData != null && showData.forceResetWindow))
            {
                baseWindow.ResetWindow();
            }

            if (showData == null || (showData != null && showData.executeNavLogic))
            {
                // refresh the navigation data
                ExecuteNavigationLogic(baseWindow, showData);
            }

            // Adjust the window depth
            AdjustBaseWindowDepth(baseWindow);

            // Add common background collider to window
            AddColliderBgForWindow(baseWindow);
            return(baseWindow);
        }
Ejemplo n.º 11
0
        private void RefreshBackSequenceData(UIWindowBase targetWindow, ShowWindowData showData)
        {
            WindowCoreData coreData = targetWindow.windowData;

            if (dicShownWindows.Count == 0)
            {
                return;
            }

            List <WindowID>     removedKey          = null;
            List <UIWindowBase> sortedHiddenWindows = new List <UIWindowBase>();

            NavigationData backData = new NavigationData();

            foreach (KeyValuePair <WindowID, UIWindowBase> window in dicShownWindows)
            {
                if (coreData.showMode != UIWindowShowMode.DoNothing)
                {
                    if (window.Value.windowData.windowType == UIWindowType.BackgroundLayer)
                    {
                        continue;
                    }
                    if (removedKey == null)
                    {
                        removedKey = new List <WindowID>();
                    }
                    removedKey.Add(window.Key);
                    window.Value.HideWindowDirectly();
                }

                if (window.Value.windowData.windowType != UIWindowType.BackgroundLayer)
                {
                    sortedHiddenWindows.Add(window.Value);
                }
            }

            if (removedKey != null)
            {
                for (int i = 0; i < removedKey.Count; i++)
                {
                    dicShownWindows.Remove(removedKey[i]);
                }
            }

            // Push new navigation data
            if (coreData.navigationMode == UIWindowNavigationMode.NormalNavigation && (showData == null || (!showData.ignoreAddNavData)))
            {
                // Add to return show target list
                sortedHiddenWindows.Sort(this.compareWindowFun);
                List <WindowID> navHiddenWindows = new List <WindowID>();
                for (int i = 0; i < sortedHiddenWindows.Count; i++)
                {
                    WindowID pushWindowId = sortedHiddenWindows[i].ID;
                    navHiddenWindows.Add(pushWindowId);
                }
                backData.CloseTargetWindow = targetWindow;
                backData.backShowTargets   = navHiddenWindows;

                backSequence.Push(backData);
                Debug.Log("<color=#2a5caa>### !!!Push new Navigation data!!! ###</color>");
            }
        }