2024-10-28 04:24:04 +00:00
|
|
|
using System.Collections;
|
|
|
|
using BlueWater;
|
2024-10-29 10:43:07 +00:00
|
|
|
using BlueWater.Uis;
|
2024-10-21 05:47:20 +00:00
|
|
|
using UnityEngine;
|
2024-10-28 09:09:18 +00:00
|
|
|
using UnityEngine.UI;
|
2024-10-21 05:47:20 +00:00
|
|
|
|
2024-10-29 10:43:07 +00:00
|
|
|
public class Upgrade_Popup : PopupUi
|
2024-10-21 05:47:20 +00:00
|
|
|
{
|
2024-10-28 09:27:48 +00:00
|
|
|
[SerializeField]
|
|
|
|
private GameObject _panel;
|
|
|
|
|
2024-10-28 04:24:04 +00:00
|
|
|
[SerializeField]
|
|
|
|
private AnimationController _animationController;
|
|
|
|
private bool isReversing = false; // 애니메이션 상태를 체크할 변수
|
|
|
|
|
2024-10-28 09:09:18 +00:00
|
|
|
[SerializeField]
|
|
|
|
private Image information; //정보를 알려주는 이미지
|
2024-10-28 09:27:48 +00:00
|
|
|
|
|
|
|
private void Start()
|
|
|
|
{
|
|
|
|
EventManager.OnUpgradeUi += StartUpgradePopup;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void OnDestroy()
|
2024-10-21 05:47:20 +00:00
|
|
|
{
|
2024-10-28 09:27:48 +00:00
|
|
|
EventManager.OnUpgradeUi -= StartUpgradePopup;
|
|
|
|
}
|
2024-10-29 10:43:07 +00:00
|
|
|
|
|
|
|
public override void Open()
|
|
|
|
{
|
2024-10-31 05:41:13 +00:00
|
|
|
VisualFeedbackManager.Instance.SetBaseTimeScale(0.0f);
|
|
|
|
PlayerInputKeyManager.Instance.DisableAction("Manual");
|
2024-10-29 10:43:07 +00:00
|
|
|
PopupUiController.RegisterPopup(this);
|
2024-10-31 05:41:13 +00:00
|
|
|
ShowUi();
|
2024-10-29 10:43:07 +00:00
|
|
|
IsOpened = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void Close()
|
|
|
|
{
|
|
|
|
HideUi();
|
2024-10-31 05:41:13 +00:00
|
|
|
PlayerInputKeyManager.Instance.EnableAction("Manual");
|
2024-10-29 10:43:07 +00:00
|
|
|
PopupUiController.UnregisterPopup(this);
|
|
|
|
IsOpened = false;
|
|
|
|
|
|
|
|
if (!PopupUiController.IsPopupListEmpty()) return;
|
|
|
|
|
|
|
|
VisualFeedbackManager.Instance.ResetTimeScale();
|
|
|
|
}
|
2024-10-28 09:27:48 +00:00
|
|
|
|
|
|
|
private void StartUpgradePopup(LevelData currentLevelData)
|
|
|
|
{
|
|
|
|
StartCoroutine(StartUpgradePopupCoroutine(currentLevelData));
|
2024-10-21 05:47:20 +00:00
|
|
|
}
|
2024-10-28 04:24:04 +00:00
|
|
|
|
|
|
|
// ReSharper disable Unity.PerformanceAnalysis
|
2024-10-28 09:27:48 +00:00
|
|
|
private IEnumerator StartUpgradePopupCoroutine(LevelData currentLevelData)
|
2024-10-21 05:47:20 +00:00
|
|
|
{
|
2024-10-29 10:43:07 +00:00
|
|
|
Open();
|
2024-10-28 09:09:18 +00:00
|
|
|
float timer = 0f;
|
|
|
|
|
|
|
|
while (timer < 1.0f)
|
2024-10-28 04:24:04 +00:00
|
|
|
{
|
2024-10-28 09:09:18 +00:00
|
|
|
timer += Time.unscaledDeltaTime;
|
|
|
|
yield return null;
|
2024-10-28 04:24:04 +00:00
|
|
|
}
|
|
|
|
|
2024-10-28 09:09:18 +00:00
|
|
|
timer = 0f;
|
2024-10-28 04:24:04 +00:00
|
|
|
|
2024-10-28 09:09:18 +00:00
|
|
|
while (timer < 0.5)
|
|
|
|
{
|
|
|
|
timer += Time.unscaledDeltaTime;
|
|
|
|
|
|
|
|
float t = timer / 0.5f;
|
|
|
|
float easedT = EaseEffect.BounceOut(t);
|
|
|
|
|
|
|
|
information.transform.localScale = Vector3.Lerp( new Vector3(0.0f,0.0f,0.0f), new Vector3(1.0f,1.0f,1.0f), easedT);
|
|
|
|
yield return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
timer = 0f;
|
|
|
|
|
|
|
|
while (timer < 2.0)
|
2024-10-28 04:24:04 +00:00
|
|
|
{
|
|
|
|
timer += Time.unscaledDeltaTime;
|
|
|
|
yield return null;
|
|
|
|
}
|
|
|
|
|
2024-10-28 09:09:18 +00:00
|
|
|
timer = 0f;
|
|
|
|
|
|
|
|
while (timer < 0.5)
|
|
|
|
{
|
|
|
|
timer += Time.unscaledDeltaTime;
|
|
|
|
|
|
|
|
float t = timer / 0.5f;
|
|
|
|
float easedT = EaseEffect.BounceOut(t);
|
|
|
|
|
|
|
|
information.transform.localScale = Vector3.Lerp( new Vector3(1.0f,1.0f,1.0f), new Vector3(0.0f,0.0f,0.0f), easedT);
|
|
|
|
yield return null;
|
|
|
|
}
|
|
|
|
|
2024-10-28 04:24:04 +00:00
|
|
|
_animationController.PlayAnimation("CardUpgrade_Reverse");
|
|
|
|
|
2024-10-28 09:09:18 +00:00
|
|
|
timer = 0f;
|
|
|
|
|
|
|
|
while (timer < 1.0f)
|
2024-10-28 04:24:04 +00:00
|
|
|
{
|
2024-10-28 09:09:18 +00:00
|
|
|
timer += Time.unscaledDeltaTime;
|
|
|
|
yield return null;
|
2024-10-28 04:24:04 +00:00
|
|
|
}
|
2024-10-21 05:47:20 +00:00
|
|
|
|
2024-10-28 04:24:04 +00:00
|
|
|
VisualFeedbackManager.Instance.ResetTimeScale();
|
2024-10-29 10:43:07 +00:00
|
|
|
Close();
|
2024-10-21 05:47:20 +00:00
|
|
|
}
|
2024-10-28 09:27:48 +00:00
|
|
|
|
|
|
|
public void ShowUi() => _panel.SetActive(true);
|
|
|
|
public void HideUi() => _panel.SetActive(false);
|
2024-10-21 05:47:20 +00:00
|
|
|
}
|