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().CouponData; if (_data is not {IsActive: true}) { UIManager.Instance.DestroyUI(UITypes.BlackFridayPopupPanel); } var couponUiData = GContext.container.Resolve().TbEventCoupon[_data.RedirectId]; textTitle.text = LocalizationMgr.GetText(couponUiData.Title_l10n_key); GContext.container.Resolve().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().StopFaceUI(); await UIManager.Instance.ShowUI(UITypes.FishingShopPanel); GContext.Publish(new LackOfResourceConfirmEvent() { state = 1 }); UIManager.Instance.DestroyUI(UITypes.BlackFridayPopupPanel); GContext.Publish(new HideHomePanelEvent()); } }