132 lines
4.0 KiB
C#
132 lines
4.0 KiB
C#
using System.Collections;
|
|
using BlueWater.Items;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace BlueWater.Uis
|
|
{
|
|
public class UpgradePopupUi : 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()
|
|
{
|
|
PlayerInputKeyManager.Instance.DisableAction("OpenManualBook");
|
|
VisualFeedbackManager.Instance.SetBaseTimeScale(0.0f);
|
|
PlayerInputKeyManager.Instance.SwitchCurrentActionMap(InputActionMaps.TycoonUi);
|
|
PopupUiController.RegisterPopup(this);
|
|
_panel.SetActive(true);
|
|
IsOpened = true;
|
|
}
|
|
|
|
public override void Close()
|
|
{
|
|
_panel.SetActive(false);
|
|
PopupUiController.UnregisterPopup(this);
|
|
PlayerInputKeyManager.Instance.SwitchCurrentActionMap(InputActionMaps.Tycoon);
|
|
IsOpened = false;
|
|
VisualFeedbackManager.Instance.ResetTimeScale();
|
|
PlayerInputKeyManager.Instance.EnableAction("OpenManualBook");
|
|
}
|
|
|
|
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)
|
|
{
|
|
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;
|
|
}
|
|
|
|
Close();
|
|
}
|
|
}
|
|
} |