137 lines
3.5 KiB
C#
137 lines
3.5 KiB
C#
using UnityEngine;
|
|
using System.Collections;
|
|
using UnityEngine.UI;
|
|
using SPacket.SocketInstance;
|
|
using System.Collections.Generic;
|
|
using Games.Events;
|
|
using GCGame.Table;
|
|
|
|
public class ImperialGuessingPanelCtr : MonoBehaviour {
|
|
|
|
public static ImperialGuessingPanelCtr Instance;
|
|
private void Awake()
|
|
{
|
|
Instance = this;
|
|
GetRemainTime();
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
Instance = null;
|
|
}
|
|
|
|
public RoleInfoBtn[] m_RoleInfoBnts; //根据排行榜信息进行初始化
|
|
|
|
public Button CloseBtn;
|
|
public Button SubmitBtn;
|
|
public Text RemainTimeText;
|
|
|
|
public Toggle[] m_RoleInfoToggle;
|
|
|
|
public ulong m_SelectedGuid = 0;
|
|
public float CountTime = 0f;
|
|
|
|
private int GuessingRemainTime = 60;
|
|
public void GetRemainTime()
|
|
{
|
|
var questionOther = TableManager.GetQuestionOtherByID(2, 0);
|
|
if(questionOther != null)
|
|
{
|
|
GuessingRemainTime = questionOther.WaitTime;
|
|
}
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update () {
|
|
if(GuessingRemainTime > 0)
|
|
{
|
|
CountTime += Time.deltaTime;
|
|
if (CountTime >= 1.0f)
|
|
{
|
|
if (GuessingRemainTime > 0)
|
|
{
|
|
GuessingRemainTime--;
|
|
//显示
|
|
RemainTimeText.text = GuessingRemainTime.ToString();
|
|
//滞空
|
|
CountTime = 1.0f - CountTime;
|
|
}
|
|
else
|
|
{
|
|
if (this.gameObject.activeInHierarchy)
|
|
{
|
|
UIManager.CloseUI(UIInfo.ImperialGuessingPanel);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public void SetMyRoleInfoPanel(List<QuestionRankInfoList> m_List, int RemainTime)
|
|
{
|
|
for(int index = 0; index < m_RoleInfoBnts.Length; index++)
|
|
{
|
|
m_RoleInfoBnts[index].gameObject.SetActive(index < m_List.Count ? true : false);
|
|
}
|
|
|
|
for(int index = 0; index < m_List.Count; index++)
|
|
{
|
|
m_RoleInfoBnts[index].GetComponent<RoleInfoBtn>().SetNameAndGuid(m_List[index].name, m_List[index].guid);
|
|
}
|
|
|
|
GuessingRemainTime = RemainTime;;
|
|
}
|
|
|
|
public void OnToggleValueChange(int index)
|
|
{
|
|
if(m_RoleInfoToggle[index].isOn)
|
|
{
|
|
m_SelectedGuid = m_RoleInfoToggle[index].GetComponent<RoleInfoBtn>().RoleGuid;
|
|
}
|
|
|
|
}
|
|
|
|
public void SubmitBtnClick()
|
|
{
|
|
if(m_SelectedGuid == 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
CG_REQ_GUESSING guessing = (CG_REQ_GUESSING)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_GUESSING);
|
|
guessing.SetTargetGuid((ulong)m_SelectedGuid);
|
|
guessing.SendPacket();
|
|
|
|
//发一句话提醒玩家竞猜成功
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{44006}"));
|
|
|
|
CloseBtnClick(); //发送协议 关闭窗口
|
|
ShowWaitPanel();
|
|
}
|
|
|
|
public void ShowWaitPanel()
|
|
{
|
|
if(ImpreialExamPanelCtr.Instance && ImpreialExamPanelCtr.Instance.gameObject.activeInHierarchy)
|
|
{
|
|
ImpreialExamPanelCtr.Instance.ShowWaitPanel();
|
|
}
|
|
else
|
|
{
|
|
UIManager.ShowUI(UIInfo.ImperialExamPanel, delegate (bool bSucess, object param) {
|
|
if (bSucess)
|
|
{
|
|
ImpreialExamPanelCtr.Instance.ShowWaitPanel();
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
public void CloseBtnClick()
|
|
{
|
|
UIManager.CloseUI(UIInfo.ImperialGuessingPanel);
|
|
}
|
|
|
|
}
|