using asap.core; using cfg; using GameCore; using System; using System.Collections.Generic; using TMPro; public class AdsPackPanel : GiftPopupPanel { protected int Type = 5; protected TriggerPackManager packManager; protected TriggerPackBuyData curTriggerPackState; List> VIPPackList; int allCount = 0; int buyCount = 0; TMP_Text txt_packName; protected override void Awake() { base.Awake(); txt_packName = transform.Find("root/text_title").GetComponent(); } protected override void Start() { SetData(); base.Start(); btn_close.onClick.AddListener(OnClickClose); SetTriggerPackTimer(); } public void SetData() { var triggerPackDic = GContext.container.Resolve().GetTriggerPackList(Type); if (triggerPackDic.Count <= 0) { OnClickClose(); return; } curTriggerPackState = triggerPackDic[0]; TimeSpan now = GContext.container.Resolve().GetCurTriggerPackEndTime(curTriggerPackState); if (now.TotalSeconds < 0) { OnClickClose(); return; } int id = curTriggerPackState.ID; packManager = _tables.TbTriggerPackManager.GetOrDefault(id); int vipLevel = curTriggerPackState.vipLevel; List VIPPackList = packManager.VIPPackList[vipLevel]; pack = _tables.TbPack.GetOrDefault(VIPPackList[0]); iAPItemList = _tables.TbIAPItemList.GetOrDefault(pack.IAPID); itemDatas = GContext.container.Resolve().GetItemDataByDropIdAndType(pack.DropID); SetShowData(); SKUDetailDataEvent sKUDetailDataEvent = new SKUDetailDataEvent(iAPItemList); GContext.Publish(sKUDetailDataEvent); text_buy.text = sKUDetailDataEvent.price; tag_more.SetActive(pack.Rebate > 0.01); text_best.text = LocalizationMgr.GetFormatTextValue("UI_FishingShopPanel_2", (pack.Rebate * 100).ToString("F0")); text_time.text = ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds); //txt_packName.text = LocalizationMgr.GetText(pack.Title_l10n_key); } protected override ShopBuyTypeData GetShopBuyTypeData() { ShopBuyTypeData shopBuyTypeData = new ShopBuyTypeData(); shopBuyTypeData.type = ShopBuyType.TriggerPack; shopBuyTypeData.ID = packManager.ID; return shopBuyTypeData; } protected override void OnSuccess() { GContext.container.Resolve().AddTriggerPackCount(packManager.ID); OnClickClose(); } protected override void OnBuySuccess() { OnClickClose(); } public async void SetTriggerPackTimer() { DateTime dateTime = ZZTimeHelper.UtcNow().UtcNowOffset(); DateTime dateTime1 = dateTime.AddDays(1).Date; while (this != null && dateTime.Ticks < dateTime1.Ticks) { TimeSpan now = GContext.container.Resolve().GetCurTriggerPackEndTime(curTriggerPackState); if (now.TotalSeconds < 0) { OnClickClose(); return; } text_time.text = ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds); await System.Threading.Tasks.Task.Delay(1000); dateTime.AddSeconds(1); } } protected void OnClickClose() { UIManager.Instance.DestroyUI(UITypes.AdsPackPanel); } }