public void IncreaseEnergy(float amount, bool percent = false) { float newEnergy = (percent ? energy + maxEnergy * (amount / 100f) : energy + amount); energy = Mathf.Clamp(newEnergy, 0, maxEnergy); abilityManager.UpdateAbilityButtons(); StartCoroutine(energyBar.FillAmount(energy / maxEnergy, false)); }
public override void Start() { healthBar = UIManager.I.healthBar; energyBar = UIManager.I.energyBar; attributes = GameManager.I.attributes; health = baseHealth + baseHealth * GameManager.I.costHolder.GetStatAsMultiplier(AttributeType.HEALTH); base.Start(); facingDirection = Vector2.down; if (abilityManager == null) { abilityManager = GetComponentInChildren <AbilityManager>(); } speed = normalSpeed; soundController = GetComponent <SoundController>(); path = GetComponent <Pathfinding.AIPath>(); MoveToPosition((Vector2)transform.position + Vector2.down * 3); energyBar.BuildHealtBar(maxEnergy, false); StartCoroutine(energyBar.FillAmount(energy / maxEnergy, false)); }
public bool TakeDamage(float damage) { UIManager.I.ShowHitDamage(GetComponentInChildren <Canvas>(), 1, damage); if ((health -= damage) <= 0) { Die(); return(true); } StartCoroutine(healthBar.FillAmount(health / maxHealth, true)); return(true); }