Example #1
0
 private void DamageEnemy()
 {
     if (lives > 0)
     {
         lives--;
     }
     if (lives <= 0)
     {
         SpawnManagerBehavior spawnManager = GameObject.FindGameObjectWithTag("SpawnManager").GetComponent <SpawnManagerBehavior>();
         spawnManager.UpdateDestroyedEnemies();
         Instantiate(_death, this.transform.position, Quaternion.identity);
         Destroy(this.gameObject);
     }
 }
Example #2
0
 public void DamagePlayer()
 {
     if (!_shieldEnabled)
     {
         if (_lives > 0)
         {//if the player has more than 0 lives, play the damaged noise and subtract a life
             AudioSource.PlayClipAtPoint(_damagedSound, new Vector3(0, 0, -10));
             _lives--;
             uim.UpdateLives(_lives);
         }
         if (_lives == 0)
         {//if lives are 0, destroy player game object and play the player death noise
             uim.UpdateLives(_lives);
             AudioSource.PlayClipAtPoint(_playerDeath, new Vector3(0, 0, -10));
             SpawnManagerBehavior sm = GameObject.Find("SpawnManager").GetComponent <SpawnManagerBehavior>();
             sm.EndGame();
             this.gameObject.SetActive(false);
         }
     }
 }
Example #3
0
 private void DamageEnemy()
 {
     if (_lives > 0)
     {
         _lives--;
     }
     if (_lives <= 0)
     {
         SpawnManagerBehavior spawnManager = GameObject.FindGameObjectWithTag("SpawnManager").GetComponent <SpawnManagerBehavior>();
         spawnManager.UpdateDestroyedEnemies();
         Instantiate(_death, this.transform.position, Quaternion.identity);
         Instantiate(_death, this.transform.position + new Vector3(-.5f, .5f, 0), Quaternion.identity);
         Instantiate(_death, this.transform.position + new Vector3(.5f, -.5f, 0), Quaternion.identity);
         Instantiate(_death, this.transform.position + new Vector3(-.5f, -.5f, 0), Quaternion.identity);
         Instantiate(_death, this.transform.position + new Vector3(.5f, .5f, 0), Quaternion.identity);
         SpawnManagerBehavior sm = GameObject.Find("SpawnManager").GetComponent <SpawnManagerBehavior>();
         sm.NextLevel();
         Destroy(this.gameObject);
     }
 }