104 lines
3.5 KiB
C#
104 lines
3.5 KiB
C#
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<List<int>> 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<TMP_Text>();
|
|
}
|
|
protected override void Start()
|
|
{
|
|
SetData();
|
|
base.Start();
|
|
btn_close.onClick.AddListener(OnClickClose);
|
|
SetTriggerPackTimer();
|
|
}
|
|
|
|
public void SetData()
|
|
{
|
|
var triggerPackDic = GContext.container.Resolve<TriggerPackData>().GetTriggerPackList(Type);
|
|
if (triggerPackDic.Count <= 0)
|
|
{
|
|
OnClickClose();
|
|
return;
|
|
}
|
|
curTriggerPackState = triggerPackDic[0];
|
|
TimeSpan now = GContext.container.Resolve<TriggerPackData>().GetCurTriggerPackEndTime(curTriggerPackState);
|
|
if (now.TotalSeconds < 0)
|
|
{
|
|
OnClickClose();
|
|
return;
|
|
}
|
|
int id = curTriggerPackState.ID;
|
|
packManager = _tables.TbTriggerPackManager.GetOrDefault(id);
|
|
int vipLevel = curTriggerPackState.vipLevel;
|
|
List<int> VIPPackList = packManager.VIPPackList[vipLevel];
|
|
pack = _tables.TbPack.GetOrDefault(VIPPackList[0]);
|
|
iAPItemList = _tables.TbIAPItemList.GetOrDefault(pack.IAPID);
|
|
itemDatas = GContext.container.Resolve<PlayerItemData>().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<TriggerPackData>().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<TriggerPackData>().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);
|
|
}
|
|
}
|