Files
JJBB/Assets/Project/Script/GUI/Chat/ChatQuestion.cs

86 lines
2.3 KiB
C#
Raw Normal View History

2024-08-23 15:49:34 +08:00
using UnityEngine;
using UnityEngine.UI;
using System;
using System.Collections;
using System.Collections.Generic;
using GCGame.Table;
//聊天频道答题相关
public class ChatQuestion : MonoBehaviour
{
public Text title;
public Text QuestionText;
public Text tip1;
public Text tip2;
float answerOverTime = 0;
float QuestionOverTime = 0;
void Start()
{
InvokeRepeating("TimeDown", 1, 1);
}
public void UpdateInfo(GC_SYNC_QUESTIONS packet)
{
if (packet.Question == -99)
{
gameObject.SetActive(false);
return;
}
if (packet.Channel != ChatInfoLogic.Instance().GetCurChannelType())
return;
gameObject.SetActive(true);
QuestionText.text = StrDictionary.GetClientDictionaryString("#{28012}");
Tab_QuestionBank bank = TableManager.GetQuestionBankByID(packet.Question,0);
if(bank!=null)
{
QuestionText.text = StrDictionary.GetClientDictionaryString("#{28000}",bank.QuestionDesc);
}
answerOverTime = 0;
QuestionOverTime = 0;
if (packet.AnswerCD > 0)
{
answerOverTime = Time.realtimeSinceStartup + packet.AnswerCD;
}
if (packet.QuestionCD > 0)
{
QuestionOverTime = Time.realtimeSinceStartup + packet.QuestionCD;
}
tip1.gameObject.SetActive(packet.QuestionCD > 0 && bank != null);
if(packet.HasWinner==false || packet.Winner=="")
{
tip1.text = StrDictionary.GetClientDictionaryString("#{28010}", bank.RightAnswer);
}
else
{
tip1.text = StrDictionary.GetClientDictionaryString("#{28002}",packet.Winner);
}
}
void TimeDown()
{
if(answerOverTime>0)
{
int LeaveTime = (int)(answerOverTime - Time.realtimeSinceStartup);
if (LeaveTime < 0)
LeaveTime = 0;
tip2.text = StrDictionary.GetClientDictionaryString("#{28014}", LeaveTime);
}
if(QuestionOverTime>0)
{
int LeaveTime = (int)(QuestionOverTime - Time.realtimeSinceStartup);
if (LeaveTime < 0)
LeaveTime = 0;
tip2.text = StrDictionary.GetClientDictionaryString("#{28013}", LeaveTime);
}
}
}