Example #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();
        }