Project_WL/Assets/Script/UI/Base/CardCoolTimeBase.cs

53 lines
1.4 KiB
C#
Raw Normal View History

2024-12-15 01:39:39 +00:00
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class CardCoolTimeBase : CardBase
{
public GameObject go_canuse;
public Image sprite_cooltime;
public TextMeshProUGUI label_cooltime;
protected bool ShowCoolTimeFlash;
protected float m_CoolTime, m_CoolTimeMax;
protected int m_Index;
protected void CoolTime_Off()
{
if (go_canuse.activeInHierarchy) go_canuse.SetActive(false);
m_CoolTime = m_CoolTimeMax = sprite_cooltime.fillAmount = 0f;
label_cooltime.text = "";
ShowCoolTimeFlash = false;
}
public void Set_CoolTime(float _time, float _maxtime, int _index)
{
m_CoolTime = _time;
m_CoolTimeMax = _maxtime;
m_Index = _index;
Set_CoolTimeText();
if (m_CoolTime <= 0f && !ShowCoolTimeFlash)
{
ShowCoolTimeFlash = true;
go_canuse.SetActive(true);
Set_Coroutine_withCancel(() => { go_canuse.SetActive(false); }, 0.3f);
}
}
protected void Set_CoolTimeText()
{
if (m_CoolTime > 0f)
{
label_cooltime.text = m_CoolTime.ToString("N0");
float v = m_CoolTime / m_CoolTimeMax;
sprite_cooltime.fillAmount = v;
if (m_CoolTime / m_CoolTimeMax < 0.9f)
ShowCoolTimeFlash = false;
}
else
{
label_cooltime.text = "";
sprite_cooltime.fillAmount = 0f;
}
}
}