PlayerSfxScript.playDeathSound C# (CSharp) Method

playDeathSound() public static method

public static playDeathSound ( ) : void
return void
    public static void playDeathSound()
    {
        instance.sound.PlayOneShot(instance.deathSound);
    }

Usage Example

Ejemplo n.º 1
0
    public void TakeDamage(int amount)
    {
        // Reduce the current health by the amount of damage sustained.
        currentHealth -= amount;

        if (amount != 0)
        {
            hasTakenDamage = true;
            dmgTimer       = secDamage;
        }

        // Update health on slider to new value.
        healthSlider.value = currentHealth;

        // It there is no health left.
        if (currentHealth <= 0)
        {
            // Play sound, animate and destroy object.
            PlayerSfxScript.playDeathSound();
            playerControlScript.InitiateAnimation("Die");
            Destroy(gameObject, 0.95f);
        }
        else
        {
            // Play sound and animate.
            PlayerSfxScript.playHitSound();
            playerControlScript.InitiateAnimation("Hit");
        }
    }