Esempio n. 1
0
    /// <summary>
    /// 获取最大的SortingOrder层级
    /// </summary>
    public int GetHighestSortingOrder()
    {
        int result = 0;

        if (_fullStack.Count > 0)
        {
            result = _fullStack.Peek().lastSortingOrder + 10;  //弹窗这里的排序还是加上10才保险,可以预留10个深度来用
        }
        return(Mathf.Clamp(result + 1, 10, int.MaxValue));
    }
Esempio n. 2
0
    /// <summary>
    /// 入栈的协程
    /// </summary>
    /// <param name="stackable"></param>
    /// <param name="manualDepth"></param>
    /// <returns></returns>
    private IEnumerator EnStackCoroutine(IStackableUI stackable)
    {
        if (stackable != null && !stackable.Equals(null))
        {
            // disable Main Camera
            if (stackable.IsFullscreen())
            {
                _isFullScreenOpened = true;

                GameUtils.SetMainCameraActive(stackable.IsRenderingWorldWhileFullscreen());
            }

            // OnBlur Event on top ui
            if (_backStack.Count > 0)
            {
                if (_enstackFlag == 0 && _backstackFlag == 0)
                {
                    _backStack.Peek().stackable.OnBlur();
                }
            }

            _enstackFlag   = 0;
            _backstackFlag = 0;

            // Create wrapper
            IStackableWrapper wrapper = new IStackableWrapper();
            wrapper.stackable = stackable;

            // Insert an input blocker if needed
            if (stackable.ShowUIBlocker)
            {
                _isInputBlockerVisible            = true;
                wrapper.inputBlockerInstance      = GameObject.Instantiate(inputBlockerPrefab);
                wrapper.inputBlockerInstance.name = string.Format("InputBlockerFor{0}", stackable.ToString());
                wrapper.inputBlockerInstance.transform.SetParent(gameObject.transform);
                wrapper.inputBlockerInstance.transform.localPosition = Vector3.zero;
                wrapper.inputBlockerInstance.transform.localScale    = Vector3.one;
                wrapper.inputBlockerInstance.GetComponentInChildren <UISprite>().alpha = 0.05f;
                TweenAlpha ta = wrapper.inputBlockerInstance.GetComponentInChildren <TweenAlpha>();
                ta.tweenFactor = 1.0f;                  //0.0f
                ta.PlayForward();
            }

            // Warn other screens that we're about to stack someone
            if (onEnstack != null)
            {
                onEnstack(stackable);
            }

            _nextStackDepth = AssignDepths(wrapper);

            // Hide below, set visible variables
            EB.Collections.Stack <IStackableWrapper> tempStack = new EB.Collections.Stack <IStackableWrapper>();
            while (_backStack.Count > 0)
            {
                tempStack.Push(_backStack.Pop());

                if (stackable.IsFullscreen())
                {
                    tempStack.Peek().stackable.Show(false);
                }
                if (tempStack.Peek().inputBlockerInstance != null && (stackable.ShowUIBlocker || stackable.IsFullscreen()))
                {
                    if (stackable.IsFullscreen() && wrapper.inputBlockerInstance == null)
                    {
                        _isInputBlockerVisible = false;
                    }

                    // hide blocker for next frame
                    var tempPanel = tempStack.Peek().inputBlockerInstance.GetComponent <UIPanel>();
                    if (wrapper.inputBlockerInstance && wrapper.inputBlockerInstance.name.Contains("DataPanelNew"))
                    {
                        tempPanel.alpha = 0.0f;
                    }
                    else
                    {
                        EB.Coroutines.EndOfFrame(delegate()
                        {
                            tempPanel.alpha = 0.0f;
                        });
                    }
                }
            }

            while (tempStack.Count > 0)
            {
                _backStack.Push(tempStack.Pop());
            }

            // Fix again
            if (_isInputBlockerVisible && stackable.IsFullscreen() && wrapper.inputBlockerInstance == null)
            {
                _isInputBlockerVisible = false;
            }

            // Place stackable
            _backStack.Push(wrapper);
            _fullStack.Push(wrapper);

            // OnFocus Event
            _enstackFlag = ++s_seed;
            int currentFlag = _enstackFlag;
            yield return(StartCoroutine(stackable.OnAddToStack()));

            if (_enstackFlag == currentFlag && !IsLoadingScreenUp)
            {
                _enstackFlag = 0;
                stackable.OnFocus();
            }
        }
    }
Esempio n. 3
0
    /// <summary>
    /// 执行ui出栈操作,移除栈顶ui
    /// </summary>
    /// <param name="isPartOfExitStack">是否是退出状态的一部分,从而决定是否做些uicontroller中的一些逻辑或回调</param>
    /// <returns></returns>
    private IEnumerator BackstackCoroutine(bool isPartOfExitStack)
    {
        if (_backStack.Count == 0)
        {
            EB.Debug.LogWarning("BackstackCoroutine: backStack is empty");
            yield break;
        }

        IStackableWrapper wrapper = _backStack.Pop();

        EB.Debug.LogUI("界面UIStack:【<color=#00ff00>{0}</color>】在<color=#fff348>UIStack</color>中<color=#ff0000>从栈顶出栈</color>", wrapper.stackable);

        // Clear eventual stacked renderers from the full stack
        while (_fullStack.Pop() != wrapper)
        {
            ;
        }

        if (onBackstack != null)
        {
            onBackstack(wrapper.stackable);
        }

        if (wrapper.inputBlockerInstance != null)
        {
            // Value might be changed later depending on whether we find another input blocker before the next panel
            _isInputBlockerVisible = false;
            TweenAlpha ta = wrapper.inputBlockerInstance.GetComponentInChildren <TweenAlpha>();
            ta.tweenFactor = 1.0f;
            EventDelegate.Add(ta.onFinished, () => Destroy(wrapper.inputBlockerInstance));
            ta.PlayReverse();
        }

        if (wrapper.firstStackDepth >= 0 && wrapper.firstStackDepth < _nextStackDepth)
        {
            _nextStackDepth = wrapper.firstStackDepth;
        }

        // Let the other windows know what happened, show what needs to be shown, etc.
        if (_backStack.Count > 0)
        {
            EB.Collections.Stack <IStackableWrapper> tempStack = new EB.Collections.Stack <IStackableWrapper>();
            while (_backStack.Count > 0 && !_backStack.Peek().stackable.IsFullscreen())
            {
                tempStack.Push(_backStack.Pop());

                if (wrapper.stackable.IsFullscreen())
                {
                    tempStack.Peek().stackable.Show(true);
                }
                if (tempStack.Peek().inputBlockerInstance != null && !_isInputBlockerVisible)
                {
                    // show top blocker
                    //TweenAlpha tempTa = tempStack.Peek().inputBlockerInstance.GetComponentInChildren<TweenAlpha>();
                    _isInputBlockerVisible = true;
                    tempStack.Peek().inputBlockerInstance.GetComponent <UIPanel>().alpha = 1f;                   // tempTa.to;

                    // update tween parameters
                    if (wrapper.inputBlockerInstance != null)
                    {
                        TweenAlpha ta = wrapper.inputBlockerInstance.GetComponentInChildren <TweenAlpha>();
                        ta.tweenFactor = 0.0f;
                        wrapper.inputBlockerInstance.GetComponentInChildren <UISprite>().alpha = 0.05f;
                    }
                }
            }

            if (wrapper.stackable.IsFullscreen())
            {
                // If the count is positive, it means that we've hit a full screen
                if (_backStack.Count > 0)
                {
                    // show top full screen
                    _backStack.Peek().stackable.Show(true);
                    if (_backStack.Peek().inputBlockerInstance != null && !_isInputBlockerVisible)
                    {
                        // show top blocker
                        TweenAlpha tempTa = tempStack.Peek().inputBlockerInstance.GetComponentInChildren <TweenAlpha>();
                        _isInputBlockerVisible = true;
                        _backStack.Peek().inputBlockerInstance.GetComponent <UIPanel>().alpha = tempTa.to;

                        // update tween parameters
                        if (wrapper.inputBlockerInstance != null)
                        {
                            TweenAlpha ta = wrapper.inputBlockerInstance.GetComponentInChildren <TweenAlpha>();
                            ta.tweenFactor = 0.0f;
                            wrapper.inputBlockerInstance.GetComponentInChildren <UISprite>().alpha = 0.05f;
                        }
                    }

                    GameUtils.SetMainCameraActive(_backStack.Peek().stackable.IsRenderingWorldWhileFullscreen());
                }
                else
                {
                    // No full screen, show the HUD
                    _isFullScreenOpened = false;
                }
            }

            while (tempStack.Count > 0)
            {
                _backStack.Push(tempStack.Pop());
            }
        }
        else
        {
            // There's nothing in the stack, so no full screen, no blocker
            _isFullScreenOpened    = false;
            _isInputBlockerVisible = false;
        }

        if (!_isFullScreenOpened && !IsLoadingScreenUp)
        {
            GameUtils.SetMainCameraActive(true);
        }

        if (wrapper.stackable == _currentQueuedStackableDisplayed)
        {
            _currentQueuedStackableDisplayed = null;
        }

        if (_enstackFlag == 0 && _backstackFlag == 0 && !isPartOfExitStack)
        {
            wrapper.stackable.OnBlur();
        }

        _enstackFlag   = 0;
        _backstackFlag = 0;

        _backstackFlag = ++s_seed;
        var currentFlag = _backstackFlag;

        wrapper.stackable.ClearData();
        yield return(StartCoroutine(wrapper.stackable.OnRemoveFromStack()));

        if (currentFlag == _backstackFlag)
        {
            _backstackFlag = 0;

            if (_backStack.Count > 0 && !isPartOfExitStack)
            {
                //EB.Debug.LogWarning("Backstack: finish {0} onfocus", backStack.Peek().stackable);
                _backStack.Peek().stackable.OnFocus();
            }
            else
            {
                //EB.Debug.LogWarning("Backstack: finish");
            }

            if (!isPartOfExitStack)
            {
                OnFinishedBackstacking();
            }
        }
    }
Esempio n. 4
0
    private void ShowLoadingScreen_AfterFunc(bool showSplash, bool showBlock, bool showCloud, System.Action onReady)
    {
        System.Action newOnReady = delegate
        {
            if (_backStack.Count > 0 && !_backStack.Peek().stackable.CanAutoBackstack() && _backstackFlag == 0 && _enstackFlag == 0)
            {
                _backStack.Peek().stackable.OnBlur();
            }
            _nextStackDepth = STACK_DEPTH_OFFSET;

            onReady?.Invoke();
        };

        _loadingScreen_logic.SetLoadingScreen(showSplash, showBlock, showCloud, onReady);
    }