123 lines
3.3 KiB
C#
123 lines
3.3 KiB
C#
using UnityEngine;
|
|
using System.Collections;
|
|
using GCGame.Table;
|
|
using System.Collections.Generic;
|
|
using System;
|
|
using Games.Mission;
|
|
|
|
public class AucationCtr : MonoBehaviour {
|
|
|
|
public static AucationCtr Instance;
|
|
private void Awake()
|
|
{
|
|
Instance = this;
|
|
}
|
|
private void OnDestroy()
|
|
{
|
|
Instance = null;
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
ShowPage(0); //默认显示第一个
|
|
CountRemainTime();
|
|
}
|
|
|
|
public GameObject[] pagePanels;
|
|
public AucationMenuItem[] aucationMenuItems;
|
|
|
|
public void ShowPage(int _Index)
|
|
{
|
|
for(int index = 0; index < pagePanels.Length; index++)
|
|
{
|
|
if(index == _Index)
|
|
{
|
|
pagePanels[index].gameObject.SetActive(true);
|
|
}else
|
|
{
|
|
pagePanels[index].gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
for(int index = 0; index < aucationMenuItems.Length; index++)
|
|
{
|
|
aucationMenuItems[index].GetComponent<AucationMenuItem>().SetMenuItemState(index == _Index ? true : false);
|
|
}
|
|
}
|
|
|
|
public void OnCloseBtnClick()
|
|
{
|
|
if(AucationingPanelCtr.Instance)
|
|
{
|
|
if(AucationingPanelCtr.Instance.numBoard._NumBoard.gameObject.activeInHierarchy)
|
|
{
|
|
AucationingPanelCtr.Instance.numBoard._NumBoard.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
UIManager.CloseUI(UIInfo.AucationCtr);
|
|
}
|
|
|
|
//计算当前活动的剩余时间
|
|
private int remainSeconds = 0;
|
|
private bool isNeedCountRemainTime = false;
|
|
public void CountRemainTime()
|
|
{
|
|
var activityBaseDic = TableManager.GetActivityBase().Values;
|
|
foreach (var activity in activityBaseDic)
|
|
{
|
|
//当前活动为寻宝任务
|
|
if (activity.ActivityServerType == (int)ActivityDataManager.Activity_Type.ACTIVITY_TYPE_GRAB_TREASURE)
|
|
{
|
|
//记录当前活动的结束时间
|
|
int endTimeFromTab = int.Parse(activity.GetTimebyIndex(0).Split('|')[1]);
|
|
|
|
DateTime curServerTime = GCGame.Utils.GetServerDateTime();
|
|
|
|
int endHour = endTimeFromTab / 100;
|
|
int endMinute = endTimeFromTab % 100;
|
|
|
|
int curHour = curServerTime.Hour;
|
|
int curMinute = curServerTime.Minute;
|
|
int curSecond = curServerTime.Second;
|
|
|
|
remainSeconds = (endHour * 3600 + endMinute * 60 - curHour * 3600 - curMinute * 60 - curSecond); //剩余秒数
|
|
|
|
if (remainSeconds > 0)
|
|
{
|
|
isNeedCountRemainTime = true;
|
|
}
|
|
else
|
|
{
|
|
isNeedCountRemainTime = false;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
private float countTime = 0.0f;
|
|
private void Update()
|
|
{
|
|
if(isNeedCountRemainTime)
|
|
{
|
|
countTime += Time.deltaTime;
|
|
if(countTime > 1.0f)
|
|
{
|
|
remainSeconds--;
|
|
countTime = 1.0f - countTime;
|
|
if(remainSeconds <= 0)
|
|
{
|
|
isNeedCountRemainTime = false;
|
|
OnCloseBtnClick();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void OnHelpBtn()
|
|
{
|
|
MessageHelpLogic.ShowHelpMessage(64);
|
|
}
|
|
}
|