Esempio n. 1
0
 private void OnCollisionEnter(Collision collision)
 {
     if (!collision.gameObject.CompareTag("EnemyShot"))
     {
         ExplosionSoundScript.playShotSound();
         if (collision.gameObject.CompareTag("PlayerShot"))
         {
             PlayerPrefs.SetInt("PlayerScore", PlayerPrefs.GetInt("PlayerScore") + score);
         }
         Destroy(gameObject);
     }
 }
Esempio n. 2
0
 private void OnCollisionEnter(Collision collision)
 {
     if (Time.time > nextHit && collision.gameObject.CompareTag("PlayerShot"))
     {
         nextHit = Time.time + hitRate;
         health--;
         if (health <= 0)
         {
             ExplosionSoundScript.playShotSound();
             PlayerPrefs.SetInt("PlayerScore", PlayerPrefs.GetInt("PlayerScore") + score);
             Destroy(gameObject);
         }
     }
 }
Esempio n. 3
0
 private void OnCollisionEnter(Collision collision)
 {
     print("Here");
     print(collision.gameObject);
     if (Time.time > nextHit && (collision.gameObject.CompareTag("EnemyShot") || collision.gameObject.CompareTag("Missile")))
     {
         nextHit = Time.time + hitRate;
         flashOn = true;
         health--;
         healthDisplay.GetComponent <Text>().text = health.ToString() + " HP";
         if (health <= 0)
         {
             ExplosionSoundScript.playShotSound();
             SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
         }
     }
 }