35 lines
959 B
C#

using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;
public class AbilitySlotUI : MonoBehaviour
{
public AbilityInput bar;
public int slotIndex = 0;
[Header("UI")]
public Image iconImage;
public Image cooldownMask; // Image.type = Filled, Fill Method = Radial 360
void Start()
{
var slot = bar?.slots?[slotIndex];
if (slot != null && slot.ability && iconImage)
iconImage.sprite = slot.ability.icon;
if (cooldownMask) cooldownMask.fillAmount = 0f;
}
void Update()
{
var slot = bar?.slots?[slotIndex];
if (slot == null || slot.ability == null || cooldownMask == null) return;
float target = slot.CooldownRatio; // 0..1
// Tween a bit for smoothness
cooldownMask.DOKill();
cooldownMask.DOFillAmount(target, 0.1f);
}
// Optional: hook this to a UI Button to trigger
public void ClickUse() => bar?.Use(slotIndex);
}