2024-06-03 18:26:03 +00:00
|
|
|
using DG.Tweening;
|
|
|
|
using Sirenix.OdinInspector;
|
|
|
|
using TMPro;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
namespace BlueWater.Uis
|
|
|
|
{
|
|
|
|
public class CombatSkillUi : MonoBehaviour
|
|
|
|
{
|
2024-06-28 04:58:32 +00:00
|
|
|
[SerializeField]
|
|
|
|
private DOTweenAnimation _punchDoTween;
|
|
|
|
|
2024-06-03 18:26:03 +00:00
|
|
|
[SerializeField, Required]
|
|
|
|
private Image _skillGaugeFillImage;
|
|
|
|
|
|
|
|
[SerializeField, Required]
|
|
|
|
private TMP_Text _percentText;
|
|
|
|
|
2024-06-23 15:57:47 +00:00
|
|
|
[SerializeField]
|
|
|
|
private Image _highlightOutline;
|
2024-06-28 04:58:32 +00:00
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
private Image _glowImage;
|
2024-06-23 15:57:47 +00:00
|
|
|
|
2024-06-03 18:26:03 +00:00
|
|
|
[SerializeField, Required]
|
|
|
|
private Image _fadeImage;
|
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
private Vector2 _fadeInOutDuration = new(0.05f, 0.2f);
|
|
|
|
|
|
|
|
private Tween _coolDownTween;
|
|
|
|
private Tween _fadeTween;
|
2024-06-23 15:57:47 +00:00
|
|
|
private bool _isQuitting;
|
|
|
|
|
|
|
|
private void OnApplicationQuit()
|
|
|
|
{
|
|
|
|
_isQuitting = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void OnDestroy()
|
|
|
|
{
|
|
|
|
if (_isQuitting) return;
|
|
|
|
|
|
|
|
_coolDownTween.Kill();
|
|
|
|
_fadeTween.Kill();
|
2024-06-28 04:58:32 +00:00
|
|
|
_punchDoTween.DOKill();
|
2024-06-23 15:57:47 +00:00
|
|
|
}
|
2024-06-03 18:26:03 +00:00
|
|
|
|
|
|
|
[Button("컴포넌트 초기화")]
|
|
|
|
private void InitializeComponents()
|
|
|
|
{
|
2024-06-28 04:58:32 +00:00
|
|
|
_punchDoTween = GetComponent<DOTweenAnimation>();
|
2024-06-03 18:26:03 +00:00
|
|
|
_skillGaugeFillImage = transform.Find("SkillGaugeFillImage").GetComponent<Image>();
|
|
|
|
_percentText = transform.Find("PercentText").GetComponent<TMP_Text>();
|
2024-06-23 15:57:47 +00:00
|
|
|
_highlightOutline = _skillGaugeFillImage.transform.Find("HighlightOutline").GetComponent<Image>();
|
2024-06-28 04:58:32 +00:00
|
|
|
_glowImage = _skillGaugeFillImage.transform.Find("Glow").GetComponent<Image>();
|
2024-06-03 18:26:03 +00:00
|
|
|
_fadeImage = transform.Find("FadeImage").GetComponent<Image>();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void CoolDown(float fillDuration)
|
|
|
|
{
|
2024-06-23 15:57:47 +00:00
|
|
|
_highlightOutline.enabled = false;
|
2024-06-28 04:58:32 +00:00
|
|
|
if (_glowImage)
|
|
|
|
{
|
|
|
|
_glowImage.enabled = false;
|
|
|
|
}
|
2024-06-03 18:26:03 +00:00
|
|
|
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);
|
2024-06-23 15:57:47 +00:00
|
|
|
_highlightOutline.enabled = true;
|
2024-06-28 04:58:32 +00:00
|
|
|
if (_glowImage)
|
|
|
|
{
|
|
|
|
_glowImage.enabled = true;
|
|
|
|
}
|
2024-06-03 18:26:03 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2024-06-28 04:58:32 +00:00
|
|
|
|
|
|
|
private void SetFill(float value)
|
|
|
|
{
|
|
|
|
_skillGaugeFillImage.fillAmount = value;
|
|
|
|
_percentText.text = (int)(value * 100) + "%";
|
|
|
|
}
|
2024-06-03 18:26:03 +00:00
|
|
|
|
|
|
|
public void ResetSkillUi()
|
|
|
|
{
|
|
|
|
SetFill(1f);
|
2024-06-23 15:57:47 +00:00
|
|
|
_highlightOutline.enabled = true;
|
2024-06-28 04:58:32 +00:00
|
|
|
if (_glowImage)
|
|
|
|
{
|
|
|
|
_glowImage.enabled = true;
|
|
|
|
}
|
2024-06-03 18:26:03 +00:00
|
|
|
}
|
|
|
|
|
2024-06-28 04:58:32 +00:00
|
|
|
public void PunchAnimation()
|
2024-06-03 18:26:03 +00:00
|
|
|
{
|
2024-06-28 04:58:32 +00:00
|
|
|
_punchDoTween.DORestart();
|
2024-06-03 18:26:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|