Ejemplo n.º 1
0
    public void TakeDamage(int amount)
    {
        if (amount != 0)
        {
            audS.PlayOneShot(audio_takedamage, 0.01f);
        }

        long now = Convert.ToInt64((DateTime.Now - epoch).TotalMilliseconds);

        if (msec + 500 > now)
        {
            return;
        }

        msec           = now;
        currentHealth -= amount;

        if (currentHealth < 0)
        {
            if (livesLeft.DecreaseLives())
            {
                ResetHealth();
                levelManager.RespawnPlayer();
            }
            else
            {
                Death();
            }
        }
        healthSlider.value = currentHealth;
    }