private Image image;
int number;
public float cooldown=2;
float startTime;
private void Awake()
{
number = int.Parse ( this.name);
image = this.transform.GetChild(0).GetComponent<Image>();
image.fillAmount = 0f;
SkillTime.instanceSkill += SkillCooldown;
}
bool IsSkill = true ;
private void SkillCooldown(int index)
{
if(index ==number && IsSkill)
{
StartCoroutine(CooldownSkill());
}
}
private IEnumerator CooldownSkill()
{
float a = 0;
startTime = Time.time;
image.fillAmount = 1;
IsSkill = false;
float temp = cooldown;
while (image.fillAmount > 0 )
{
a += Time.deltaTime;
image.fillAmount = 1-(a/2);
yield return null ;
}
IsSkill = true;
yield return null;
}
協程倒計時
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.