138 lines
3.9 KiB
C#
138 lines
3.9 KiB
C#
using System.Collections;
|
|
using BlueWater;
|
|
using BlueWater.Items;
|
|
using BlueWater.Tycoons;
|
|
using BlueWater.Uis;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class Upgrade_Popup : PopupUi
|
|
{
|
|
[SerializeField]
|
|
private GameObject _panel;
|
|
|
|
[SerializeField]
|
|
private AnimationController _animationController;
|
|
|
|
[SerializeField]
|
|
private Image information; //정보를 알려주는 이미지
|
|
|
|
[SerializeField]
|
|
private Image liqueurImage; //리큐르 팝업창에 뜰 이미지
|
|
|
|
private void Start()
|
|
{
|
|
EventManager.OnLevelUp += StartUpgradePopup;
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
EventManager.OnLevelUp -= StartUpgradePopup;
|
|
}
|
|
|
|
public override void Open()
|
|
{
|
|
VisualFeedbackManager.Instance.SetBaseTimeScale(0.0f);
|
|
PlayerInputKeyManager.Instance.DisableAction("Manual");
|
|
PopupUiController.RegisterPopup(this);
|
|
ShowUi();
|
|
IsOpened = true;
|
|
}
|
|
|
|
public override void Close()
|
|
{
|
|
HideUi();
|
|
PlayerInputKeyManager.Instance.EnableAction("Manual");
|
|
PopupUiController.UnregisterPopup(this);
|
|
IsOpened = false;
|
|
|
|
if (!PopupUiController.IsPopupListEmpty()) return;
|
|
|
|
VisualFeedbackManager.Instance.ResetTimeScale();
|
|
}
|
|
|
|
private void StartUpgradePopup(LevelData currentLevelData)
|
|
{
|
|
if (string.IsNullOrEmpty(currentLevelData.OpenUpgrade)) return;
|
|
|
|
liqueurImage.sprite = int.Parse(currentLevelData.Idx) switch
|
|
{
|
|
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
|
|
};
|
|
|
|
StartCoroutine(StartUpgradePopupCoroutine(currentLevelData));
|
|
}
|
|
|
|
// ReSharper disable Unity.PerformanceAnalysis
|
|
private IEnumerator StartUpgradePopupCoroutine(LevelData currentLevelData)
|
|
{
|
|
int lv = TycoonManager.Instance.LevelDataSo.GetDataCount();
|
|
|
|
Open();
|
|
float timer = 0f;
|
|
|
|
while (timer < 1.0f)
|
|
{
|
|
timer += Time.unscaledDeltaTime;
|
|
yield return null;
|
|
}
|
|
|
|
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(0.0f,0.0f,0.0f), new Vector3(1.0f,1.0f,1.0f), easedT);
|
|
yield return null;
|
|
}
|
|
|
|
|
|
timer = 0f;
|
|
|
|
while (timer < 2.0)
|
|
{
|
|
timer += Time.unscaledDeltaTime;
|
|
yield return null;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
_animationController.PlayAnimation("CardUpgrade_Reverse");
|
|
|
|
timer = 0f;
|
|
|
|
while (timer < 1.0f)
|
|
{
|
|
timer += Time.unscaledDeltaTime;
|
|
yield return null;
|
|
}
|
|
|
|
VisualFeedbackManager.Instance.ResetTimeScale();
|
|
Close();
|
|
}
|
|
|
|
public void ShowUi() => _panel.SetActive(true);
|
|
public void HideUi() => _panel.SetActive(false);
|
|
}
|