106 lines
3.2 KiB
C#
106 lines
3.2 KiB
C#
using asap.core;
|
|
using cfg;
|
|
using GameCore;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class GiftPopupPanel_2 : MonoBehaviour
|
|
{
|
|
//public Button btn_mask;
|
|
public Button btn_close;
|
|
public TMP_Text text_time;
|
|
List<GiftPopupItem> giftPopupItems = new List<GiftPopupItem>();
|
|
GiftPopupItem curData;
|
|
private void Awake()
|
|
{
|
|
//btn_mask = transform.Find("mask").GetComponent<Button>();
|
|
btn_close = transform.Find("root/btn_close").GetComponent<Button>();
|
|
text_time = transform.Find("root/text_time").GetComponent<TMP_Text>();
|
|
giftPopupItems.Capacity = 3;
|
|
for (int i = 1; i < 4; i++)
|
|
{
|
|
giftPopupItems.Add(transform.Find($"root/Content/gift{i}/Item").GetComponent<GiftPopupItem>());
|
|
}
|
|
|
|
}
|
|
protected void Start()
|
|
{
|
|
//btn_mask.onClick.AddListener(OnClickClose);
|
|
btn_close.onClick.AddListener(OnClickClose);
|
|
SetEndTime();
|
|
SetData();
|
|
}
|
|
async void OnBuySuccess()
|
|
{
|
|
//GContext.container.Resolve<PlayerShopData>().AddOpenChainGifIndex();
|
|
curData.SetReceived();
|
|
await Awaiters.Seconds(0.5f);
|
|
SetData();
|
|
}
|
|
private void SetData()
|
|
{
|
|
List<int> items = new List<int>();
|
|
PlayerShopData playerShopData = GContext.container.Resolve<PlayerShopData>();
|
|
int curIndex = playerShopData.ChainPackData.index;
|
|
int vipLevel = playerShopData.ChainPackData.lastID;
|
|
EventPackManager chainGiftPack = playerShopData.chainPackM;
|
|
if (chainGiftPack == null)
|
|
{
|
|
OnClickClose();
|
|
return;
|
|
}
|
|
List<int> packIDs = chainGiftPack.VIPPackList[vipLevel];
|
|
int startIndex = curIndex;
|
|
if (curIndex > packIDs.Count - 3)
|
|
{
|
|
startIndex = packIDs.Count - 3;
|
|
}
|
|
else
|
|
{
|
|
for (int i = 0; i < 3; i++)
|
|
{
|
|
giftPopupItems[i].PlayMove(i);
|
|
}
|
|
}
|
|
int isDone = 1;
|
|
for (int i = 0; i < 3; i++)
|
|
{
|
|
if (startIndex + i == curIndex)
|
|
{
|
|
isDone = 1;
|
|
curData = giftPopupItems[i];
|
|
}
|
|
else if (startIndex + i < curIndex)
|
|
{
|
|
isDone = 0;
|
|
}
|
|
else
|
|
{
|
|
isDone = 2;
|
|
}
|
|
giftPopupItems[i].SetData(OnBuySuccess, packIDs[startIndex + i], isDone, startIndex + i, i);
|
|
}
|
|
}
|
|
void SetEndTime()
|
|
{
|
|
DateTime endTime = GContext.container.Resolve<PlayerShopData>().GetChainEndTime();
|
|
TimeSpan now = endTime - ZZTimeHelper.UtcNow().UtcNowOffset();
|
|
double seconds = now.TotalSeconds;
|
|
this.AttachTimer((float)seconds,
|
|
() => { OnClickClose(); },
|
|
(elapsed) =>
|
|
{
|
|
now = endTime - ZZTimeHelper.UtcNow().UtcNowOffset();
|
|
text_time.text = ConvertTools.ConvertTime2(now.Days, now.Hours, now.Minutes, now.Seconds);
|
|
}, useRealTime: true);
|
|
}
|
|
void OnClickClose()
|
|
{
|
|
UIManager.Instance.DestroyUI(gameObject.name);
|
|
//GContext.container.Resolve<IFaceUIService>().ShowFaceUI();
|
|
}
|
|
}
|