using System; using System.Collections.Generic; using KKSG; using XMainClient.UI; using XMainClient.UI.UICommon; using XUtliPoolLib; namespace XMainClient { internal class XVoiceQADocument : XDocComponent { public override uint ID { get { return XVoiceQADocument.uuID; } } public QAConditionTable QaConfigTable { get { return XVoiceQADocument._qaconfigTable; } } public QuestionLibraryTable QuestionTable { get { return XVoiceQADocument._questionTable; } } public QALevelRewardTable QaLevelRewardTable { get { return XVoiceQADocument._qaLevelRewardTable; } } public List AnswerList { get { return this._answerList; } } public uint CurrentType { get { return this._currentType; } set { this._currentType = value; } } public new static readonly uint uuID = XSingleton.singleton.XHash("VoiceQADocument"); public static XTableAsyncLoader AsyncLoader = new XTableAsyncLoader(); private static QAConditionTable _qaconfigTable = new QAConditionTable(); private static QuestionLibraryTable _questionTable = new QuestionLibraryTable(); private static QALevelRewardTable _qaLevelRewardTable = new QALevelRewardTable(); private Dictionary _nameIndex = new Dictionary(); private List _answerList = new List(); public SeqListRef Reward; public SeqListRef ExtraReward; public List ScoreList = new List(); public uint MyScore = 0u; private uint _currentType = 1u; public uint TempType; public bool IsVoiceQAIng = false; public bool IsNowDesRight = false; public bool IsAutoPlay = true; public bool IsFirstOpenUI = false; public bool MainInterFaceBtnState = false; public override void OnAttachToHost(XObject host) { base.OnAttachToHost(host); } public static void Execute(OnLoadedCallback callback = null) { XVoiceQADocument.AsyncLoader.AddTask("Table/QuestionLibrary", XVoiceQADocument._questionTable, false); XVoiceQADocument.AsyncLoader.AddTask("Table/QALevelReward", XVoiceQADocument._qaLevelRewardTable, false); XVoiceQADocument.AsyncLoader.AddTask("Table/QACondition", XVoiceQADocument._qaconfigTable, false); XVoiceQADocument.AsyncLoader.Execute(callback); } protected override void EventSubscribe() { base.EventSubscribe(); base.RegisterEvent(XEventDefine.XEvent_PlayerLevelChange, new XComponent.XEventHandler(this.OnPlayerLevelChange)); } protected override void OnReconnected(XReconnectedEventArgs arg) { bool flag = DlgBase.singleton.IsVisible(); if (flag) { this.SendQueryVoiceQAInfo(); } } public override void OnEnterSceneFinally() { base.OnEnterSceneFinally(); bool flag = DlgBase.singleton.IsVisible(); if (flag) { bool isVoiceQAIng = this.IsVoiceQAIng; if (isVoiceQAIng) { DlgBase.singleton.OnVoiceBtnAppear(0u); } else { bool flag2 = this.TempType > 0u; if (flag2) { DlgBase.singleton.OnVoiceBtnAppear(this.TempType); } } } } public void VoiceQAInit(uint type) { this._currentType = type; this.IsAutoPlay = (XSingleton.singleton.IsWifiEnable() || !XSingleton.singleton.IsChannelAutoPlayEnable(ChatChannelType.ZeroChannel)); } public void VoiceQAJoinChoose(bool join, uint type) { this.TempType = 0u; this._answerList.Clear(); RpcC2G_AgreeQAReq rpcC2G_AgreeQAReq = new RpcC2G_AgreeQAReq(); rpcC2G_AgreeQAReq.oArg.agree = join; rpcC2G_AgreeQAReq.oArg.type = type; XSingleton.singleton.Send(rpcC2G_AgreeQAReq); } public void SendAnswer(string ans, ulong audioID, uint audioTime) { bool flag = ans.Length == 0; if (!flag) { PtcC2M_CommitAnswerNtf ptcC2M_CommitAnswerNtf = new PtcC2M_CommitAnswerNtf(); ptcC2M_CommitAnswerNtf.Data.audiouid = audioID; ptcC2M_CommitAnswerNtf.Data.answer = ans; ptcC2M_CommitAnswerNtf.Data.audiotime = audioTime; XSingleton.singleton.Send(ptcC2M_CommitAnswerNtf); } } public void SendQueryVoiceQAInfo() { RpcC2M_GetQADataReq rpc = new RpcC2M_GetQADataReq(); XSingleton.singleton.Send(rpc); } public void SetVoiceQAInfo(GetQADataRes data) { XSingleton.singleton.AddLog("Get VoiceQA data for server, Time = ", data.leftTime.ToString(), " question id = ", data.serialnum.ToString(), null, null, XDebugColor.XDebug_None); bool flag = DlgBase.singleton.IsVisible(); if (flag) { DlgBase.singleton.RefreshPage((int)data.serialnum, data.qid, data.leftTime); } } public void SetRankList(List list, uint myscore) { this.MyScore = myscore; this.ScoreList.Clear(); for (int i = 0; i < list.Count; i++) { QARoomRankData qaroomRankData = new QARoomRankData(); qaroomRankData.uuid = list[i].uuid; qaroomRankData.score = list[i].score; this.ScoreList.Add(qaroomRankData); } bool flag = DlgBase.singleton.IsVisible(); if (flag) { DlgBase.singleton.RefreshRank(); } } public void SetQuestion(int id, uint index) { this.IsNowDesRight = false; bool flag = DlgBase.singleton.IsVisible(); if (flag) { DlgBase.singleton.SetQuestion(id, index, true, 0.0); } } public void NextQuestionQuery() { PtcC2M_GiveUpQAQuestionNtf proto = new PtcC2M_GiveUpQAQuestionNtf(); XSingleton.singleton.Send(proto); } public void VoiceQAStatement(uint totol, uint right, List list) { this.TempType = 0u; this.IsVoiceQAIng = false; this.MainInterFaceBtnState = false; DlgBase.singleton.RefreshH5ButtonState(XSysDefine.XSys_GuildRelax_VoiceQA, true); bool flag = totol == 10000u || right == 10000u; if (!flag) { bool flag2 = DlgBase.singleton.IsVisible(); if (flag2) { DlgBase.singleton.VoiceQAEnd(totol, right, list); } } } public void DealWithNameIndex(List list) { this._nameIndex.Clear(); this.ScoreList.Clear(); this.MyScore = 0u; for (int i = 0; i < list.Count; i++) { this._nameIndex[list[i].uuid] = list[i].name; QARoomRankData qaroomRankData = new QARoomRankData(); qaroomRankData.uuid = list[i].uuid; qaroomRankData.score = 0u; this.ScoreList.Add(qaroomRankData); } bool flag = DlgBase.singleton.IsVisible(); if (flag) { DlgBase.singleton.RefreshRank(); } } public string GetPlayerNameByRoleID(ulong roleID) { string result = ""; bool flag = !this._nameIndex.TryGetValue(roleID, out result); if (flag) { XSingleton.singleton.AddErrorLog("Can't find player name by roleID, roleID = ", roleID.ToString(), null, null, null, null); } return result; } public void AddEnterRoomInfo2List(QAEnterRoomNtf data) { VoiceAnswer voiceAnswer = new VoiceAnswer(); voiceAnswer.isEnterRoom = true; voiceAnswer.roleId = data.roleID; voiceAnswer.name = data.name; voiceAnswer.profession = data.profession; voiceAnswer.answerTime = data.time; voiceAnswer.desID = data.coverDesignationID; voiceAnswer.times = 0u; voiceAnswer.content = ""; voiceAnswer.right = false; voiceAnswer.rank = 999u; voiceAnswer.audioTime = 0u; voiceAnswer.audioID = 0UL; voiceAnswer.isNew = true; this._answerList.Add(voiceAnswer); this._nameIndex[data.roleID] = data.name; QARoomRankData qaroomRankData = new QARoomRankData(); qaroomRankData.uuid = data.roleID; qaroomRankData.score = 0u; this.ScoreList.Add(qaroomRankData); bool flag = DlgBase.singleton.IsVisible(); if (flag) { DlgBase.singleton.RefreshList(); DlgBase.singleton.RefreshRank(); } } public void AddAnswer2List(AnswerAckNtf data) { VoiceAnswer voiceAnswer = new VoiceAnswer(); voiceAnswer.isEnterRoom = false; voiceAnswer.roleId = data.roleId; voiceAnswer.audioID = data.audioUid; voiceAnswer.name = data.userName; voiceAnswer.content = data.answer; voiceAnswer.right = data.correct; voiceAnswer.times = data.times; voiceAnswer.rank = data.rank; voiceAnswer.answerTime = data.answertime; voiceAnswer.desID = data.coverDesignationId; voiceAnswer.audioTime = data.audioTime; voiceAnswer.profession = data.profession; voiceAnswer.isNew = true; this._answerList.Add(voiceAnswer); bool flag = DlgBase.singleton.IsVisible(); if (flag) { DlgBase.singleton.RefreshList(); } } public void OpenView() { DlgBase.singleton.SetVisible(true, true); } public void GetReward() { uint level = XSingleton.singleton.XPlayerData.Level; foreach (QALevelRewardTable.RowData rowData in XVoiceQADocument._qaLevelRewardTable.Table) { bool flag = rowData.QAType == this._currentType && level >= rowData.MinLevel && level <= rowData.MaxLevel; if (flag) { this.Reward = rowData.Reward; this.ExtraReward = rowData.ExtraReward; return; } } XSingleton.singleton.AddErrorLog("Can't Find QALevelReward!!! Level = ", level.ToString(), "QAType = ", this._currentType.ToString(), null, null); } public void LevelUp() { bool flag = this.TempType == 0u; if (!flag) { QAConditionTable.RowData byQAType = XVoiceQADocument._qaconfigTable.GetByQAType((int)this.TempType); bool flag2 = byQAType == null; if (!flag2) { uint level = XSingleton.singleton.XPlayerData.Level; for (int i = 0; i < byQAType.LevelSection.Count; i++) { bool flag3 = level >= byQAType.LevelSection[i, 0] && level <= byQAType.LevelSection[i, 1]; if (flag3) { return; } } this.TempType = 0u; this.IsVoiceQAIng = false; this.MainInterFaceBtnState = false; DlgBase.singleton.RefreshH5ButtonState(XSysDefine.XSys_GuildRelax_VoiceQA, true); } } } public void IDIPClearRoleMsg(ulong roleID) { for (int i = this._answerList.Count - 1; i >= 0; i--) { bool flag = this._answerList[i].roleId == roleID; if (flag) { this._answerList.RemoveAt(i); } } bool flag2 = DlgBase.singleton.IsVisible(); if (flag2) { DlgBase.singleton.RefreshList(); } } private bool OnPlayerLevelChange(XEventArgs arg) { this.LevelUp(); return true; } } }