示例#1
0
 // Update is called once per frame
 void Update()
 {
     if (health <= 0)
     {
         score.AddScore(scoreValue);
         if (scoreValue == 0)
         {
             score.scoreIncreasing = false;
         }
         if (transform.gameObject.tag == "Player" && gameOver != null && mainGame != null)
         {
             gameOver.SetActive(true);
             mainGame.SetActive(false);
         }
         if (transform.gameObject.tag == "Enemy")
         {
             PlayerPrefs.SetInt("Kills", PlayerPrefs.GetInt("Kills") + 1);
         }
         if (gameObject.transform.parent == null)
         {
             Destroy(gameObject);
         }
         else
         {
             Destroy(gameObject.transform.parent.gameObject);
         }
     }
 }
示例#2
0
 // Update is called once per frame
 void Update()
 {
     if (!isLocalPlayer)
     {
         return;
     }
     if (health <= 0)
     {
         score.AddScore(scoreValue);
         if (scoreValue == 0)
         {
             score.scoreIncreasing = false;
         }
         if (transform.gameObject.tag == "Player" && gameOver != null && mainGame != null)
         {
             gameOver.SetActive(true);
             mainGame.SetActive(false);
         }
         if (gameObject.transform.parent == null)
         {
             Destroy(gameObject);
         }
         else
         {
             if (gameObject.transform.parent.gameObject.tag == "Player")
             {
                 Destroy(gameObject.transform.parent.gameObject);
             }
         }
     }
 }
示例#3
0
 void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.tag == "Player")
     {
         score.AddScore(coinValue);
         Destroy(gameObject);
     }
 }