备份CatanBuilding瘦身独立工程
This commit is contained in:
56
Assets/Scripts/UI/Shop/BlackFridayCouponPopupPanel.cs
Normal file
56
Assets/Scripts/UI/Shop/BlackFridayCouponPopupPanel.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UniRx;
|
||||
using cfg;
|
||||
|
||||
public class BlackFridayCouponPopupPanel : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Button btnClose, btnClaim;
|
||||
[SerializeField] private TMP_Text textTimer, textInfo, textTitle;
|
||||
[SerializeField] private Image bg;
|
||||
private BlackFridayCouponData _data;
|
||||
private void Start()
|
||||
{
|
||||
btnClose.onClick.AddListener(OnClickClose);
|
||||
_data = GContext.container.Resolve<PlayerShopData>().CouponData;
|
||||
if (_data is not {IsActive: true})
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.BlackFridayPopupPanel);
|
||||
}
|
||||
var couponUiData = GContext.container.Resolve<Tables>().TbEventCoupon[_data.RedirectId];
|
||||
textTitle.text = LocalizationMgr.GetText(couponUiData.Title_l10n_key);
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(bg, couponUiData.BgBanner);
|
||||
textTimer.text = ConvertTools.ConvertTime2(_data.RemainingTime);
|
||||
Observable.Interval(TimeSpan.FromSeconds(1.0f))
|
||||
.Subscribe(_ =>
|
||||
{
|
||||
textTimer.text = ConvertTools.ConvertTime2(_data.RemainingTime);
|
||||
if (!_data.IsActive)
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.BlackFridayPopupPanel);
|
||||
}
|
||||
})
|
||||
.AddTo(this);
|
||||
textInfo.text = LocalizationMgr.GetFormatTextValue("UI_GiftPopupPanel_13_3", _data.Multiplier + "%");
|
||||
btnClaim.onClick.RemoveAllListeners();
|
||||
btnClaim.onClick.AddListener(OnClickBuy);
|
||||
}
|
||||
|
||||
private void OnClickClose()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.BlackFridayPopupPanel);
|
||||
}
|
||||
|
||||
private async void OnClickBuy()
|
||||
{
|
||||
GContext.container.Resolve<IFaceUIService>().StopFaceUI();
|
||||
await UIManager.Instance.ShowUI(UITypes.FishingShopPanel);
|
||||
GContext.Publish(new LackOfResourceConfirmEvent() { state = 1 });
|
||||
UIManager.Instance.DestroyUI(UITypes.BlackFridayPopupPanel);
|
||||
GContext.Publish(new HideHomePanelEvent());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user