1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
|
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<VoiceAnswer> AnswerList
{
get
{
return this._answerList;
}
}
public uint CurrentType
{
get
{
return this._currentType;
}
set
{
this._currentType = value;
}
}
public new static readonly uint uuID = XSingleton<XCommon>.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<ulong, string> _nameIndex = new Dictionary<ulong, string>();
private List<VoiceAnswer> _answerList = new List<VoiceAnswer>();
public SeqListRef<uint> Reward;
public SeqListRef<uint> ExtraReward;
public List<QARoomRankData> ScoreList = new List<QARoomRankData>();
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<XVoiceQAView, XVoiceQABehaviour>.singleton.IsVisible();
if (flag)
{
this.SendQueryVoiceQAInfo();
}
}
public override void OnEnterSceneFinally()
{
base.OnEnterSceneFinally();
bool flag = DlgBase<XMainInterface, XMainInterfaceBehaviour>.singleton.IsVisible();
if (flag)
{
bool isVoiceQAIng = this.IsVoiceQAIng;
if (isVoiceQAIng)
{
DlgBase<XMainInterface, XMainInterfaceBehaviour>.singleton.OnVoiceBtnAppear(0u);
}
else
{
bool flag2 = this.TempType > 0u;
if (flag2)
{
DlgBase<XMainInterface, XMainInterfaceBehaviour>.singleton.OnVoiceBtnAppear(this.TempType);
}
}
}
}
public void VoiceQAInit(uint type)
{
this._currentType = type;
this.IsAutoPlay = (XSingleton<XClientNetwork>.singleton.IsWifiEnable() || !XSingleton<XChatIFlyMgr>.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<XClientNetwork>.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<XClientNetwork>.singleton.Send(ptcC2M_CommitAnswerNtf);
}
}
public void SendQueryVoiceQAInfo()
{
RpcC2M_GetQADataReq rpc = new RpcC2M_GetQADataReq();
XSingleton<XClientNetwork>.singleton.Send(rpc);
}
public void SetVoiceQAInfo(GetQADataRes data)
{
XSingleton<XDebug>.singleton.AddLog("Get VoiceQA data for server, Time = ", data.leftTime.ToString(), " question id = ", data.serialnum.ToString(), null, null, XDebugColor.XDebug_None);
bool flag = DlgBase<XVoiceQAView, XVoiceQABehaviour>.singleton.IsVisible();
if (flag)
{
DlgBase<XVoiceQAView, XVoiceQABehaviour>.singleton.RefreshPage((int)data.serialnum, data.qid, data.leftTime);
}
}
public void SetRankList(List<QARoomRankData> 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<XVoiceQAView, XVoiceQABehaviour>.singleton.IsVisible();
if (flag)
{
DlgBase<XVoiceQAView, XVoiceQABehaviour>.singleton.RefreshRank();
}
}
public void SetQuestion(int id, uint index)
{
this.IsNowDesRight = false;
bool flag = DlgBase<XVoiceQAView, XVoiceQABehaviour>.singleton.IsVisible();
if (flag)
{
DlgBase<XVoiceQAView, XVoiceQABehaviour>.singleton.SetQuestion(id, index, true, 0.0);
}
}
public void NextQuestionQuery()
{
PtcC2M_GiveUpQAQuestionNtf proto = new PtcC2M_GiveUpQAQuestionNtf();
XSingleton<XClientNetwork>.singleton.Send(proto);
}
public void VoiceQAStatement(uint totol, uint right, List<ItemBrief> list)
{
this.TempType = 0u;
this.IsVoiceQAIng = false;
this.MainInterFaceBtnState = false;
DlgBase<XMainInterface, XMainInterfaceBehaviour>.singleton.RefreshH5ButtonState(XSysDefine.XSys_GuildRelax_VoiceQA, true);
bool flag = totol == 10000u || right == 10000u;
if (!flag)
{
bool flag2 = DlgBase<XVoiceQAView, XVoiceQABehaviour>.singleton.IsVisible();
if (flag2)
{
DlgBase<XVoiceQAView, XVoiceQABehaviour>.singleton.VoiceQAEnd(totol, right, list);
}
}
}
public void DealWithNameIndex(List<QAIDName> 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<XVoiceQAView, XVoiceQABehaviour>.singleton.IsVisible();
if (flag)
{
DlgBase<XVoiceQAView, XVoiceQABehaviour>.singleton.RefreshRank();
}
}
public string GetPlayerNameByRoleID(ulong roleID)
{
string result = "";
bool flag = !this._nameIndex.TryGetValue(roleID, out result);
if (flag)
{
XSingleton<XDebug>.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<XVoiceQAView, XVoiceQABehaviour>.singleton.IsVisible();
if (flag)
{
DlgBase<XVoiceQAView, XVoiceQABehaviour>.singleton.RefreshList();
DlgBase<XVoiceQAView, XVoiceQABehaviour>.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<XVoiceQAView, XVoiceQABehaviour>.singleton.IsVisible();
if (flag)
{
DlgBase<XVoiceQAView, XVoiceQABehaviour>.singleton.RefreshList();
}
}
public void OpenView()
{
DlgBase<XVoiceQAView, XVoiceQABehaviour>.singleton.SetVisible(true, true);
}
public void GetReward()
{
uint level = XSingleton<XAttributeMgr>.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<XDebug>.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<XAttributeMgr>.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<XMainInterface, XMainInterfaceBehaviour>.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<XVoiceQAView, XVoiceQABehaviour>.singleton.IsVisible();
if (flag2)
{
DlgBase<XVoiceQAView, XVoiceQABehaviour>.singleton.RefreshList();
}
}
private bool OnPlayerLevelChange(XEventArgs arg)
{
this.LevelUp();
return true;
}
}
}
|