Пример #1
0
    //Moves the player to the respawn position.
    //Resets the player's health and give the player control over the player character again.
    //Resets/respawns all enemies in the current area.
    public void Respawn()
    {
        transform.position  = RespawnPoint;
        m_deathFadeOutTimer = m_deathFadeOutTime;

        Dead              = false;
        m_hasDropped      = false;
        HasDroppedTrigger = false;

        m_health = m_maxHealth;
        UpdateHealthDisplay();

        if (Rp != null)
        {
            Rp.ResetEnemies();
        }

        if (m_playerAnimator != null)
        {
            m_playerAnimator.SetTrigger("Respawn");
        }

        if (m_dieParticleSystem != null)
        {
            m_dieParticleSystem.Stop();
            m_dieParticleSystem.Clear();
        }

        //if (m_camAnimator != null)
        //    m_camAnimator.PlayerRespawn();
        //else
        if (m_UIManager != null)
        {
            m_UIManager.RespawnFade();
        }

        GetComponent <NavMeshAgent>().enabled = true;

        if (m_input != null)
        {
            if (m_input.WeapCont != null)
            {
                m_input.WeapCont.InstantReload();
                if (m_input.AmmoCont != null)
                {
                    for (int i = 0; i < m_input.WeapCont.EquippedGun.CurrentClip; i++)
                    {
                        m_input.AmmoCont.Reload();
                    }
                }
            }
            m_input.EndRoll();
        }
    }