Beispiel #1
0
        /// <summary>
        /// 退出指定UI
        /// </summary>
        /// <param name="UIname"></param>
        private void ExitUIForm(string uIName)
        {
            BaseUI baseUI = null;

            // 如果"当前显示的UI"不包含这个UI ,就直接返回
            dicCurrentShowUIForms.TryGetValue(uIName, out baseUI);
            if (baseUI == null)
            {
                return;
            }
            // 隐藏UI 并从"当前显示的UI"集合中移除UI
            baseUI.Hiding();
            dicCurrentShowUIForms.Remove(uIName);
        }
Beispiel #2
0
        /// <summary>
        /// (反向切换UI) 窗体出站逻辑
        /// </summary>
        private void PopUIForm(string uIName)
        {
            if (stackCurrentUIForm.Count >= 2)
            {
                BaseUI topUIForm = stackCurrentUIForm.Pop();
                topUIForm.Hiding();

                BaseUI enxtUIform = stackCurrentUIForm.Peek();
                enxtUIform.Redisplay();
            }
            else if (stackCurrentUIForm.Count == 1)
            {
                BaseUI topUIForm = stackCurrentUIForm.Pop();
                topUIForm.Hiding();
            }
        }
Beispiel #3
0
        /// <summary>
        /// 将UI加载到"当前窗体"的集合中
        /// </summary>
        /// <param name="UIname"></param>
        private void LoadUIToCurrentCache(string uIName)
        {
            BaseUI baseUI             = null;
            BaseUI baseUIFromAllCache = null;

            // 查看当前显示得到UI窗体中是否包含这个UI窗体,如果包含 直接返回
            dicCurrentShowUIForms.TryGetValue(uIName, out baseUI);
            if (baseUI != null)
            {
                return;
            }
            // 将当前窗体添加到正在显示的集合中
            dicALLUIForm.TryGetValue(uIName, out baseUIFromAllCache);
            if (baseUIFromAllCache != null)
            {
                dicCurrentShowUIForms.Add(uIName, baseUIFromAllCache);
                baseUIFromAllCache.Display();
            }
        }
Beispiel #4
0
        /// <summary>
        /// 打开UI
        /// </summary>
        /// <param name="UIName"></param>
        public void OpenUI(string UIName)
        {
            BaseUI baseUI = null;

            if (string.IsNullOrEmpty(UIName))
            {
                return;
            }

            baseUI = LoadFormsToAllUIFormsCatch(UIName);
            if (baseUI == null)
            {
                return;
            }

            if (baseUI.SetUIType.IsClearReverseChange)
            {
                ClearStackArraty(); // 清空栈集合中的数据
            }
            switch (baseUI.SetUIType._UIFormShowMode)
            {
            case EnumUIFormShowMode.Normal:
                LoadUIToCurrentCache(UIName);
                break;

            case EnumUIFormShowMode.ReversChange:
                PushUIFormToStack(UIName);
                break;

            case EnumUIFormShowMode.HideOther:
                EnterUIFormsAndHideOther(UIName);
                break;

            case EnumUIFormShowMode.Floating:
                FloatingUIFormsShow(UIName);
                break;

            default:
                break;
            }
        }
Beispiel #5
0
        /// <summary>
        /// 关闭UI
        /// </summary>
        /// <param name="UIName"></param>
        public void CloseUI(string UIName)
        {
            BaseUI baseUI = null;

            if (string.IsNullOrEmpty(UIName))
            {
                return;
            }

            dicALLUIForm.TryGetValue(UIName, out baseUI);
            if (baseUI == null)
            {
                return;
            }

            switch (baseUI.SetUIType._UIFormShowMode)
            {
            case EnumUIFormShowMode.Normal:
                ExitUIForm(UIName);
                break;

            case EnumUIFormShowMode.ReversChange:
                PopUIForm(UIName);
                break;

            case EnumUIFormShowMode.HideOther:
                ExitUIFormsAndDisplayOther(UIName);
                break;

            case EnumUIFormShowMode.Floating:
                if (FloatingUIFormsObject != null)
                {
                    FloatingUIFormsObject.Hiding();
                }
                break;

            default:
                break;
            }
        }
Beispiel #6
0
        /// <summary>
        /// 将UI加载到"当前窗体"的集合中
        /// </summary>
        /// <param name="UIname"></param>
        private void PushUIFormToStack(string uIName)
        {
            BaseUI baseUI = null;

            // 判断栈集合中 是否包含其他UI 否则做冻结处理
            if (stackCurrentUIForm.Count > 0)
            {
                BaseUI topBaseUI = stackCurrentUIForm.Peek();
                topBaseUI.Freeze(); // 栈顶元素冻结处理
            }

            dicALLUIForm.TryGetValue(uIName, out baseUI);
            if (baseUI != null)
            {
                baseUI.Display();                //将当前窗体设置为显示状态
                stackCurrentUIForm.Push(baseUI); // 将当前窗体入栈操作
            }
            else
            {
                Debug.LogError("baseUIForm==null,Please Check, 参数 uiFormName=" + uIName);
            }
        }
Beispiel #7
0
        /// <summary>
        /// 浮动窗口显示的位置
        /// </summary>
        /// <param name="floattingWindew"></param>
        /// <param name="parentObject"></param>
        /// <param name="floattingWindewBaseUI"></param>
        Vector2 CreatePosition(RectTransform floattingWindew, RectTransform parentObject, BaseUI floattingWindewBaseUI)
        {
            EnumFloatingUIShowPosition floatingUIShowPosition = floattingWindewBaseUI.SetUIType._FloatingUIShowPosition;

            return(CreatePosition(floattingWindew, parentObject, floatingUIShowPosition));
        }
Beispiel #8
0
        /// <summary>
        /// 浮动窗口打开
        /// </summary>
        /// <param name="UIname"></param>
        /// <param name="vector"></param>
        void FloatingUIFormsShow(string UIname)
        {
            BaseUI        baseUIForm;
            GameObject    parentObj           = EventSystem.current.currentSelectedGameObject;
            RectTransform parentRectTransform = parentObj.gameObject.GetComponent <RectTransform>();

            if (FloatingUIFormsObject != null)
            {
                FloatingUIFormsObject.Hiding();
                FloatingUIFormsObject = null;
            }

            dicALLUIForm.TryGetValue(UIname, out baseUIForm);
            if (baseUIForm != null)
            {
                FloatingUIFormsObject = baseUIForm;
                RectTransform rectTran = FloatingUIFormsObject.gameObject.GetComponent <RectTransform>();
                Vector2       scope    = CreatePosition(rectTran, parentRectTransform, FloatingUIFormsObject);
                scope = new Vector2(Mathf.Abs(scope.x), Mathf.Abs(scope.y));
                if (canvasScope.x < scope.x || canvasScope.y < scope.y)
                {
                    switch (FloatingUIFormsObject.SetUIType._FloatingUIShowPosition)
                    {
                    case EnumFloatingUIShowPosition.Top:
                        CreatePosition(rectTran, parentRectTransform, EnumFloatingUIShowPosition.Below);
                        break;

                    case EnumFloatingUIShowPosition.Below:
                        CreatePosition(rectTran, parentRectTransform, EnumFloatingUIShowPosition.Top);
                        break;

                    case EnumFloatingUIShowPosition.Left:
                        CreatePosition(rectTran, parentRectTransform, EnumFloatingUIShowPosition.Right);
                        break;

                    case EnumFloatingUIShowPosition.LeftTop:
                        CreatePosition(rectTran, parentRectTransform, EnumFloatingUIShowPosition.RightBelow);
                        break;

                    case EnumFloatingUIShowPosition.LeftBelow:
                        CreatePosition(rectTran, parentRectTransform, EnumFloatingUIShowPosition.RightTop);
                        break;

                    case EnumFloatingUIShowPosition.Right:
                        CreatePosition(rectTran, parentRectTransform, EnumFloatingUIShowPosition.Left);
                        break;

                    case EnumFloatingUIShowPosition.RightTop:
                        CreatePosition(rectTran, parentRectTransform, EnumFloatingUIShowPosition.LeftBelow);
                        break;

                    case EnumFloatingUIShowPosition.RightBelow:
                        CreatePosition(rectTran, parentRectTransform, EnumFloatingUIShowPosition.LeftTop);
                        break;

                    default:
                        break;
                    }
                }
                FloatingUIFormsObject.Display();
            }
        }