public virtual void Initialize()
 {
     Health    = _unit.UnitData.MaxHealth;
     MaxHealth = Health;
     OnCurrentHealthChanged?.Invoke(Health);
     OnMaxHealthChanged?.Invoke(MaxHealth);
 }
Exemplo n.º 2
0
    public void ChangeMaxHealth(int newMaxHealth)
    {
        maxHealth = newMaxHealth;
        int exessHealth = currentHealth - maxHealth;

        if (currentHealth < maxHealth)
        {
            currentHealth = maxHealth;
        }
        OnMaxHealthChanged?.Invoke(this, new OnMaxHealthChangedArgs {
            excessHealth = exessHealth
        });
    }
Exemplo n.º 3
0
 public void SetMaxHealth(float value)
 {
     maxHealth     = Mathf.Clamp(value, 0, float.MaxValue);
     currentHealth = Mathf.Clamp(currentHealth, 0, maxHealth);
     OnMaxHealthChanged?.Invoke(maxHealth);
 }