Пример #1
0
    private void DamageUpdate()
    {
        if (!startTakingDamage)
        {
            return;
        }

        //  Update amount of health by which to decrease
        if (startTakingDamage)
        {
            currentHealthDecrease += healthDecrementRate * Time.deltaTime;;
            if (currentHealthDecrease >= 1.0f)
            {
                currentHealthDecrease -= 1.0f;
                currentHealth         -= 1;
            }
            else
            {
                GameAudioController.playBuzz();
            }
        }

        //  Update slider
        if (currentHealth != healthbar.GetSliderValue())
        {
            healthbar.SetHealth(currentHealth);
            AudioManager.Instance.StopSfx();
            GameAudioController.playHurt();
        }

        //  Update isAlive
        if (currentHealth == 0)
        {
            isAlive = false;
        }
    }