using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
namespace Snxxz.UI
|
{
|
public class OperationFlashSale : OperationBase
|
{
|
public List<FlashSale> flashShops = new List<FlashSale>();
|
|
public int IndexOfFlashShop()
|
{
|
if (flashShops.Count == 1)
|
{
|
return 0;
|
}
|
var _timeIndex = IndexOfOpenTime(TimeUtility.ServerNow);
|
if (_timeIndex == -1)
|
{
|
return -1;
|
}
|
return Mathf.Min(flashShops.Count - 1, allDay ? 0 : _timeIndex);
|
}
|
|
public FlashSaleGift GetFlashSaleGift(int _index, int _id)
|
{
|
if (_index < flashShops.Count)
|
{
|
for (int i = 0; i < flashShops[_index].gifts.Length; i++)
|
{
|
if (flashShops[_index].gifts[i].id == _id)
|
{
|
return flashShops[_index].gifts[i];
|
}
|
}
|
}
|
return default(FlashSaleGift);
|
}
|
|
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 int GetSurplusTime(int index)
|
{
|
if (!InTime(TimeUtility.ServerNow))
|
{
|
return 0;
|
}
|
var seconds = 0;
|
if (times.Count == 0)
|
{
|
DateTime endOperationTime = new DateTime(TimeUtility.Year, TimeUtility.Month,
|
TimeUtility.Day, 0, 0, 0);
|
endOperationTime = endOperationTime.AddDays(1);
|
seconds = (int)(endOperationTime - TimeUtility.ServerNow).TotalSeconds;
|
}
|
if (index >= 0 && index < times.Count)
|
{
|
var _endTime = times[index];
|
DateTime endOperationTime = new DateTime(TimeUtility.Year, TimeUtility.Month,
|
TimeUtility.Day, _endTime.endHour, _endTime.endMinute, 0);
|
seconds = (int)(endOperationTime - TimeUtility.ServerNow).TotalSeconds;
|
}
|
return seconds;
|
}
|
|
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 int isBind;
|
public bool isMainItem;
|
}
|
}
|
}
|