forked from moto2002/mobahero_src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ViewMsgMonitor.cs
520 lines (492 loc) · 17.8 KB
/
ViewMsgMonitor.cs
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
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
using Assets.Scripts.Model;
using Assets.Scripts.Server;
using Com.Game.Module;
using ExitGames.Client.Photon;
using MobaProtocol;
using MobaProtocol.Data;
using System;
using System.Collections.Generic;
public class ViewMsgMonitor : IGlobalComServer
{
private CoroutineManager m_CoroutineManager;
private string oldNotificationDataContent = string.Empty;
private object[] mgs;
public void OnAwake()
{
}
public void OnStart()
{
this.RegistHandler();
this.m_CoroutineManager = new CoroutineManager();
}
public void OnUpdate()
{
}
public void OnDestroy()
{
this.UnregistHandler();
}
public void Enable(bool b)
{
}
public void OnRestart()
{
}
public void OnApplicationQuit()
{
}
public void OnApplicationFocus(bool isFocus)
{
MobaMessage message = MobaMessageManager.GetMessage((ClientMsg)25063, isFocus, 0f);
MobaMessageManager.ExecuteMsg(message);
}
public void OnApplicationPause(bool isPause)
{
MobaMessage message = MobaMessageManager.GetMessage((ClientMsg)25064, isPause, 0f);
MobaMessageManager.ExecuteMsg(message);
}
private void RegistHandler()
{
this.mgs = new object[]
{
MobaUserDataCode.UD_StatusChanged,
MobaChatCode.Chat_NoticePrivateNewMsg,
MobaUserDataCode.UD_ClientRichGiftUser
};
MVC_MessageManager.AddListener_view(MobaGameCode.CompleteTaskMessage, new MobaMessageFunc(this.OnGetMsg_CompleteTaskMessage));
MVC_MessageManager.AddListener_view(MobaGameCode.SystemNotice, new MobaMessageFunc(this.OnGetMsg_SystemNotice));
MVC_MessageManager.AddListener_view(MobaGameCode.GetMailList, new MobaMessageFunc(this.OnGetMailList));
MVC_MessageManager.AddListener_view(MobaGameCode.GetChargeInfo, new MobaMessageFunc(this.OnGetChargeInfo));
MVC_MessageManager.AddListener_view(MobaGameCode.GetCurrencyCount, new MobaMessageFunc(this.OnGetCurrencyCount));
MVC_MessageManager.AddListener_view(MobaFriendCode.Friend_StatusChange, new MobaMessageFunc(this.OnGetMsg_Friend_StatusChange));
MVC_MessageManager.AddListener_view(MobaTeamRoomCode.Room_InviteJoinRoom, new MobaMessageFunc(this.OnGetMsg_Room_InviteJoinRoom));
MVC_MessageManager.AddListener_view(MobaTeamRoomCode.Room_NotifyErrorInfo, new MobaMessageFunc(this.OnGetMsg_Room_NotifyErrorInfo));
Singleton<PvpRoomView>.Instance.RegisterCallBack();
MobaMessageManagerTools.RegistMsg(this, this.mgs, true, "OnMsg_");
}
private void UnregistHandler()
{
MVC_MessageManager.RemoveListener_view(MobaGameCode.CompleteTaskMessage, new MobaMessageFunc(this.OnGetMsg_CompleteTaskMessage));
MVC_MessageManager.RemoveListener_view(MobaGameCode.SystemNotice, new MobaMessageFunc(this.OnGetMsg_SystemNotice));
MVC_MessageManager.RemoveListener_view(MobaGameCode.GetMailList, new MobaMessageFunc(this.OnGetMailList));
MVC_MessageManager.RemoveListener_view(MobaGameCode.GetChargeInfo, new MobaMessageFunc(this.OnGetChargeInfo));
MVC_MessageManager.RemoveListener_view(MobaGameCode.GetCurrencyCount, new MobaMessageFunc(this.OnGetCurrencyCount));
MVC_MessageManager.RemoveListener_view(MobaFriendCode.Friend_StatusChange, new MobaMessageFunc(this.OnGetMsg_Friend_StatusChange));
MVC_MessageManager.RemoveListener_view(MobaTeamRoomCode.Room_InviteJoinRoom, new MobaMessageFunc(this.OnGetMsg_Room_InviteJoinRoom));
MVC_MessageManager.RemoveListener_view(MobaTeamRoomCode.Room_NotifyErrorInfo, new MobaMessageFunc(this.OnGetMsg_Room_NotifyErrorInfo));
Singleton<PvpRoomView>.Instance.CancelCallBack();
MobaMessageManagerTools.RegistMsg(this, this.mgs, false, "OnMsg_");
}
private void OnGetMsg_Room_NotifyErrorInfo(MobaMessage msg)
{
this.OnGetMsg_SystemNotice(msg);
}
private void OnGetMsg_Room_InviteJoinRoom(MobaMessage msg)
{
this.OnGetMsg_SystemNotice(msg);
}
private void OnGetMsg_Friend_StatusChange(MobaMessage msg)
{
OperationResponse operationResponse = msg.Param as OperationResponse;
if (operationResponse == null)
{
return;
}
int num = (int)operationResponse.Parameters[1];
MobaErrorCode mobaErrorCode = (MobaErrorCode)num;
if (mobaErrorCode != MobaErrorCode.Ok)
{
this.OnNotificationEvent(num, operationResponse.DebugMessage, null);
}
else
{
byte[] buffer = operationResponse.Parameters[40] as byte[];
NotificationData notificationData = SerializeHelper.Deserialize<NotificationData>(buffer);
if (notificationData.Type == 14 || notificationData.Type == 15)
{
string[] array = notificationData.Content.Split(new char[]
{
'|'
});
if (array.Length > 1)
{
string s = array[array.Length - 1];
if (Singleton<FriendView>.Instance.newMessageList.Contains(ToolsFacade.Instance.GetUserIdBySummId(long.Parse(s))))
{
Singleton<FriendView>.Instance.newMessageList.Remove(ToolsFacade.Instance.GetUserIdBySummId(long.Parse(s)));
}
}
Singleton<MenuView>.Instance.UpdateFriendNew();
}
this.OnNotificationEvent(num, operationResponse.DebugMessage, notificationData);
}
}
private void OnGetMsg_SystemNotice(MobaMessage msg)
{
OperationResponse operationResponse = msg.Param as OperationResponse;
if (operationResponse == null)
{
return;
}
int num = (int)operationResponse.Parameters[1];
MobaErrorCode mobaErrorCode = (MobaErrorCode)num;
if (mobaErrorCode != MobaErrorCode.Ok)
{
this.OnNotificationEvent(num, operationResponse.DebugMessage, null);
}
else
{
byte[] buffer = operationResponse.Parameters[40] as byte[];
NotificationData notificationData = SerializeHelper.Deserialize<NotificationData>(buffer);
this.OnNotificationEvent(num, operationResponse.DebugMessage, notificationData);
}
}
private void OnGetMsg_OnChangeGroupst(MobaMessage msg)
{
if (msg == null)
{
return;
}
OperationResponse operationResponse = msg.Param as OperationResponse;
if (operationResponse == null)
{
return;
}
int num = (int)operationResponse.Parameters[1];
MobaErrorCode mobaErrorCode = (MobaErrorCode)num;
if (mobaErrorCode != MobaErrorCode.Ok)
{
this.OnNotificationEvent(num, operationResponse.DebugMessage, null);
}
else
{
byte[] buffer = operationResponse.Parameters[40] as byte[];
NotificationData notificationData = SerializeHelper.Deserialize<NotificationData>(buffer);
this.OnNotificationEvent(num, operationResponse.DebugMessage, notificationData);
}
}
private void OnGetMsg_CompleteTaskMessage(MobaMessage msg)
{
OperationResponse operationResponse = msg.Param as OperationResponse;
if (operationResponse == null)
{
return;
}
int num = (int)operationResponse.Parameters[1];
MobaErrorCode mobaErrorCode = (MobaErrorCode)num;
if (mobaErrorCode == MobaErrorCode.Ok)
{
int num2 = (int)operationResponse.Parameters[123];
int num3 = (int)operationResponse.Parameters[252];
int num4 = (int)operationResponse.Parameters[241];
this.OnCompleteTaskMessage(num4, num2, num3);
if (num4 == 1)
{
SendMsgManager.Instance.SendMsg(MobaGameCode.GetTaskList, null, new object[]
{
num3
});
}
else if (num4 == 3 && (num2 == 10101 || num2 == 10102))
{
Singleton<MenuView>.Instance.UpdateFirstPay();
}
}
}
public void OnCompleteTaskMessage(int type, int taskId, int AchieveId)
{
AchieveAll achieveAll = ModelManager.Instance.Get_AchieveAll_X();
if (achieveAll == null)
{
return;
}
if (type == 1)
{
Singleton<MenuBottomBarView>.Instance.SetNews(2, taskId.ToString());
DetailAchieveData detailAchieveData = achieveAll.detailAchieveDataList.Find((DetailAchieveData obj) => obj.taskid == taskId);
detailAchieveData.isComplete = true;
}
else if (type == 2)
{
Singleton<MenuBottomBarView>.Instance.SetNews(1, taskId.ToString());
DailyTaskData dailyTaskData = achieveAll.dailyTaskList.Find((DailyTaskData obj) => obj.taskid == taskId);
dailyTaskData.isComplete = true;
}
if (GlobalSettings.isLoginByHoolaiSDK)
{
AnalyticsToolManager.Quest(taskId.ToString(), CharacterDataMgr.instance.GetUserLevel(ModelManager.Instance.Get_userData_X().Exp));
}
}
private void OnGetMailList(MobaMessage msg)
{
if (msg == null)
{
return;
}
OperationResponse operationResponse = msg.Param as OperationResponse;
if (operationResponse == null)
{
return;
}
int num = (int)operationResponse.Parameters[1];
MobaErrorCode mobaErrorCode = (MobaErrorCode)num;
if (mobaErrorCode == MobaErrorCode.Ok)
{
Singleton<MenuBottomBarView>.Instance.CheckEmailNewsState();
if (null != Singleton<MailView>.Instance.gameObject && Singleton<MailView>.Instance.gameObject.activeInHierarchy)
{
Singleton<MailView>.Instance.UpdateMailView();
}
}
}
private void OnGetChargeInfo(MobaMessage msg)
{
if (msg == null)
{
return;
}
OperationResponse operationResponse = msg.Param as OperationResponse;
if (operationResponse == null)
{
return;
}
int num = (int)operationResponse.Parameters[1];
MobaErrorCode mobaErrorCode = (MobaErrorCode)num;
if (mobaErrorCode == MobaErrorCode.Ok)
{
PayDimondData payDimondData = SerializeHelper.Deserialize<PayDimondData>(operationResponse.Parameters[84] as byte[]);
SendMsgManager.SendMsgParam param = new SendMsgManager.SendMsgParam(false, "刷新数据...", true, 15f);
int num2 = 2;
SendMsgManager.Instance.SendMsg(MobaGameCode.GetCurrencyCount, param, new object[]
{
num2
});
}
}
private void OnGetCurrencyCount(MobaMessage msg)
{
if (msg == null)
{
return;
}
OperationResponse operationResponse = msg.Param as OperationResponse;
if (operationResponse == null)
{
return;
}
int num = (int)operationResponse.Parameters[1];
MobaErrorCode mobaErrorCode = (MobaErrorCode)num;
if (mobaErrorCode == MobaErrorCode.Ok)
{
int num2 = (int)operationResponse.Parameters[10];
if (num2 == 0)
{
ModelManager.Instance.Get_userData_X().Money = (long)operationResponse.Parameters[61];
ModelManager.Instance.Get_userData_X().Diamonds = (long)operationResponse.Parameters[62];
ModelManager.Instance.Get_userData_X().SmallCap = (int)operationResponse.Parameters[101];
ModelManager.Instance.Get_userData_X().Speaker = (int)operationResponse.Parameters[11];
}
else if (num2 == 1)
{
long money = (long)operationResponse.Parameters[101];
ModelManager.Instance.Get_userData_X().Money = money;
}
else if (num2 == 2)
{
long diamonds = (long)operationResponse.Parameters[101];
ModelManager.Instance.Get_userData_X().Diamonds = diamonds;
}
else if (num2 == 9)
{
int smallCap = (int)operationResponse.Parameters[101];
ModelManager.Instance.Get_userData_X().SmallCap = smallCap;
}
if (Singleton<MenuTopBarView>.Instance.gameObject)
{
Singleton<MenuTopBarView>.Instance.RefreshUI();
}
}
}
private void OnMsg_UD_StatusChanged(MobaMessage msg)
{
OperationResponse operationResponse = msg.Param as OperationResponse;
if (operationResponse == null)
{
return;
}
int num = (int)operationResponse.Parameters[1];
MobaErrorCode mobaErrorCode = (MobaErrorCode)num;
if (mobaErrorCode != MobaErrorCode.Ok)
{
this.OnNotificationEvent(num, operationResponse.DebugMessage, null);
}
else
{
byte[] buffer = operationResponse.Parameters[40] as byte[];
NotificationData notificationData = SerializeHelper.Deserialize<NotificationData>(buffer);
this.OnNotificationEvent(num, operationResponse.DebugMessage, notificationData);
}
}
private void OnMsg_Chat_NoticePrivateNewMsg(MobaMessage msg)
{
OperationResponse operationResponse = msg.Param as OperationResponse;
if (operationResponse == null)
{
return;
}
string content = (string)operationResponse.Parameters[100];
NotificationData notificationData = new NotificationData();
notificationData.Type = 9;
notificationData.Content = content;
this.OnNotificationEvent(0, operationResponse.DebugMessage, notificationData);
}
private void OnMsg_UD_ClientRichGiftUser(MobaMessage msg)
{
Singleton<MenuView>.Instance.UpdateTuhaoHongBao();
}
private void OnNotificationEvent(int ret, string debugMessage, NotificationData notificationData)
{
if (notificationData == null || notificationData.Content == null)
{
return;
}
if (ret == 0)
{
this.oldNotificationDataContent = notificationData.Content;
short type = notificationData.Type;
switch (type + 5)
{
case 0:
MobaMessageManager.ExecuteMsg(MobaMessageManager.GetMessage((ClientMsg)23066, notificationData, 0f));
break;
case 1:
MobaMessageManager.DispatchMsg(MobaMessageManager.GetMessage((ClientMsg)25024, null, 0f));
NetWorkHelper.Instance.Enable(false);
CtrlManager.ShowMsgBox("服务器提示", notificationData.Content, new Action(GlobalObject.QuitApp), PopViewType.PopOneButton, "确定", "取消", null);
break;
case 2:
NetWorkHelper.Instance.Enable(false);
CtrlManager.ShowMsgBox("服务器维护", "请点击确认,退出游戏", new Action(GlobalObject.QuitApp), PopViewType.PopOneButton, "确定", "取消", null);
break;
case 3:
CtrlManager.ShowMsgBox("服务器提示", notificationData.Content, null, PopViewType.PopOneButton, "确定", "取消", null);
break;
case 4:
CtrlManager.ShowMsgBox("服务器重启提示", "服务器已经重启,客户端将在5秒后强制退出,退出后请尝试重新登入!", new Action(GlobalObject.ReStartGame), PopViewType.PopOneButton, "立刻退出", "取消", null);
break;
case 5:
SendMsgManager.Instance.SendMsg(MobaGameCode.GetCurrencyCount, null, new object[]
{
1
});
SendMsgManager.Instance.SendMsg(MobaGameCode.GetCurrencyCount, null, new object[]
{
2
});
break;
case 12:
Singleton<FriendView>.Instance.UpdateNewApply(notificationData.Content);
Singleton<PvpRoomView>.Instance.UpdateApplyState(notificationData.Content);
Singleton<HomeChatview>.Instance.UpdateFriendList(true, string.Empty);
break;
case 14:
Singleton<FriendView>.Instance.AddMessage(notificationData.Content);
Singleton<HomeChatview>.Instance.AddFriendMessage(notificationData.Content);
Singleton<MenuView>.Instance.SetNews(14, "0");
break;
case 15:
Singleton<FriendView>.Instance.UpdateNewApply(notificationData.Content);
Singleton<PvpRoomView>.Instance.UpdateApplyState(notificationData.Content);
break;
case 16:
Singleton<PvpRoomView>.Instance.InviteGoToRoom(notificationData.Content);
break;
case 17:
if (Singleton<PvpRoomView>.Instance.gameObject != null && Singleton<PvpRoomView>.Instance.gameObject.activeInHierarchy)
{
Singleton<PvpRoomView>.Instance.RefuseGoToRoom(notificationData.Content);
}
break;
case 19:
Singleton<FriendView>.Instance.UpdateApplyState(notificationData.Content, true);
Singleton<PvpRoomView>.Instance.UpdateApplyState(notificationData.Content);
if (Singleton<HomeChatview>.Instance.gameObject != null && Singleton<HomeChatview>.Instance.gameObject.activeInHierarchy)
{
Singleton<HomeChatview>.Instance.UnFriended();
}
Singleton<HomeChatview>.Instance.UpdateFriendList(false, notificationData.Content);
break;
case 20:
Singleton<FriendView>.Instance.UpdateApplyState(notificationData.Content, true);
Singleton<PvpRoomView>.Instance.UpdateApplyState(notificationData.Content);
if (Singleton<HomeChatview>.Instance.gameObject != null && Singleton<HomeChatview>.Instance.gameObject.activeInHierarchy)
{
Singleton<HomeChatview>.Instance.UnFriended();
}
Singleton<HomeChatview>.Instance.UpdateFriendList(false, notificationData.Content);
break;
case 23:
{
if (Singleton<FriendView>.Instance.gameObject != null && Singleton<FriendView>.Instance.gameObject.activeInHierarchy)
{
Singleton<FriendView>.Instance.UpdateFriendState(notificationData.Content);
}
if (Singleton<PvpRoomView>.Instance.gameObject != null && Singleton<PvpRoomView>.Instance.gameObject.activeInHierarchy)
{
Singleton<PvpRoomView>.Instance.UpdateFriendState(notificationData.Content);
}
if (Singleton<HomeChatview>.Instance.gameObject != null)
{
Singleton<HomeChatview>.Instance.UpdateFriendState(notificationData.Content);
}
string[] stateStrs = notificationData.Content.Split(new char[]
{
'|'
});
if (stateStrs != null)
{
if (stateStrs.Length >= 3)
{
List<FriendData> list = ModelManager.Instance.Get_FriendDataList_X();
if (list != null)
{
FriendData friendData = list.Find((FriendData _obj) => _obj.TargetId.ToString() == stateStrs[1]);
if (friendData != null)
{
friendData.GameStatus = (sbyte)int.Parse(stateStrs[2]);
}
}
}
Singleton<MenuBottomBarView>.Instance.UpdateFriendNum();
}
break;
}
case 24:
SendMsgManager.Instance.SendMsg(MobaGameCode.GetMailList, null, new object[0]);
break;
case 30:
Singleton<TipView>.Instance.ShowViewSetText("已经在房间中!", 1f);
Singleton<PvpRoomView>.Instance.ErrorToLeve();
break;
case 31:
Singleton<TipView>.Instance.ShowViewSetText("房间关闭!", 1f);
break;
case 32:
Singleton<TipView>.Instance.ShowViewSetText("房间已经满员!", 1f);
break;
case 33:
Singleton<TipView>.Instance.ShowViewSetText("房间已经不存在!", 1f);
break;
case 34:
Singleton<TipView>.Instance.ShowViewSetText("不是房主无法操作!", 1f);
break;
case 35:
Singleton<TipView>.Instance.ShowViewSetText("当前无法修改房间的类型!", 1f);
break;
case 36:
Singleton<TipView>.Instance.ShowViewSetText("不在房间中!", 1f);
break;
}
}
}
}