96 lines
2.4 KiB
C#
96 lines
2.4 KiB
C#
using System.Collections;
|
|
using DG.Tweening;
|
|
using Michsky.UI.MTP;
|
|
using Obvious.Soap;
|
|
using UnityEngine;
|
|
|
|
public class UI_FishCatchPanel : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private ScriptableEventFishData OnFishCatched;
|
|
|
|
[SerializeField]
|
|
private ScriptableEventFishData OnFishCollected;
|
|
|
|
[SerializeField]
|
|
private ScriptableEventFishData OnFishReleased;
|
|
|
|
[SerializeField]
|
|
private StyleManager _FishNameTitle;
|
|
|
|
[SerializeField]
|
|
private StyleManager _FishWeightTitle;
|
|
|
|
[SerializeField]
|
|
private StyleManager _NewRecordTitle;
|
|
|
|
[SerializeField]
|
|
private CanvasGroup _BuyPanelGroup;
|
|
|
|
public float StyleDurationInterval = 0.4f;
|
|
|
|
private FishData _CatchedFish;
|
|
|
|
public BoolVariable IsNewRecordRegistred;
|
|
|
|
private void OnEnable()
|
|
{
|
|
OnFishCatched.OnRaised += OnFishCatched_OnRaised;
|
|
OnFishCollected.OnRaised += OnFishCollected_OnRaised;
|
|
OnFishReleased.OnRaised += OnFishReleased_OnRaised;
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
OnFishCatched.OnRaised -= OnFishCatched_OnRaised;
|
|
OnFishCollected.OnRaised -= OnFishCollected_OnRaised;
|
|
OnFishReleased.OnRaised -= OnFishReleased_OnRaised;
|
|
}
|
|
|
|
private void OnFishReleased_OnRaised(FishData obj)
|
|
{
|
|
OnFishCollected_OnRaised(obj);
|
|
}
|
|
|
|
private void OnFishCollected_OnRaised(FishData obj)
|
|
{
|
|
_FishNameTitle.PlayOutAndDisable();
|
|
_FishWeightTitle.PlayOutAndDisable();
|
|
if (_NewRecordTitle.gameObject.activeSelf)
|
|
{
|
|
_NewRecordTitle.PlayOutAndDisable();
|
|
}
|
|
_BuyPanelGroup.DOFade(0f, StyleDurationInterval).OnComplete(delegate
|
|
{
|
|
_BuyPanelGroup.gameObject.SetActive(value: false);
|
|
});
|
|
}
|
|
|
|
private void OnFishCatched_OnRaised(FishData obj)
|
|
{
|
|
_CatchedFish = obj;
|
|
StartCoroutine(Tween());
|
|
}
|
|
|
|
private IEnumerator Tween()
|
|
{
|
|
string fishName = _CatchedFish.FishName;
|
|
float fishWeight = _CatchedFish.Weight;
|
|
_ = _CatchedFish.Length;
|
|
_FishNameTitle.textItems[2].text = fishName.ToUpper();
|
|
_FishNameTitle.gameObject.SetActive(value: true);
|
|
yield return new WaitForSeconds(StyleDurationInterval);
|
|
_FishWeightTitle.textItems[0].text = fishWeight.ToString("0.00") + " kg";
|
|
_FishWeightTitle.gameObject.SetActive(value: true);
|
|
if ((bool)IsNewRecordRegistred)
|
|
{
|
|
yield return new WaitForSeconds(StyleDurationInterval);
|
|
_NewRecordTitle.gameObject.SetActive(value: true);
|
|
IsNewRecordRegistred.Value = false;
|
|
}
|
|
yield return new WaitForSeconds(StyleDurationInterval);
|
|
_BuyPanelGroup.gameObject.SetActive(value: true);
|
|
_BuyPanelGroup.DOFade(1f, StyleDurationInterval);
|
|
}
|
|
}
|