Exemplo n.º 1
0
    void DoPlayerDeath(DeathType deathtype)
    {
        if (isDead)
        {
            return;
        }

        if (deathtype == DeathType.Pierce)
        {
            SetState(PlayerState.DeadImpaled);
        }
        else
        {
            SetState(PlayerState.Dead);
        }

        // Send HUD info so it can dim and red the screen.
        if (gameHUD)
        {
            gameHUD.DoPlayerDeath(deathtype);
        }

        // Used for allowing the camera to free rotate if we're falling forever.
        m_diedFromFall = deathtype == DeathType.Fall;

        /*if (deathtype != DeathType.Fall)
         *      resetGravity(true);*/

        // All sorts of different sounds depending on how we died!
        AudioClip[] sounds;
        if (deathtype == DeathType.Pierce)
        {
            sounds = deathSoundImpaled;
        }
        else if (deathtype == DeathType.Fall)
        {
            sounds = deathSoundFall;
        }
        else
        {
            sounds = deathSound;
        }

        if (sounds.Length > 0)
        {
            GetComponent <AudioSource>().PlayOneShot(UtilRandom.RandomFromArray(sounds) as AudioClip, 1.0f);
        }
    }