using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Unity.VisualScripting; using UnityEngine; using UnityEngine.UI; namespace BrewMonster.Assets.PerfectWorld.Scripts.UI.GamePlay { public class AUIImagePicture : MonoBehaviour { CECShortcut pSC; [Header("AUIImagePicture")] [SerializeField] Button skillbutton; [SerializeField] protected Image skillImage; [SerializeField] GameObject borderImage; [SerializeField] int cooldownTime; [SerializeField] AUIClockIcon m_ClockCounter; private void Awake() { if (skillbutton == null) { Debug.LogError("Skill Button is not assigned in AUIImagePicture"); } skillbutton.onClick.AddListener(Execute); } public void SetDataPtr(CECShortcut pvData, string strName) { pSC = pvData; } public void Execute() { if (pSC != null) { pSC.Execute(); StartCoroutine(CooldownRoutine()); } else { EventBus.Publish(new OpenSkillUIEvent()); } } public void SetImage(Sprite sprite) { if(skillImage == null) { Debug.LogError("Skill Image is not assigned in AUIImagePicture"); return; } skillImage.sprite = sprite; if(borderImage != null) borderImage.SetActive(true); } private IEnumerator CooldownRoutine() { // Disable interaction skillbutton.interactable = false; // Set gray skillImage.color = Color.gray; // Wait yield return new WaitForSeconds(cooldownTime); // Restore skillImage.color = Color.white; skillbutton.interactable = true; } public AUIClockIcon GetClockIcon() => m_ClockCounter; } public struct OpenSkillUIEvent { } }