using System.Collections;
using UnityEngine;
using UnityEngine.UI;
namespace Streamingle.Contents.BossRaid
{
///
/// GAME OVER 화면. 유저 HP 0 시 표시됩니다.
///
public class GameOverScreen : MonoBehaviour
{
#region Fields
[Header("비주얼")]
[SerializeField] private Color titleColor = new Color(0.9f, 0.15f, 0.1f);
[SerializeField] private Color bgColor = new Color(0f, 0f, 0f, 0.6f);
private Canvas _canvas;
private CanvasGroup _canvasGroup;
private Text _titleText;
private Coroutine _showCoroutine;
private Font _font;
#endregion
#region Unity Messages
private void Awake()
{
_font = BossRaidFontLoader.Load();
CreateUI();
_canvasGroup.alpha = 0f;
}
#endregion
#region Public Methods
public void Show()
{
if (_showCoroutine != null) StopCoroutine(_showCoroutine);
_showCoroutine = StartCoroutine(ShowCoroutine());
}
public void Hide()
{
if (_showCoroutine != null)
{
StopCoroutine(_showCoroutine);
_showCoroutine = null;
}
_canvasGroup.alpha = 0f;
}
#endregion
#region Private Methods
private IEnumerator ShowCoroutine()
{
_titleText.text = "";
_canvasGroup.alpha = 0f;
// 페이드 인
float elapsed = 0f;
while (elapsed < 0.5f)
{
elapsed += Time.deltaTime;
_canvasGroup.alpha = elapsed / 0.5f;
yield return null;
}
_canvasGroup.alpha = 1f;
// 텍스트 등장 (펀치 스케일)
_titleText.text = "GAME OVER";
var rect = _titleText.rectTransform;
rect.localScale = Vector3.one * 2f;
elapsed = 0f;
while (elapsed < 0.4f)
{
elapsed += Time.deltaTime;
float t = elapsed / 0.4f;
float ease = 1f + 2.7f * Mathf.Pow(t - 1f, 3f) + 1.7f * Mathf.Pow(t - 1f, 2f);
rect.localScale = Vector3.one * Mathf.LerpUnclamped(2f, 1f, ease);
yield return null;
}
rect.localScale = Vector3.one;
}
private void CreateUI()
{
var canvasObj = new GameObject("BossRaid_GameOver");
canvasObj.transform.SetParent(transform);
_canvas = canvasObj.AddComponent