37 lines
878 B
C#
37 lines
878 B
C#
using System;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
public class AbilityHotbarIcon : MonoBehaviour
|
|
{
|
|
[SerializeField] private Transform cooldownBar;
|
|
[SerializeField] private TextMeshProUGUI text;
|
|
private bool onCooldown;
|
|
private PlayerAbility thisAbility;
|
|
|
|
private void Update()
|
|
{
|
|
if (onCooldown)
|
|
{
|
|
cooldownBar.localScale = new Vector3(Math.Clamp(1 - thisAbility.currentCooldown/thisAbility.cooldown, 0, 1), 1, 1);
|
|
if (thisAbility.currentCooldown <= 0)
|
|
{
|
|
onCooldown = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void UpdateCooldown()
|
|
{
|
|
if (thisAbility.currentCooldown > 0)
|
|
{
|
|
onCooldown = true;
|
|
}
|
|
}
|
|
|
|
public void UpdateAbility(PlayerAbility ability)
|
|
{
|
|
thisAbility = ability;
|
|
text.text = thisAbility.abilityName;
|
|
}
|
|
}
|