55 lines
1.5 KiB
C#
55 lines
1.5 KiB
C#
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;
|
|
[SerializeField] Button skillbutton;
|
|
[SerializeField] Image skillImage;
|
|
[SerializeField] int cooldownTime;
|
|
|
|
private void Awake()
|
|
{
|
|
skillbutton.onClick.AddListener(Execute);
|
|
}
|
|
public void SetDataPtr(CECShortcut pvData, string strName)
|
|
{
|
|
pSC = pvData;
|
|
}
|
|
public void Execute()
|
|
{
|
|
if (pSC != null)
|
|
{
|
|
pSC.Execute();
|
|
// TODO: FIXlater - get cooldown time from skill data
|
|
StartCoroutine(CooldownRoutine());
|
|
}
|
|
}
|
|
public void SetSkillImage(Sprite sprite)
|
|
{
|
|
skillImage.sprite = sprite;
|
|
}
|
|
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;
|
|
}
|
|
}
|
|
}
|