using System; using DG.Tweening; using Sirenix.OdinInspector; using TMPro; using UnityEditor.Searcher; using UnityEngine; using UnityEngine.UI; namespace BlueWater.Uis { public class CombatSkillUi : MonoBehaviour { [SerializeField, Required] private Image _skillGaugeFillImage; [SerializeField, Required] private TMP_Text _percentText; [SerializeField] private Image _highlightOutline; [SerializeField, Required] private Image _fadeImage; [SerializeField] private Vector2 _fadeInOutDuration = new(0.05f, 0.2f); private Tween _coolDownTween; private Tween _fadeTween; private bool _isQuitting; private void OnApplicationQuit() { _isQuitting = true; } private void OnDestroy() { if (_isQuitting) return; _coolDownTween.Kill(); _fadeTween.Kill(); } [Button("컴포넌트 초기화")] private void InitializeComponents() { _skillGaugeFillImage = transform.Find("SkillGaugeFillImage").GetComponent(); _percentText = transform.Find("PercentText").GetComponent(); _highlightOutline = _skillGaugeFillImage.transform.Find("HighlightOutline").GetComponent(); _fadeImage = transform.Find("FadeImage").GetComponent(); } public void CoolDown(float fillDuration) { _highlightOutline.enabled = false; SetFill(0f); _coolDownTween = _skillGaugeFillImage.DOFillAmount(1f, fillDuration) .OnUpdate(() => { _percentText.text = (int)(_skillGaugeFillImage.fillAmount * 100) + "%"; }) .OnComplete(() => { SetFill(1f); _fadeImage.color = new Color(1, 1, 1, 0); _fadeTween = _fadeImage.DOFade(1f, _fadeInOutDuration.x).OnComplete(() => { _fadeImage.DOFade(0f, _fadeInOutDuration.y); _highlightOutline.enabled = true; }); }); } public void ResetSkillUi() { SetFill(1f); _highlightOutline.enabled = true; } private void SetFill(float value) { _skillGaugeFillImage.fillAmount = value; _percentText.text = (int)(value * 100) + "%"; } } }