public TransitionDetails(
     ITransitionDetails transitionDetails
     ) : base(transitionDetails)
 {
     m_TransitionOnWake       = transitionDetails.TransitionOnWake;
     m_TransitionStyle        = transitionDetails.TransitionStyle;
     m_TransitionLoop         = transitionDetails.TransitionLoop;
     m_VisibleAfterTransition = transitionDetails.VisibleAfterTransition;
 }
        private void CalculateTransitionPercent(ITransitionElement transitionElement, float percent)
        {
            ITransitionStatusControl transitionStatusControl = GetTransitionStatusControl(transitionElement);
            ITransitionDetails       transitionDetails       = GetTransitionDetails(transitionElement);

            if (transitionDetails.TransitionStyle.Contains(TransitionStyle.InOut))
            {
                transitionStatusControl.TransitionPercent = percent / 2 + transitionStatusControl.TransitionPercentBreak;
            }
            else
            {
                transitionStatusControl.TransitionPercent = percent;
            }
        }
        private IEnumerator PLayFadeAnimation(ITransitionElement transitionElement, float alphaStart, float alphaEnd)
        {
            ITransitionStatusControl transitionStatusControl = GetTransitionStatusControl(transitionElement);

            if (transitionStatusControl != null)
            {
                ITransitionDetails transitionDetails = GetTransitionDetails(transitionElement);
                float lerpValue = 0f;
                while (lerpValue <= 1f && transitionStatusControl.InTransition)
                {
                    lerpValue += Time.deltaTime / transitionDetails.TransitionDuration;
                    CalculateTransitionPercent(transitionElement, lerpValue);
                    transitionDetails.TransitionOverlay.alpha = Mathf.Lerp(alphaStart, alphaEnd, transitionDetails.Interpolation.Evaluate(lerpValue));
                    yield return(null);
                }
            }
        }
        private void EndTransition(ITransitionElement transitionElement, bool visible = false)
        {
            ITransitionDetails transitionDetails = GetTransitionDetails(transitionElement);

            if (transitionDetails.TransitionElementChild != null)
            {
                StopTransition(transitionDetails.TransitionElementChild);
            }

            if (!visible && !transitionDetails.VisibleAfterTransition)
            {
                SetTransitionCanvasEnable(transitionDetails.TransitionOverlay, false);
            }
            GetTransitionStatusControl(transitionElement).InTransition = false;
            this.PostNotification(TransitionElementNotificationName(transitionElement), transitionElement);
            m_TransitionTable.Remove(transitionElement);
        }
        private IEnumerator SetUpTransition(ITransitionElement transitionElement)
        {
            StartTransition(transitionElement);
            {
                ITransitionDetails transitionDetails = transitionElement.TransitionDetails;
                do
                {
                    GetTransitionStatusControl(transitionElement).TransitionPercentBreak = 0f;
                    switch (transitionDetails.TransitionStyle)
                    {
                    case TransitionStyle.In:
                    {
                        yield return(StartCoroutine(PLayFadeAnimation(transitionElement, true)));

                        break;
                    }

                    case TransitionStyle.Out:
                    {
                        yield return(StartCoroutine(PLayFadeAnimation(transitionElement, false)));

                        break;
                    }

                    case TransitionStyle.InOut:
                    {
                        yield return(StartCoroutine(PLayFadeAnimation(transitionElement, true)));

                        GetTransitionStatusControl(transitionElement).TransitionPercentBreak = 0.5f;
                        yield return(StartCoroutine(PLayFadeAnimation(transitionElement, false)));

                        break;
                    }

                    default:
                    {
                        break;
                    }
                    }
                } while (transitionDetails.TransitionLoop);
            }
            EndTransition(transitionElement);
        }
        public void PlayTransition(ITransitionElement transitionElement, Handler handler = null)
        {
            if (!m_TransitionTable.ContainsKey(transitionElement))
            {
                m_TransitionTable.Add(transitionElement, new TransitionStatusControl());
            }
            else
            {
                if (GetTransitionStatus(transitionElement).InTransition)
                {
                    Debug.LogWarning(
                        "[TransitionScene] Element '" + transitionElement.Name +
                        "' already is in transition. Wait for it to finished."
                        );
                    return;
                }
            }

            if (handler != null)
            {
                this.AddObserver(handler, TransitionElementNotificationName(transitionElement));
            }

            ITransitionStatusControl transitionStatusControl = GetTransitionStatusControl(transitionElement);

            if (transitionStatusControl != null)
            {
                transitionStatusControl.Coroutine = SetUpTransition(transitionElement);
                StartCoroutine(transitionStatusControl.Coroutine);
            }
            ITransitionDetails transitionDetails = GetTransitionDetails(transitionElement);

            if (transitionDetails.TransitionElementChild != null)
            {
                PlayTransition(transitionDetails.TransitionElementChild);
            }
        }