Пример #1
0
 /// <summary>
 /// When the player has lost all health and dies
 /// </summary>
 public void Die()
 {
     SoundEffectBoard.PlayDeathSound();
     Instantiate(blowUp, transform.position, transform.rotation); // spawning the blewUp particle effect
     gameOverText.gameObject.SetActive(true);                     // showing the Game Over text
     Destroy(gameObject);                                         // destroy player
 }
Пример #2
0
        /// <summary>
        /// When the object has been damaged
        /// </summary>
        /// <param name="damage"></param>
        public void DamageTaken(float damage)
        {
            health -= damage; // takes health away from damage

            CurrentHealth();  // sets the health for the health bar

            if (health <= 0)
            {
                Destroy(this.gameObject, 3);       // destroys the game object in 3 seconds
                SoundEffectBoard.PlayDeathSound(); // plays the deathSound
            }
        }