예제 #1
0
        protected IEnumerator RespawnRoutine()
        {
            // Wait for the animator to be transitioning from the EllenDeath state.
            while (m_CurrentStateInfo.shortNameHash != m_HashEllenDeath || !m_IsAnimatorTransitioning)
            {
                yield return(null);
            }

            // Wait for the screen to fade out.
            yield return(StartCoroutine(ScreenFader.FadeSceneOut()));

            while (ScreenFader.IsFading)
            {
                yield return(null);
            }

            // Enable spawning.
            BaseSpawn spawn = GetComponentInChildren <BaseSpawn>();

            spawn.enabled = true;

            // If there is a checkpoint, move Ellen to it.
            if (m_CurrentCheckpoint != null)
            {
                transform.position = m_CurrentCheckpoint.transform.position;
                transform.rotation = m_CurrentCheckpoint.transform.rotation;
            }
            else
            {
                Debug.LogError("There is no Checkpoint set, there should always be a checkpoint set. Did you add a checkpoint at the spawn?");
            }

            // Set the Respawn parameter of the animator.
            m_Animator.SetTrigger(m_HashRespawn);

            // Start the respawn graphic effects.
            spawn.Respawn();

            // Wait for the screen to fade in.
            // Currently it is not important to yield here but should some changes occur that require waiting until a respawn has finished this will be required.
            yield return(StartCoroutine(ScreenFader.FadeSceneIn()));

            m_Damageable.ResetDamage();
        }
예제 #2
0
        protected IEnumerator Transition(string newSceneName, SceneTransitionDestination.DestinationTag destinationTag, TransitionPoint.TransitionType transitionType = TransitionPoint.TransitionType.DifferentZone)
        {
            m_Transitioning = true;
            // PersistentDataManager.SaveAllData();

            if (m_PlayerInput == null)
            {
                m_PlayerInput = FindObjectOfType <PlayerInput>();
            }
            if (m_PlayerInput)
            {
                m_PlayerInput.ReleaseControl();
            }
            yield return(StartCoroutine(ScreenFader.FadeSceneOut(ScreenFader.FadeType.Loading)));

            // PersistentDataManager.ClearPersisters();
            yield return(SceneManager.LoadSceneAsync(newSceneName));

            m_PlayerInput = FindObjectOfType <PlayerInput>();
            if (m_PlayerInput)
            {
                m_PlayerInput.ReleaseControl();
            }
            // PersistentDataManager.LoadAllData();
            SceneTransitionDestination entrance = GetDestination(destinationTag);

            SetEnteringGameObjectLocation(entrance);
            SetupNewScene(transitionType, entrance);
            if (entrance != null)
            {
                entrance.OnReachDestination.Invoke();
            }
            yield return(StartCoroutine(ScreenFader.FadeSceneIn()));

            if (m_PlayerInput)
            {
                m_PlayerInput.GainControl();
            }

            m_Transitioning = false;
        }