备份CatanBuilding瘦身独立工程
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using GameCore;
|
||||
using UniRx;
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
public class EventLuckMagicRoadSignPanel : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private TMP_Text textTimer;
|
||||
[SerializeField] private Image iconSign;
|
||||
[SerializeField] private Button btnLater, btnClose;
|
||||
[SerializeField] private EventLuckMagicDrawButtonView btnNow;
|
||||
private System.DateTime _expireTime;
|
||||
private System.TimeSpan RemainingTime => _expireTime - ZZTimeHelper.UtcNow();
|
||||
private TaskCompletionSource<bool> _tcs;
|
||||
|
||||
public void Init(System.DateTime expireTime, int roadSignId, EEventLuckMagicRingType higherRingType,
|
||||
int higherRingCost, TaskCompletionSource<bool> taskCompletionSource)
|
||||
{
|
||||
btnClose.onClick.AddListener(OnClickClose);
|
||||
btnLater.onClick.AddListener(OnClickClose);
|
||||
btnNow.ButtonDraw.onClick.AddListener(OnClickNow);
|
||||
_expireTime = expireTime;
|
||||
UpdateTimer();
|
||||
Observable.Interval(System.TimeSpan.FromSeconds(1)).Subscribe(UpdateTimer).AddTo(this);
|
||||
btnNow.Init(higherRingCost, higherRingType);
|
||||
var roadSignIcon = GContext.container.Resolve<Tables>().TbItem[roadSignId].Icon;
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(iconSign, roadSignIcon);
|
||||
_tcs = taskCompletionSource;
|
||||
}
|
||||
|
||||
private void OnClickClose()
|
||||
{
|
||||
_tcs.SetResult(false);
|
||||
UIManager.Instance.DestroyUI(UITypes.EventLuckMagicRoadSignPanel);
|
||||
}
|
||||
|
||||
private void UpdateTimer(long _ = 0L)
|
||||
{
|
||||
textTimer.text = LocalizationMgr.GetFormatTextValue("UI_COMMON_end", ConvertTools.ConvertTime2(RemainingTime));
|
||||
if (RemainingTime.TotalSeconds <= 0)
|
||||
OnClickClose();
|
||||
}
|
||||
|
||||
private void OnClickNow()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.EventLuckMagicRoadSignPanel);
|
||||
EventLuckMagicAct.EventAggregator.Publish(new EventLuckMagicClickRoadSignNow());
|
||||
_tcs.SetResult(true);
|
||||
}
|
||||
}
|
||||
|
||||
public class EventLuckMagicClickRoadSignNow { }
|
||||
|
||||
/* public enum EEventLuckMagicRoadSignExitType
|
||||
{
|
||||
Now,
|
||||
Later
|
||||
} */
|
||||
Reference in New Issue
Block a user