CapersProject/Assets/02.Scripts/Ui/Tycoon/Upgrade_Popup.cs

138 lines
3.9 KiB
C#
Raw Normal View History

2024-10-28 04:24:04 +00:00
using System.Collections;
using BlueWater;
2024-11-07 12:02:00 +00:00
using BlueWater.Items;
using BlueWater.Tycoons;
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;
2024-10-28 09:09:18 +00:00
[SerializeField]
private Image information; //정보를 알려주는 이미지
2024-11-07 12:02:00 +00:00
[SerializeField]
private Image liqueurImage; //리큐르 팝업창에 뜰 이미지
2024-10-28 09:27:48 +00:00
private void Start()
{
2024-11-11 09:51:12 +00:00
EventManager.OnLevelUp += StartUpgradePopup;
2024-10-28 09:27:48 +00:00
}
private void OnDestroy()
2024-10-21 05:47:20 +00:00
{
2024-11-11 09:51:12 +00:00
EventManager.OnLevelUp -= StartUpgradePopup;
2024-10-28 09:27:48 +00:00
}
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)
{
2024-11-11 09:51:12 +00:00
if (string.IsNullOrEmpty(currentLevelData.OpenUpgrade)) return;
liqueurImage.sprite = int.Parse(currentLevelData.Idx) switch
2024-11-07 12:02:00 +00:00
{
2024-11-11 09:51:12 +00:00
5 => ItemManager.Instance.LiquidDataSo.GetDataByIdx("LiquidB").Sprite,
10 => ItemManager.Instance.LiquidDataSo.GetDataByIdx("LiquidC").Sprite,
15 => ItemManager.Instance.LiquidDataSo.GetDataByIdx("LiquidD").Sprite,
20 => ItemManager.Instance.LiquidDataSo.GetDataByIdx("LiquidE").Sprite,
25 => ItemManager.Instance.LiquidDataSo.GetDataByIdx("Garnish1").Sprite,
30 => ItemManager.Instance.LiquidDataSo.GetDataByIdx("Garnish2").Sprite,
_ => liqueurImage.sprite
};
2024-11-07 12:02:00 +00:00
2024-10-28 09:27:48 +00:00
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-11-07 12:02:00 +00:00
int lv = TycoonManager.Instance.LevelDataSo.GetDataCount();
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
}