예제 #1
0
    void Death()
    {
        // Set the death flag so this function won't be called again.
        isDead = true;

        GameObject.FindGameObjectWithTag("Sound").GetComponent <SoundScript>().NormalMusic();
        // Change the deathText color to dark red
        deathText.color = deathTextColor;

        // Set the audiosource to play the death clip and play it (this will stop the hurt sound from playing).
        //playerAudio.clip = deathClip;
        //playerAudio.Play ();

        // Turn off the movement and shooting scripts -- for our project we should figure out something comperable
        //playerMovement.enabled = false;
        //playerShooting.enabled = false;
        fill.color = Color.Lerp(damageImage.color, Color.clear, flashSpeed * Time.deltaTime);
        Debug.Log("You died!");

        // checks to see if the player got a new high score
        ScoreScript scoreScript = GameObject.FindGameObjectWithTag("Score").GetComponent <ScoreScript>();

        scoreScript.CheckScore();

        Debug.Log("enabling death menu");
        // Ask if they would like to start again or quit


        if (!scoreScript.IsNewHighScore())
        {
            deathMenu.SetActive(true);
        }

        else
        {
        }
    }