You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace Unity.Multiplayer.Samples.BossRoom
|
|
{
|
|
|
|
public class AbilityUI : MonoBehaviour
|
|
{
|
|
public string key;
|
|
public Image CoolDownImg;
|
|
public IEnumerator StopWatchRoutine;
|
|
public void StopWatchFiller(float coolDownTime)
|
|
{
|
|
if (StopWatchRoutine == null)
|
|
{
|
|
StopWatchRoutine = StopWatchFillerRoutine(coolDownTime);
|
|
StartCoroutine(StopWatchRoutine);
|
|
}
|
|
else
|
|
{
|
|
StopCoroutine(StopWatchRoutine);
|
|
StopWatchRoutine = StopWatchFillerRoutine(coolDownTime);
|
|
StartCoroutine(StopWatchRoutine);
|
|
}
|
|
}
|
|
public IEnumerator StopWatchFillerRoutine(float coolDownTime)
|
|
{
|
|
float factor = coolDownTime;
|
|
CoolDownImg.gameObject.SetActive(true);
|
|
CoolDownImg.fillAmount = 1;
|
|
while (coolDownTime > 0)
|
|
{
|
|
coolDownTime -= Time.deltaTime;
|
|
CoolDownImg.fillAmount = coolDownTime / factor;
|
|
yield return new WaitForSeconds(Time.deltaTime);
|
|
}
|
|
CoolDownImg.gameObject.SetActive(false);
|
|
StopWatchRoutine = null;
|
|
}
|
|
}
|
|
}
|