Ejemplo n.º 1
0
        public void TakeDamage(int amount)
        {
            // Set the damaged flag so the screen will flash.
            damaged = true;

            // Reduce the current health by the damage amount.
            currentHealth -= amount;


            healthSlider.value = currentHealth;
            // Play the hurt sound effect.
            playerAudio.Play();
            if (particleHits == null)
            {
                Debug.Log("Player hits!");
            }
            particleHits.Play();

            // If the player has lost all it's health and the death flag hasn't been set yet...
            if (currentHealth <= 0 && !isDead)
            {
                // ... it should die.
                /*Death();*/
                stateMachine.DeathState();
            }
        }