예제 #1
0
 public void playerDeath(bool playAnimation = false)
 {
     DeathSource.Play();
     //insert player death animation here
     myAnimator.SetBool("dead", true);
     UnityStandardAssets._2D.LevelManager levelManager = FindObjectOfType <UnityStandardAssets._2D.LevelManager>();
     lives--;
     if (lives == 0)
     {
         PlayerPrefs.DeleteKey("Lives");
         PlayerPrefs.DeleteKey("Health");
         enabled = false;             //disables player control
         levelManager.GameOver();
     }
     else
     {
         if (playAnimation)
         {
             guitar.SetActive(false);
             myRigidbody.velocity = new Vector3(0, 0, 0);
             levelManager.Invoke("RespawnPlayer", 1.0f);
         }
         else
         {
             levelManager.RespawnPlayer();
         }
     }
 }