using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
namespace vnxbqy.UI
|
{
|
public class OperationFlashSale : OperationBase
|
{
|
public List<FlashSale> flashShops = new List<FlashSale>();
|
|
public bool TryGetFlashSale(DateTime time, out FlashSale flashSale)
|
{
|
flashSale = default(FlashSale);
|
var index = IndexOfTime(time, inAdvanceMinute > 0 ? -1 : 0);
|
index = Mathf.Min(index, flashShops.Count - 1);
|
if (index >= 0)
|
{
|
flashSale = flashShops[index];
|
}
|
return index >= 0;
|
}
|
|
public override bool SatisfyOpenCondition()
|
{
|
return PlayerDatas.Instance.baseData.LV >= limitLv;
|
}
|
|
public override void Reset()
|
{
|
base.Reset();
|
flashShops.Clear();
|
}
|
|
public override string ToDisplayTime()
|
{
|
var textBuilder = OperationTimeHepler.textBuilder;
|
textBuilder.Length = 0;
|
textBuilder.Append(startDate.ToDisplay());
|
if (startDate != endDate)
|
{
|
textBuilder.Append("—");
|
textBuilder.Append(endDate.ToDisplay());
|
}
|
return textBuilder.ToString();
|
}
|
|
public void ParsePackage(HAA11_tagMCSpringSaleInfo package)
|
{
|
for (int i = 0; i < package.ShopCount; i++)
|
{
|
var flashShop = new FlashSale();
|
var shop = package.ShopInfo[i];
|
flashShop.gifts = new FlashSaleGift[shop.GiftbagCount];
|
for (int k = 0; k < shop.GiftbagCount; k++)
|
{
|
var gift = new FlashSaleGift();
|
var pakGift = shop.GiftbagInfo[k];
|
gift.id = (int)pakGift.GiftID;
|
gift.limitNum = pakGift.BuyCountLimit;
|
gift.moneyNumber = (int)pakGift.MoneyNumber;
|
gift.moneyType = pakGift.MoneyType;
|
gift.moneyOriginal = (int)pakGift.MoneyOriginal;
|
gift.items = new FlashSaleItem[pakGift.GiftItemCount];
|
for (int q = 0; q < pakGift.GiftItemCount; q++)
|
{
|
var item = new FlashSaleItem();
|
item.itemId = (int)pakGift.ItemInfo[q].ItemID;
|
item.itemCount = pakGift.ItemInfo[q].ItemCount;
|
item.isMainItem = pakGift.ItemInfo[q].IsMainItem == 1;
|
gift.items[q] = item;
|
}
|
flashShop.gifts[k] = gift;
|
}
|
flashShops.Add(flashShop);
|
}
|
}
|
|
public struct FlashSale
|
{
|
public FlashSaleGift[] gifts;
|
}
|
|
public struct FlashSaleGift
|
{
|
public int id;
|
public int limitNum;
|
public int moneyType;
|
public int moneyNumber;
|
public int moneyOriginal;
|
public FlashSaleItem[] items;
|
}
|
|
public struct FlashSaleItem
|
{
|
public int itemId;
|
public int itemCount;
|
public bool isMainItem;
|
}
|
}
|
}
|