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; } } }