using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace vnxbqy.UI
|
{
|
public class FlashRushToBuyCoolDown : MonoBehaviour
|
{
|
[SerializeField] Text timeText;
|
FlashRushToBuyModel rushToBuyModel { get { return ModelCenter.Instance.GetModel<FlashRushToBuyModel>(); } }
|
bool isReplace = false;
|
|
private void OnEnable()
|
{
|
DisplayTime();
|
WindowCenter.Instance.windowBeforeOpenEvent += OpenWindow;
|
}
|
|
private void OnDisable()
|
{
|
WindowCenter.Instance.windowBeforeOpenEvent -= OpenWindow;
|
}
|
|
|
private void OpenWindow(Window win)
|
{
|
if (win.name != typeof(MainInterfaceWin).Name) return;
|
|
DisplayTime();
|
}
|
|
|
void DisplayTime()
|
{
|
var operation = rushToBuyModel.GetOperationFlashRushToBuy();
|
if (operation == null) return;
|
int seconds = 0;
|
OperationTime operationTime;
|
OperationFlashRushToBuy.FlashSaleShop saleShop;
|
FlashRushToBuyModel.FlashRushToBuySate flashState = rushToBuyModel.GetActivityState(out seconds,out operationTime,out saleShop);
|
switch (flashState)
|
{
|
case FlashRushToBuyModel.FlashRushToBuySate.NoOpen:
|
break;
|
case FlashRushToBuyModel.FlashRushToBuySate.InAdvance:
|
var operationDate = operation.startDate.AddDays(saleShop.dayIndex);
|
DateTime openTime = new DateTime(operationDate.year,operationDate.month,operationDate.day);
|
int offsetDay = Mathf.CeilToInt((float)(openTime - TimeUtility.ServerNow).TotalDays);
|
if(offsetDay > 1)
|
{
|
string saleDate = StringUtility.Contact(operationDate.day, "/", operationDate.month);
|
timeText.text = saleDate;
|
}
|
else if(offsetDay == 1)
|
{
|
timeText.text = Language.Get("FlashRushToBuy110");
|
}
|
else
|
{
|
timeText.text = Language.Get("FlashRushToBuy106", operation.ToDisplayBuyTime(operationTime.startHour, operationTime.startMinute));
|
}
|
//if(seconds <= 3600)
|
//{
|
// int split = (3600 - seconds)/30 % 2;
|
// if(split == 0)
|
// {
|
// timeText.text = Language.Get("FlashRushToBuy109", TimeUtility.SecondsToMS(seconds));
|
// }
|
// else
|
// {
|
// timeText.text = Language.Get("FlashRushToBuy106", operation.ToDisplayBuyTime(operationTime.startHour, operationTime.startMinute));
|
// }
|
//}
|
//else
|
//{
|
// timeText.text = Language.Get("FlashRushToBuy106", operation.ToDisplayBuyTime(operationTime.startHour, operationTime.startMinute));
|
//}
|
break;
|
case FlashRushToBuyModel.FlashRushToBuySate.Begining:
|
timeText.text = Language.Get("FlashRushToBuy107");
|
break;
|
case FlashRushToBuyModel.FlashRushToBuySate.End:
|
timeText.text = Language.Get("ActivityEnd");
|
break;
|
}
|
}
|
}
|
}
|
|