68 lines
2.2 KiB
C#
68 lines
2.2 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using asap.core;
|
|
using UniRx;
|
|
using OfferTreasureAscent;
|
|
using System.Linq;
|
|
using GameCore;
|
|
|
|
public class OfferTreasureAscentEntranceButton : EventButtonResource
|
|
{
|
|
[SerializeField] private BingoTimer timer;
|
|
[SerializeField] private Image icon;
|
|
[SerializeField] private Button button;
|
|
|
|
private void Awake()
|
|
{
|
|
GContext.OnEvent<EventOfferTreasureAscentHide>()
|
|
.Subscribe(_ => gameObject.SetActive(false))
|
|
.AddTo(this);
|
|
var manager = GContext.container.Resolve<Manager>();
|
|
if (manager == null || manager.IsFinalRewardClaimed)
|
|
{
|
|
gameObject.SetActive(false);
|
|
return;
|
|
}
|
|
|
|
//Bad, do not refer to it.
|
|
var data = manager.GetEntranceData();
|
|
var isWithinTime = ZZTimeHelper.UtcNow() >= data.TimerData.StartTime && ZZTimeHelper.UtcNow() < data.TimerData.ExpiryTime;
|
|
if (!isWithinTime)
|
|
{
|
|
gameObject.SetActive(false);
|
|
return;
|
|
}
|
|
|
|
CheckResource(manager.GetUiData().ToList());
|
|
button.onClick.AddListener(OnClickOpen);
|
|
RedPointManager.Instance.SetRedPointState(manager.RedPointKey, manager.DoNeedRedPoint());
|
|
}
|
|
|
|
protected override void OnLoadEventResource()
|
|
{
|
|
gameObject.SetActive(true);
|
|
var manager = GContext.container.Resolve<Manager>();
|
|
var entranceData = manager.GetEntranceData();
|
|
GContext.container.Resolve<IUIService>().SetImageSprite(icon, entranceData.IconUrl);
|
|
timer.Init(entranceData.TimerData);
|
|
timer.OnExpire += () => gameObject.SetActive(false);
|
|
var faceUiService = GContext.container.Resolve<IFaceUIService>();
|
|
faceUiService?.AddGiftFaceUI(manager.EventId, UITypes.OfferTreasureAscentMainPanel);
|
|
Debug.Log("[OfferTreasureAscent] Face!", this);
|
|
}
|
|
|
|
private async void OnClickOpen()
|
|
{
|
|
try
|
|
{
|
|
var arc = GContext.container.Resolve<Manager>();
|
|
await UIManager.Instance.ShowUINotLoading(UITypes.OfferTreasureAscentMainPanel);
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
Debug.LogError(ex);
|
|
}
|
|
}
|
|
}
|
|
|
|
public class EventOfferTreasureAscentHide { } |