85 lines
2.3 KiB
C#
85 lines
2.3 KiB
C#
using UnityEngine;
|
|
using System.Collections;
|
|
using UnityEngine.UI;
|
|
using System;
|
|
using GCGame.Table;
|
|
|
|
public class ImperialExamWaitPanelCtr : MonoBehaviour {
|
|
|
|
public static ImperialExamWaitPanelCtr Instance;
|
|
private void Awake()
|
|
{
|
|
Instance = this;
|
|
}
|
|
private void OnDestroy()
|
|
{
|
|
Instance = null;
|
|
}
|
|
|
|
|
|
public Text CountTimeText; //计时器
|
|
public bool isCountTime = false;
|
|
public float CountTime = 0;
|
|
public int WaitTime;
|
|
|
|
//报完名之后开启等待面板 同时开始计时
|
|
public void StartCountTime(int remainTime)
|
|
{
|
|
WaitTime = remainTime;
|
|
isCountTime = true;
|
|
}
|
|
|
|
// Use this for initialization
|
|
private void OnEnable()
|
|
{
|
|
StartCountTime(GetImperialExamOverTime()); //开始计时
|
|
}
|
|
|
|
//计算剩余时间
|
|
public int GetImperialExamOverTime()
|
|
{
|
|
//结束时间
|
|
var activityBase = ActivityDataManager.Instance.GetActivityTabByServerType(ActivityDataManager.Activity_Type.ACTIVITY_HUISHI);
|
|
|
|
int openHour = int.Parse(activityBase.GetTimebyIndex(0).Split('|')[0]) / 100;
|
|
int openMin = int.Parse(activityBase.GetTimebyIndex(0).Split('|')[0]) % 100;
|
|
var questionOther = TableManager.GetQuestionOtherByID(1, 0);
|
|
DateTime DateStarTime = new System.DateTime(1970, 1, 1).ToLocalTime();
|
|
DateTime DateOverTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, openHour, openMin, 0);
|
|
return Convert.ToInt32((DateOverTime - DateStarTime.AddSeconds(GlobalData.ServerAnsiTime)).TotalSeconds) + questionOther.WaitTime;
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update () {
|
|
if(isCountTime)
|
|
{
|
|
//判断剩余时间
|
|
if (WaitTime <= 0)
|
|
{
|
|
CountTimeText.text = "0";
|
|
isCountTime = false;
|
|
return;
|
|
}
|
|
|
|
CountTime += Time.deltaTime;
|
|
if(CountTime >= 1.0f)
|
|
{
|
|
WaitTime--;
|
|
//显示剩余时间
|
|
CountTimeText.text = WaitTime.ToString();
|
|
|
|
//重置计时器
|
|
CountTime = 1.0f - CountTime;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void CloseCurWindow()
|
|
{
|
|
UIManager.CloseUI(UIInfo.ImperialExamWaitPanel);
|
|
}
|
|
|
|
}
|
|
|
|
|