Esempio n. 1
0
        protected override IEnumerator AnimateTransitionOut(OnTransitionCompleted onTransitionCompleted)
        {
            float timeElapsed = 0.0f;

            if (!controller)
            {
                Debug.LogError($"[{name}] ExplodingPolygonController is not assigned. Out transition will be skipped.");

                timeElapsed = outAnimDuration + 1.0f;
            }

            // Enable the controller
            controller.gameObject.SetActive(true);
            // When transitioning out, we should flip the controller so the animation goes upwards
            controller.transform.Rotate(new Vector3(0.0f, 0.0f, 180.0f));
            controller.SetPositionToCamera();

            while (timeElapsed < outAnimDuration)
            {
                float t = outAnimCurve.Evaluate(timeElapsed / outAnimDuration);

                // We're going from empty to covered, thus the animation is reversed
                controller.SetAnimationProgress(1.0f - t);

                timeElapsed += Time.deltaTime;

                yield return(null);
            }

            // Snap to final position
            controller.SetAnimationProgress(0.0f);

            yield return(StartCoroutine(base.AnimateTransitionOut(onTransitionCompleted)));
        }
        protected virtual IEnumerator SwapScenes(SceneManagerController sceneManager,
                                                 SceneModel current, SceneModel desired)
        {
            yield return(SceneManager.LoadSceneAsync(desired.SceneName, LoadSceneMode.Single));

            OnTransitionCompleted.SafeInvoke(
                new SceneTransitionEventArgs(sceneManager, current, desired));

            swapperCoroutine = null;
        }
        /// <summary>
        /// <para>
        /// This function is called whenever the app is switching from another state to this.
        /// Base function must be called at the end of the override.
        /// </para>
        /// <example>At the end of the override function, call this:
        /// <code>
        /// yield return StartCoroutine(base.AnimateTransitionIn(onTransitionCompleted));
        /// </code>
        /// </example>
        /// </summary>
        /// <param name="onTransitionCompleted">Callback to be executed when transition is complete.</param>
        /// <returns>Animation <see cref="IEnumerator"/>.</returns>
        protected virtual IEnumerator AnimateTransitionIn(OnTransitionCompleted onTransitionCompleted)
        {
            // Set transition flag
            IsTransitioning = false;

            Debug.Log($"[{name}] In transition of {name} completed.");

            yield return(null);

            // Execute callbacks
            onTransitionCompleted?.Invoke();
            OnTransitionInCompleted?.Invoke();
        }
        /// <summary>
        /// This function will begin the exit transition for this state.
        /// It will not stop any running transitions, but it will log a warning if another transition is active.
        /// </summary>
        /// <param name="onTransitionCompleted">Callback to be executed when transition is complete.</param>
        public void TransitionOut(OnTransitionCompleted onTransitionCompleted = null)
        {
            if (IsTransitioning)
            {
                Debug.LogWarning($"[{name}] This state is attempting to transition out while a transition is already running. It may cause issues.");
            }

            transitionEnumerator = AnimateTransitionOut(onTransitionCompleted);
            IsTransitioning      = true;

            Debug.Log($"[{name}] Starting out transition of {name}.");

            OnTransitionOutStarted?.Invoke();

            StartCoroutine(transitionEnumerator);
        }
        /// <summary>
        /// <para>
        /// This function is called whenever the app is switching from this state to another.
        /// Base function must be called at the end of the override.
        /// </para>
        /// <example>At the end of the override function, call this:
        /// <code>
        /// yield return StartCoroutine(base.AnimateTransitionOut(onTransitionCompleted));
        /// </code>
        /// </example>
        /// </summary>
        /// <param name="onTransitionCompleted">Callback to be executed when transition is complete.</param>
        /// <returns>Animation <see cref="IEnumerator"/>.</returns>
        protected virtual IEnumerator AnimateTransitionOut(OnTransitionCompleted onTransitionCompleted)
        {
            // Set transition flag
            IsTransitioning = false;

            Debug.Log($"[{name}] Out transition of {name} completed.");

            yield return(null);

            // Execute callbacks
            onTransitionCompleted?.Invoke();
            OnTransitionOutCompleted?.Invoke();

            // Hide itself
            gameObject.SetActive(false);
        }
    private IEnumerator PerformTransition(OnTransitionCompleted a_TransitionCompletedMessage)
    {
        m_Value01Timer.Initialize (transitionTime);

        float l_StartValue = 0.0f;
        float l_TargetValue = 10.0f;

        while (m_Value01Timer.Value01 < 1.0f) {
            m_Value01Timer.Progress (Time.deltaTime);
            float l_ComputedValue = m_TransitionDelegate (l_StartValue, l_TargetValue, m_Value01Timer.Value01);
            Debug.Log (l_ComputedValue);
            yield return (null);
        }

        a_TransitionCompletedMessage ();
    }
Esempio n. 7
0
    private void ClearUp()
    {
        if (Instance == null)
        {
            return;
        }

        OnTransitionCompleted?.Invoke();

        OnTransitionStarted   = null;
        OnTransitionCompleted = null;

        m_dst = -1;

        m_transitionCamera.enabled = false;
    }
        protected virtual IEnumerator SwapScenes(SceneManagerController sceneManager,
                                                 SceneModel current, SceneModel desired)
        {
            float progressModifier = current == null ? 1f : 0.5f;

            yield return(LoadAdditiveSceneAsync(desired, progressModifier));

            if (current != null)
            {
                yield return(UnloadSceneAsync(current, 2f));
            }

            OnTransitionCompleted.SafeInvoke(
                new SceneTransitionEventArgs(sceneManager, current, desired));

            swapperCoroutine = null;
        }
Esempio n. 9
0
    private IEnumerator GotoCreateAccount()
    {
        float val = 0.0f;

        while (Mathf.Approximately(val, 1.0f) == false)
        {
            val = Mathf.MoveTowards(val, 1.0f, transitionSpeed * Time.deltaTime);
            for (int i = 0; i < forms.Length; i++)
            {
                forms[i].Execute(val);
            }

            yield return(null);
        }

        OnTransitionCompleted?.Invoke();
        RaycastBlocker.Unblock();
    }
Esempio n. 10
0
        /// <summary>
        /// This function will begin the entrance transition for this state.
        /// It will not stop any running transitions, but it will log a warning if another transition is active.
        /// </summary>
        /// <param name="onTransitionCompleted">Callback to be executed when transition is complete.</param>
        public void TransitionIn(OnTransitionCompleted onTransitionCompleted = null)
        {
            if (IsTransitioning)
            {
                Debug.LogWarning($"[{name}] This state is attempting to transition in while a transition is already running. It may cause issues.");
            }

            // Show itself
            gameObject.SetActive(true);

            transitionEnumerator = AnimateTransitionIn(onTransitionCompleted);
            IsTransitioning      = true;

            Debug.Log($"[{name}] Starting in transition of {name}.");

            OnTransitionInStarted?.Invoke();

            StartCoroutine(transitionEnumerator);
        }
Esempio n. 11
0
        private IEnumerator DoTransition(mg_jr_Penguin _penguin, OnTransitionCompleted _completionCallback)
        {
            Assert.NotNull(_penguin, "Penguin must be provided");
            Minigame miniGame = MinigameManager.GetActive();

            miniGame.PlaySFX(mg_jr_Sound.UI_TURBO_MODE_START.ClipName());
            m_speedLineFX.StartLines(mg_jr_SpeedLineScreenFx.LineStartMode.RANDOM_POSITION);
            _penguin.StartTransition();
            miniGame.PlaySFX(mg_jr_Sound.PLAYER_EXPLODE.ClipName());
            yield return(StartCoroutine(FlashWhite(0.1f)));

            yield return(new WaitForSeconds(2f));

            yield return(StartCoroutine(FlashWhite(0.1f)));

            _penguin.EndTransition();
            m_speedLineFX.StopLinesImmediately();
            miniGame.PlaySFX(mg_jr_Sound.UI_TURBO_MODE_END.ClipName());
            base.gameObject.SetActive(value: false);
            _completionCallback?.Invoke();
        }
        protected override IEnumerator AnimateTransitionIn(OnTransitionCompleted onTransitionCompleted)
        {
            float timeElapsed = 0.0f;

            while (timeElapsed < inAnimDuration)
            {
                // Reverse the animation
                float t = inAnimCurve.Evaluate((inAnimDuration - timeElapsed) / inAnimDuration);

                transform.localPosition = Vector3.LerpUnclamped(originalPosition, originalPosition + endingOffset, t);
                transform.localScale    = Vector3.LerpUnclamped(originalScale, Vector3.zero, t);

                timeElapsed += Time.deltaTime;

                yield return(null);
            }

            transform.localPosition = originalPosition;
            transform.localScale    = originalScale;

            yield return(StartCoroutine(base.AnimateTransitionIn(onTransitionCompleted)));
        }
Esempio n. 13
0
        protected override IEnumerator AnimateTransitionIn(OnTransitionCompleted onTransitionCompleted)
        {
            float timeElapsed = 0.0f;

            if (!controller)
            {
                Debug.LogError($"[{name}] ExplodingPolygonController is not assigned. In transition will be skipped.");

                timeElapsed = inAnimDuration + 1.0f;
            }

            // Enable the controller
            controller.gameObject.SetActive(true);
            // When transitioning in, we should flip the controller again so the animation is in the same orientation
            controller.transform.Rotate(new Vector3(0.0f, 0.0f, 180.0f));
            controller.SetPositionToCamera();

            while (timeElapsed < inAnimDuration)
            {
                float t = inAnimCurve.Evaluate((timeElapsed) / inAnimDuration);

                // We're going from covered to empty
                controller.SetAnimationProgress(t);

                timeElapsed += Time.deltaTime;

                yield return(null);
            }

            // Snap to final position
            controller.SetAnimationProgress(1.0f);
            // Disable the controller
            controller.gameObject.SetActive(false);

            yield return(StartCoroutine(base.AnimateTransitionIn(onTransitionCompleted)));
        }
        /// <inheritdoc />
        public async Task DoSceneTransition(IEnumerable <Func <Task> > sceneOperations, IProgressIndicator progressIndicator = null)
        {
            if (TransitionInProgress)
            {
                throw new Exception("Attempting to do a transition while one is already in progress.");
            }

            #region Transition begin

            TransitionInProgress = true;
            OnTransitionStarted?.Invoke();

            if (progressIndicator == null && sceneTransitionServiceProfile.UseDefaultProgressIndicator)
            {   // If we haven't been given a progress indicator, and we're supposed to use a default
                // find / create the default progress indicator
                CreateDefaultProgressIndicator();
                progressIndicator = defaultProgressIndicator;
            }

            if (UseFadeColor)
            {
                await FadeOut();
            }

            if (progressIndicator != null)
            {
                await progressIndicator.OpenAsync();
            }

            #endregion

            #region Task execution

            // Make sure we're on the main thread

            foreach (Func <Task> sceneOperation in sceneOperations)
            {
                await sceneOperation();
            }

            #endregion

            #region Transition end

            // If we used a progress indicator, close it
            if (progressIndicator != null)
            {
                await progressIndicator.CloseAsync();
            }


            if (UseFadeColor)
            {
                await FadeIn();
            }

            TransitionInProgress = false;
            OnTransitionCompleted?.Invoke();

            #endregion
        }
Esempio n. 15
0
 public void Transition(mg_jr_Penguin _penguin, OnTransitionCompleted _completionCallback)
 {
     base.gameObject.SetActive(value: true);
     StartCoroutine(DoTransition(_penguin, _completionCallback));
 }
Esempio n. 16
0
 public void CompleteTask()
 {
     OnTransitionCompleted?.Invoke();
 }