using asap.core; using System; using System.Collections; using UnityEngine; using UnityEngine.UI; using UniRx; using DG.Tweening; public class UISkillShow { public int type; public float chargingTime; public float executeTime; public bool isStart; } public class FishingPanelIconFish : MonoBehaviour { public Image icon; public Image icon_bar; public GameObject fx_sp; public GameObject fx_escape; public GameObject fx_fishingpanel_fishboss_glowdown; IDisposable icon_bar_disposable; private void OnEnable() { fx_sp.SetActive(false); fx_escape.SetActive(false); fx_fishingpanel_fishboss_glowdown.SetActive(false); Init(); icon_bar_disposable = GContext.OnEvent().Subscribe(OnUISkillShow); } void Init() { StopAllCoroutines(); fx_fishingpanel_fishboss_glowdown.SetActive(false); fx_sp.SetActive(false); fx_escape.SetActive(false); icon_bar.DOKill(); icon_bar.fillAmount = 0; } void OnUISkillShow(UISkillShow uISkillShow) { Init(); if (uISkillShow.isStart) { StartCoroutine(StartSkill(uISkillShow.chargingTime, uISkillShow.executeTime, uISkillShow.type)); } } IEnumerator StartSkill(float time, float executeTime, int type) { icon_bar.DOFillAmount(1, time); yield return new WaitForSeconds(time); icon_bar.DOKill(); icon_bar.fillAmount = 1; fx_sp.SetActive(true); fx_escape.SetActive(type == 2); fx_fishingpanel_fishboss_glowdown.SetActive(type == 2); if (executeTime > 0.001f) { yield return new WaitForSeconds(executeTime); icon_bar.fillAmount = 0; fx_sp.SetActive(false); fx_escape.SetActive(false); fx_fishingpanel_fishboss_glowdown.SetActive(false); } } private void OnDisable() { fx_sp.SetActive(false); fx_escape.SetActive(false); icon_bar.DOKill(); icon_bar.fillAmount = 0; icon_bar_disposable?.Dispose(); icon_bar_disposable = null; } }