CapersProject/Assets/02.Scripts/BlueWater/Tycoon/GameClear.cs
2025-02-10 11:13:46 +09:00

84 lines
2.0 KiB
C#

using System.Collections;
using DDD;
using DDD.Uis;
using UnityEngine;
using UnityEngine.UI;
public class GameClear: PopupUi
{
[SerializeField]
private GameObject _panel;
[SerializeField]
private Image _stempImage;
[SerializeField]
private Image _backgroundImage;
private void Start()
{
EventManager.OnLevelUp += StartClearPopup;
}
private void OnDestroy()
{
EventManager.OnLevelUp -= StartClearPopup;
}
public override void Open()
{
VisualFeedbackManager.Instance.SetBaseTimeScale(0.0f);
PlayerInputKeyManager.Instance.SwitchCurrentActionMap(InputActionMaps.TycoonUi);
PopupUiController.RegisterPopup(this);
_panel.SetActive(true);
IsOpened = true;
StartCoroutine(StartClearPopupCoroutine());
}
public override void Close()
{
_panel.SetActive(false);
PopupUiController.UnregisterPopup(this);
PlayerInputKeyManager.Instance.SwitchCurrentActionMap(InputActionMaps.Tycoon);
IsOpened = false;
VisualFeedbackManager.Instance.ResetTimeScale();
EventManager.InvokeShowResult();
}
private void StartClearPopup(LevelData currentLevelData)
{
if (currentLevelData.Idx != 100.ToString()) return;
Open();
}
private IEnumerator StartClearPopupCoroutine()
{
float timer = 0f;
while (timer < 0.5)
{
timer += Time.unscaledDeltaTime;
float t = timer / 0.5f;
float easedT = EaseEffect.BounceOut(t);
_stempImage.transform.localScale =
Vector3.Lerp(new Vector3(5.0f, 5.0f, 1.0f), new Vector3(1.0f, 1.0f, 1.0f), easedT);
yield return null;
}
timer = 0f;
while (timer < 3.0) //단순 딜레이
{
timer += Time.unscaledDeltaTime;
yield return null;
}
Close();
}
}