2024-11-17 04:29:57 +00:00
|
|
|
using System.Collections;
|
|
|
|
using BlueWater.Items;
|
2024-12-10 09:56:18 +00:00
|
|
|
using BlueWater.Tycoons;
|
2024-11-17 04:29:57 +00:00
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.UI;
|
2024-12-03 07:54:12 +00:00
|
|
|
using Sirenix.OdinInspector;
|
2024-12-10 09:56:18 +00:00
|
|
|
using Spine.Unity;
|
|
|
|
using Unity.VisualScripting;
|
2024-11-17 04:29:57 +00:00
|
|
|
|
|
|
|
namespace BlueWater.Uis
|
|
|
|
{
|
|
|
|
public class UpgradePopupUi : PopupUi
|
|
|
|
{
|
|
|
|
[SerializeField]
|
|
|
|
private GameObject _panel;
|
|
|
|
|
|
|
|
[SerializeField]
|
2024-12-10 09:56:18 +00:00
|
|
|
private GameObject information; //정보를 알려주는 이미지
|
2024-11-17 04:29:57 +00:00
|
|
|
|
|
|
|
[SerializeField]
|
2024-12-10 09:56:18 +00:00
|
|
|
private Image informationTabel; //정보를 알려주는 이미지
|
|
|
|
|
2024-11-17 04:29:57 +00:00
|
|
|
[SerializeField]
|
2024-12-10 09:56:18 +00:00
|
|
|
private Image informationIngredient; //정보를 알려주는 이미지
|
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
private Image ingredientImage; //재료 이미지
|
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
private SkeletonGraphic paperAnimation;
|
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
private Button closeButton;
|
|
|
|
|
2024-11-17 04:29:57 +00:00
|
|
|
private void Start()
|
|
|
|
{
|
|
|
|
EventManager.OnLevelUp += StartUpgradePopup;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void OnDestroy()
|
|
|
|
{
|
|
|
|
EventManager.OnLevelUp -= StartUpgradePopup;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void Open()
|
|
|
|
{
|
|
|
|
VisualFeedbackManager.Instance.SetBaseTimeScale(0.0f);
|
|
|
|
PlayerInputKeyManager.Instance.SwitchCurrentActionMap(InputActionMaps.TycoonUi);
|
|
|
|
PopupUiController.RegisterPopup(this);
|
|
|
|
_panel.SetActive(true);
|
|
|
|
IsOpened = true;
|
|
|
|
}
|
|
|
|
|
2024-12-10 09:56:18 +00:00
|
|
|
|
|
|
|
|
2024-11-17 04:29:57 +00:00
|
|
|
public override void Close()
|
|
|
|
{
|
|
|
|
_panel.SetActive(false);
|
|
|
|
PopupUiController.UnregisterPopup(this);
|
|
|
|
PlayerInputKeyManager.Instance.SwitchCurrentActionMap(InputActionMaps.Tycoon);
|
|
|
|
IsOpened = false;
|
|
|
|
VisualFeedbackManager.Instance.ResetTimeScale();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void StartUpgradePopup(LevelData currentLevelData)
|
|
|
|
{
|
2024-12-10 09:56:18 +00:00
|
|
|
|
2024-11-17 04:29:57 +00:00
|
|
|
if (string.IsNullOrEmpty(currentLevelData.OpenUpgrade)) return;
|
|
|
|
|
2024-12-10 09:56:18 +00:00
|
|
|
ingredientImage.sprite = int.Parse(currentLevelData.Idx) switch
|
2024-11-17 04:29:57 +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,
|
2024-12-10 09:56:18 +00:00
|
|
|
_ => ingredientImage.sprite
|
2024-11-17 04:29:57 +00:00
|
|
|
};
|
2024-12-10 09:56:18 +00:00
|
|
|
|
|
|
|
informationIngredient.enabled = int.Parse(currentLevelData.Idx) != 35;
|
2024-11-17 04:29:57 +00:00
|
|
|
|
2024-12-10 09:56:18 +00:00
|
|
|
if (int.Parse(currentLevelData.Idx) <= 35)
|
|
|
|
{
|
|
|
|
informationIngredient.rectTransform.anchoredPosition = new Vector3(-250f,0f,0f);
|
|
|
|
informationTabel.rectTransform.anchoredPosition = new Vector3(250f,0f,0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
Open();
|
|
|
|
var trackEntry = paperAnimation.AnimationState.SetAnimation(0, "Idle", false);
|
|
|
|
//trackEntry.TimeScale = Time.unscaledDeltaTime * 15f;
|
|
|
|
trackEntry.Complete += (track) =>
|
|
|
|
{
|
|
|
|
StartCoroutine(StartUpgradePopupCoroutine(currentLevelData));
|
|
|
|
closeButton.GameObject().SetActive(true);
|
|
|
|
};
|
|
|
|
|
2024-11-17 04:29:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ReSharper disable Unity.PerformanceAnalysis
|
|
|
|
private IEnumerator StartUpgradePopupCoroutine(LevelData currentLevelData)
|
|
|
|
{
|
|
|
|
float timer = 0f;
|
|
|
|
|
|
|
|
while (timer < 0.5)
|
|
|
|
{
|
|
|
|
timer += Time.unscaledDeltaTime;
|
|
|
|
|
|
|
|
float t = timer / 0.5f;
|
|
|
|
float easedT = EaseEffect.BounceOut(t);
|
|
|
|
|
|
|
|
information.transform.localScale =
|
2024-12-10 09:56:18 +00:00
|
|
|
Vector3.Lerp(new Vector3(0.0f, 0.0f, 1.0f), new Vector3(1.0f, 1.0f, 1.0f), easedT);
|
2024-11-17 04:29:57 +00:00
|
|
|
yield return null;
|
|
|
|
}
|
2024-12-10 09:56:18 +00:00
|
|
|
}
|
2024-11-17 04:29:57 +00:00
|
|
|
|
2024-12-10 09:56:18 +00:00
|
|
|
public void OnCloseButton()
|
|
|
|
{
|
|
|
|
StartCoroutine(CloseUpgradePopupCoroutine());
|
|
|
|
closeButton.GameObject().SetActive(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
private IEnumerator CloseUpgradePopupCoroutine()
|
|
|
|
{
|
|
|
|
float timer = 0f;
|
2024-11-17 04:29:57 +00:00
|
|
|
|
|
|
|
while (timer < 0.5)
|
|
|
|
{
|
|
|
|
timer += Time.unscaledDeltaTime;
|
|
|
|
|
|
|
|
float t = timer / 0.5f;
|
|
|
|
float easedT = EaseEffect.BounceOut(t);
|
|
|
|
|
|
|
|
information.transform.localScale =
|
2024-12-10 09:56:18 +00:00
|
|
|
Vector3.Lerp(new Vector3(1.0f, 1.0f, 1.0f), new Vector3(0.0f, 0.0f, 1.0f), easedT);
|
2024-11-17 04:29:57 +00:00
|
|
|
yield return null;
|
|
|
|
}
|
|
|
|
|
2024-12-10 09:56:18 +00:00
|
|
|
paperAnimation.AnimationState.SetAnimation(0, "Back", false).Complete += (trackEntry) =>
|
2024-11-17 04:29:57 +00:00
|
|
|
{
|
2024-12-10 09:56:18 +00:00
|
|
|
Close();
|
|
|
|
};
|
|
|
|
|
2024-11-17 04:29:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|