Exemple #1
0
 /// <summary>
 /// Subtracts the given value from health and triggers death if health reaches 0
 /// </summary>
 /// <param name="damage">Value to be subtracted</param>
 public void ApplyDamage(float damage)
 {
     health -= damage;
     if (health <= 0)
     {
         StartDeath();
         healthBar?.SetHealth(0);
     }
     else
     {
         healthBar?.SetHealth(health);
     }
 }
Exemple #2
0
 //updates UI
 private void HealthChange(object sender, HealthController.OnHealthChangeEventArgs e)
 {
     if (healthUI)
     {
         healthUI.SetHealth(e.currentHealth);
     }
 }
    public void LoseHealth()
    {
        if ((health != 0) && (remainingInvincibility <= 0.0f))
        {
            healthBar.SetHealth(--health);

            if (health == 0)
            {
                GameMode.Instance.OnPlayerDeath();
            }
            else
            {
                StartInvincibility();
            }
        }
    }
Exemple #4
0
    void CheckHP()
    {
        HPBar.SetHealth(CurrentHP);

        if (CurrentHP <= 0)
        {
            Dies();
        }

        else
        {
            return;
        }
    }
    public void UpdateDynamicAttributesUI(DynamicAttributeContainer container)
    {
        foreach (var attribute in container.dynamicAttributes)
        {
            if (attribute.dynamicType == DynamicAttributeType.Health)
            {
                healthBar.SetHealth(attribute.currentValue);
                healthBar.SetMaxHealth(attribute.maxValue);
            }

            if (attribute.dynamicType == DynamicAttributeType.Mana)
            {
                manaBar.SetCurrentMana(attribute.currentValue);
                manaBar.SetMaxMana(attribute.maxValue);
            }

            if (attribute.dynamicType == DynamicAttributeType.Coin)
            {
                coinUI.SetValue(attribute.currentValue);
            }
        }
    }
Exemple #6
0
 void Update()
 {
     healthBar.SetHealth(currentHealth);
     currentInvincibilityFrames -= Time.deltaTime;                //invFrames updater
 }