178 lines
5.3 KiB
C#
178 lines
5.3 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using System.Collections;
|
|
using Games.Item;
|
|
using System.Collections.Generic;
|
|
using GCGame.Table;
|
|
using Games.GlobeDefine;
|
|
using GCGame;
|
|
using Module.Log;
|
|
|
|
public class GuanningRegistLogic : UIControllerBase<GuanningRegistLogic>
|
|
{
|
|
void OnEnable ()
|
|
{
|
|
SetInstance(this);
|
|
GuanningRegistLogic.Instance().InitRegister((int)ActivityDataManager.Activity_Type.ACTIVITY_FIGHTYARD);
|
|
}
|
|
|
|
void OnDisable()
|
|
{
|
|
SetInstance(null);
|
|
}
|
|
|
|
public void CloseWindow()
|
|
{
|
|
UIManager.CloseUI(UIInfo.GuanningRegistRoot);
|
|
}
|
|
|
|
public static void InitGuanningRegist(int actBaseID = (int)ActivityDataManager.Activity_Type.ACTIVITY_FIGHTYARD)
|
|
{
|
|
//UIManager.ShowUI(UIInfo.GuanningRegistRoot, ShowUIOver, actBaseID);
|
|
UIManager.ShowUI(UIInfo.GuanningRegistRoot);
|
|
}
|
|
|
|
//static void ShowUIOver(bool bSuccess, object param)
|
|
//{
|
|
// if (bSuccess)
|
|
// {
|
|
// if (GuanningRegistLogic.Instance() != null && param != null)
|
|
// {
|
|
// GuanningRegistLogic.Instance().InitRegister((int)param);
|
|
// }
|
|
// }
|
|
//}
|
|
|
|
#region regist info s
|
|
|
|
public static int _FIGHT_ROUND_CNT = 5;
|
|
public static int _FIGHT_ROUND_INTERVAL = 10;
|
|
public static int _FIGHT_ROUND_REGIST = 9;
|
|
|
|
public class RegistInfo
|
|
{
|
|
public int Idx;
|
|
public string RegistTime;
|
|
public string StarTime;
|
|
public int RegistNum;
|
|
public bool IsRegist;
|
|
public bool IsCanRegist = true;
|
|
}
|
|
|
|
public Text _ActLastTimes;
|
|
|
|
public List<RegistInfo> _ResigtInfos;
|
|
|
|
private void InitRegistInfos()
|
|
{
|
|
var actBase = TableManager.GetActivityBaseByID(_ActBaseID, 0);
|
|
var startTime = int.Parse(actBase.GetTimebyIndex(0).Split('|')[0]);
|
|
|
|
int m_Hour = startTime / 100;
|
|
int m_Minute = startTime % 100;
|
|
|
|
_ResigtInfos = new List<RegistInfo>();
|
|
List<int> listInt = new List<int>();
|
|
for (int i = 0; i < _FIGHT_ROUND_CNT; ++i)
|
|
{
|
|
int itemRegstTime = m_Minute + _FIGHT_ROUND_REGIST + _FIGHT_ROUND_INTERVAL * i;
|
|
int itemStartTime = m_Minute + _FIGHT_ROUND_INTERVAL * (i + 1);
|
|
|
|
RegistInfo registInfo = new RegistInfo();
|
|
registInfo.Idx = i;
|
|
registInfo.RegistTime = m_Hour.ToString() + ":" + string.Format("{0:D2}", m_Minute) + "-" + m_Hour.ToString() + ":" + string.Format("{0:D2}", itemRegstTime);
|
|
registInfo.StarTime = m_Hour.ToString() + ":" + string.Format("{0:D2}", itemStartTime);
|
|
registInfo.RegistNum = 0;
|
|
registInfo.IsRegist = false;
|
|
|
|
//var serverTime = Utils.GetServerDateTime();
|
|
//System.DateTime actTime = new System.DateTime(serverTime.Year, serverTime.Month, serverTime.Day, m_Hour, itemRegstTime, 0);
|
|
//if (serverTime > actTime)
|
|
//{
|
|
// registInfo.IsCanRegist = false;
|
|
//}
|
|
//else
|
|
//{
|
|
// registInfo.IsCanRegist = true;
|
|
//}
|
|
|
|
|
|
listInt.Add(i);
|
|
_ResigtInfos.Add(registInfo);
|
|
}
|
|
_RegistContainer.InitContentItem(listInt);
|
|
|
|
_ActLastTimes.text = StrDictionary.GetClientDictionaryString("#{8155}");
|
|
}
|
|
|
|
public void RegistBattle(int roundID, bool isRegist)
|
|
{
|
|
CG_SIGN_BATTLE_FIELD packet = (CG_SIGN_BATTLE_FIELD)PacketDistributed.CreatePacket(MessageID.PACKET_CG_SIGN_BATTLE_FIELD);
|
|
packet.ActivityID = (uint)_ActBaseID;
|
|
packet.IsSign = isRegist ? 1 : 0;
|
|
packet.Turnid = roundID;
|
|
packet.SendPacket();
|
|
}
|
|
|
|
public void RefreshRegistInfo(GC_BATTLE_FIELD_SIGN_INFO packet)
|
|
{
|
|
LogModule.DebugLog("RefreshRegistInfo:" + packet.turnInfoCount);
|
|
List<BattleFieldTurnInfo> signInfos = new List<BattleFieldTurnInfo>(packet.turnInfoList);
|
|
signInfos.Sort((infoA, intoB) =>
|
|
{
|
|
if (infoA.TurnID > intoB.TurnID)
|
|
return 1;
|
|
else if(infoA.TurnID < intoB.TurnID)
|
|
return -1;
|
|
else
|
|
return 0;
|
|
});
|
|
if (signInfos.Count > 0)
|
|
{
|
|
_RegistContainer.InitContentItem(signInfos);
|
|
}
|
|
|
|
//int lastTime = 3 - packet.UsedCounts;
|
|
//if (lastTime > 0)
|
|
//{
|
|
// _ActLastTimes.text = StrDictionary.GetClientDictionaryString("#{5525}") + lastTime + "/3" + "</color>";
|
|
//}
|
|
//else
|
|
//{
|
|
// _ActLastTimes.text = StrDictionary.GetClientDictionaryString("#{5526}") + lastTime + "/3" + "</color>";
|
|
//}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region
|
|
|
|
public UIContainerBase _RegistContainer;
|
|
|
|
private int _ActBaseID = 0;
|
|
public void InitRegister(int actBaseID)
|
|
{
|
|
_ActBaseID = actBaseID;
|
|
|
|
//InitRegistInfos();
|
|
|
|
CG_OPEN_BATTLE_SIGNERS packet = (CG_OPEN_BATTLE_SIGNERS)PacketDistributed.CreatePacket(MessageID.PACKET_CG_OPEN_BATTLE_SIGNERS);
|
|
packet.ActivityID = (uint)_ActBaseID;
|
|
packet.SendPacket();
|
|
}
|
|
|
|
public void BtnRefresh()
|
|
{
|
|
CG_SIGNER_NUMBER_REFRESH packet = (CG_SIGNER_NUMBER_REFRESH)PacketDistributed.CreatePacket(MessageID.PACKET_CG_SIGNER_NUMBER_REFRESH);
|
|
packet.ActivityID = (uint)_ActBaseID;
|
|
packet.SendPacket();
|
|
}
|
|
|
|
public void OnBtnHelp(int id)
|
|
{
|
|
MessageHelpLogic.ShowHelpMessage(id);
|
|
}
|
|
|
|
#endregion
|
|
}
|