备份CatanBuilding瘦身独立工程
This commit is contained in:
99
Assets/Scripts/UI/Shop/AquariumGiftPopupPanel.cs
Normal file
99
Assets/Scripts/UI/Shop/AquariumGiftPopupPanel.cs
Normal file
@@ -0,0 +1,99 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AquariumGiftPopupPanel : GiftPopupPanel
|
||||
{
|
||||
protected int Type = 6;
|
||||
protected TriggerPackManager packManager;
|
||||
protected TriggerPackBuyData curTriggerPackState;
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
SetData();
|
||||
base.Start();
|
||||
btn_close.onClick.AddListener(OnClickClose);
|
||||
StartCoroutine(Countdown());
|
||||
}
|
||||
|
||||
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>().GetItemDataByDropId(pack.DropID, curTriggerPackState.mapID);
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
IEnumerator Countdown()
|
||||
{
|
||||
DateTime curTime = ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
DateTime endTime = GlobalUtils.TryParseDateTime(curTriggerPackState.time, curTime);
|
||||
TimeSpan now = endTime - curTime;
|
||||
text_time.text = ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds);
|
||||
|
||||
while (endTime.Ticks > curTime.Ticks)
|
||||
{
|
||||
yield return new WaitForSeconds(1);
|
||||
if (curTriggerPackState.index > 0)
|
||||
{
|
||||
OnClickClose();
|
||||
yield break;
|
||||
}
|
||||
curTime = ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
now = endTime - curTime;
|
||||
text_time.text = ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds);
|
||||
}
|
||||
OnClickClose();
|
||||
}
|
||||
|
||||
protected void OnClickClose()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.AquariumGiftPopupPanel);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user