summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/XMobaEntranceDocument.cs
blob: fcf4db9f30fcfdc62af8f5bba56b90b6b9a9f4df (plain)
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
using System;
using System.Collections.Generic;
using KKSG;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

namespace XMainClient
{
	internal class XMobaEntranceDocument : XDocComponent
	{
		public override uint ID
		{
			get
			{
				return XMobaEntranceDocument.uuID;
			}
		}

		public uint MatchTotalPercent
		{
			get
			{
				bool flag = this.MatchTotalCount == 0u;
				uint result;
				if (flag)
				{
					result = 0u;
				}
				else
				{
					bool flag2 = this.WinCount == 0u;
					if (flag2)
					{
						result = 0u;
					}
					else
					{
						result = Math.Max(1u, 100u * this.WinCount / this.MatchTotalCount);
					}
				}
				return result;
			}
		}

		public new static readonly uint uuID = XSingleton<XCommon>.singleton.XHash("MobaEntranceDocument");

		public static XTableAsyncLoader AsyncLoader = new XTableAsyncLoader();

		public static MobaWeekReward _MobaWeekReward = new MobaWeekReward();

		public List<XMobaEntranceDocument.XMobaRecordTotal> RecordTotalList = new List<XMobaEntranceDocument.XMobaRecordTotal>();

		public uint WinThisWeek = 0u;

		public XMobaEntranceDocument.MobaRewardState RewardState = XMobaEntranceDocument.MobaRewardState.CanNotGet;

		public uint GetRewardStage = 0u;

		public uint MatchTotalCount = 0u;

		public uint WinCount = 0u;

		public uint LoseCount = 0u;

		public struct XMobaRecordTotal
		{
			public uint roundID;

			public uint heroID;

			public bool isWin;

			public bool isMVP;

			public bool isLoseMVP;

			public bool isEscape;

			public uint date;
		}

		public struct XMobaRecordRound
		{
			public uint roundID;

			public uint date;

			public uint time;

			public bool isteam1win;

			public List<XMobaEntranceDocument.XMobaRecordDetailOne> team1;

			public List<XMobaEntranceDocument.XMobaRecordDetailOne> team2;

			public ulong mvpid;

			public ulong losemvpid;

			public ulong damagemaxid;

			public ulong behitdamagemaxid;

			public List<XMobaEntranceDocument.XMobaRecordDetailOne> SetMobaRecordDetailOne(List<MobaBattleOneGameRole> oResData)
			{
				List<XMobaEntranceDocument.XMobaRecordDetailOne> list = new List<XMobaEntranceDocument.XMobaRecordDetailOne>(oResData.Count);
				for (int i = 0; i < oResData.Count; i++)
				{
					XMobaEntranceDocument.XMobaRecordDetailOne item = default(XMobaEntranceDocument.XMobaRecordDetailOne);
					item.heroID = oResData[i].heroid;
					item.data.uID = oResData[i].roleid;
					item.data.KillCount = (int)oResData[i].killcount;
					item.data.DeathCount = oResData[i].deathcount;
					item.data.AssitCount = oResData[i].assistcount;
					item.data.Kda = oResData[i].kda;
					item.data.MaxKillCount = (int)oResData[i].multikillcount;
					item.data.isescape = oResData[i].isescape;
					item.data.Name = oResData[i].name;
					list.Add(item);
				}
				return list;
			}
		}

		public struct XMobaRecordDetailOne
		{
			public uint heroID;

			public XLevelRewardDocument.PVPRoleInfo data;
		}

		public enum MobaRewardState
		{
			CanNotGet,
			CanGet,
			GetEnd
		}

		public static void Execute(OnLoadedCallback callback = null)
		{
			XMobaEntranceDocument.AsyncLoader.AddTask("Table/MobaWeekReward", XMobaEntranceDocument._MobaWeekReward, false);
			XMobaEntranceDocument.AsyncLoader.Execute(callback);
		}

		protected override void OnReconnected(XReconnectedEventArgs arg)
		{
			bool flag = DlgBase<MobaEntranceView, MobaEntranceBehaviour>.singleton.IsVisible();
			if (flag)
			{
				this.ReqMobaUIInfo();
			}
		}

		public override void OnEnterSceneFinally()
		{
			bool flag = XSingleton<XScene>.singleton.SceneType == SceneType.SCENE_HALL;
			if (flag)
			{
				this.ReqMobaUIInfo();
			}
		}

		public void ReqMobaUIInfo()
		{
			RpcC2M_GetMobaBattleInfo rpc = new RpcC2M_GetMobaBattleInfo();
			XSingleton<XClientNetwork>.singleton.Send(rpc);
		}

		public void ReqMobaGetReward()
		{
			RpcC2M_GetMobaBattleWeekReward rpc = new RpcC2M_GetMobaBattleWeekReward();
			XSingleton<XClientNetwork>.singleton.Send(rpc);
		}

		public void SetMobaUIInfo(GetMobaBattleInfoArg oArg, GetMobaBattleInfoRes oRes)
		{
			this.WinThisWeek = oRes.winthisweek;
			this.GetRewardStage = oRes.weekprize;
			XSingleton<XGameSysMgr>.singleton.RecalculateRedPointState(XSysDefine.XSys_Moba, true);
			this.RewardState = XMobaEntranceDocument.MobaRewardState.CanNotGet;
			bool getnextweekprize = oRes.getnextweekprize;
			if (getnextweekprize)
			{
				this.RewardState = XMobaEntranceDocument.MobaRewardState.CanGet;
			}
			bool flag = this.GetRewardStage == XMobaEntranceDocument._MobaWeekReward.Table[XMobaEntranceDocument._MobaWeekReward.Table.Length - 1].id;
			if (flag)
			{
				this.GetRewardStage -= 1u;
				this.RewardState = XMobaEntranceDocument.MobaRewardState.GetEnd;
			}
			bool flag2 = DlgBase<MobaEntranceView, MobaEntranceBehaviour>.singleton.IsVisible();
			if (flag2)
			{
				DlgBase<MobaEntranceView, MobaEntranceBehaviour>.singleton.RefreshRaward();
			}
		}

		public void SetMobaNewReward(GetMobaBattleWeekRewardArg oArg, GetMobaBattleWeekRewardRes oRes)
		{
			this.GetRewardStage = oRes.weekprize;
			XSingleton<XGameSysMgr>.singleton.RecalculateRedPointState(XSysDefine.XSys_Moba, true);
			this.RewardState = XMobaEntranceDocument.MobaRewardState.CanNotGet;
			bool getnextweekprize = oRes.getnextweekprize;
			if (getnextweekprize)
			{
				this.RewardState = XMobaEntranceDocument.MobaRewardState.CanGet;
			}
			bool flag = this.GetRewardStage == XMobaEntranceDocument._MobaWeekReward.Table[XMobaEntranceDocument._MobaWeekReward.Table.Length - 1].id;
			if (flag)
			{
				this.GetRewardStage -= 1u;
				this.RewardState = XMobaEntranceDocument.MobaRewardState.GetEnd;
			}
			bool flag2 = DlgBase<MobaEntranceView, MobaEntranceBehaviour>.singleton.IsVisible();
			if (flag2)
			{
				DlgBase<MobaEntranceView, MobaEntranceBehaviour>.singleton.RefreshRaward();
			}
		}

		public void ReqMobaRecordTotal()
		{
			RpcC2M_GetMobaBattleBriefRecord rpc = new RpcC2M_GetMobaBattleBriefRecord();
			XSingleton<XClientNetwork>.singleton.Send(rpc);
		}

		public void SetMobaRecordTotal(GetMobaBattleBriefRecordArg oArg, GetMobaBattleBriefRecordRes oRes)
		{
			this.MatchTotalCount = oRes.totalnum;
			this.WinCount = oRes.winnum;
			this.LoseCount = oRes.totalnum - oRes.winnum;
			this.RecordTotalList.Clear();
			for (int i = 0; i < oRes.brief.Count; i++)
			{
				XMobaEntranceDocument.XMobaRecordTotal item = default(XMobaEntranceDocument.XMobaRecordTotal);
				item.roundID = oRes.brief[i].tag;
				item.heroID = oRes.brief[i].heroid;
				item.isWin = oRes.brief[i].iswin;
				item.isMVP = oRes.brief[i].ismvp;
				item.isLoseMVP = oRes.brief[i].islosemvp;
				item.isEscape = oRes.brief[i].isescape;
				item.date = oRes.brief[i].date;
				this.RecordTotalList.Add(item);
			}
			bool flag = DlgBase<MobaEntranceView, MobaEntranceBehaviour>.singleton.m_MobaBattleRecordHandler != null;
			if (flag)
			{
				DlgBase<MobaEntranceView, MobaEntranceBehaviour>.singleton.m_MobaBattleRecordHandler.Refresh();
			}
		}

		public void ReqMobaRecordRound(uint roundID)
		{
			RpcC2M_GetMobaBattleGameRecord rpcC2M_GetMobaBattleGameRecord = new RpcC2M_GetMobaBattleGameRecord();
			rpcC2M_GetMobaBattleGameRecord.oArg.tag = roundID;
			XSingleton<XClientNetwork>.singleton.Send(rpcC2M_GetMobaBattleGameRecord);
		}

		public void SetMobaRecordRound(GetMobaBattleGameRecordArg oArg, GetMobaBattleGameRecordRes oRes)
		{
			XMobaEntranceDocument.XMobaRecordRound data = default(XMobaEntranceDocument.XMobaRecordRound);
			bool flag = oRes.record != null;
			if (flag)
			{
				data.roundID = oRes.record.tag;
				data.date = oRes.record.date;
				data.time = oRes.record.timeSpan;
				data.isteam1win = (oRes.record.winteamid == 1u);
				data.mvpid = oRes.record.mvpid;
				data.losemvpid = oRes.record.losemvpid;
				data.damagemaxid = oRes.record.damagemaxid;
				data.behitdamagemaxid = oRes.record.behitdamagemaxid;
				data.team1 = data.SetMobaRecordDetailOne(oRes.record.team1);
				data.team2 = data.SetMobaRecordDetailOne(oRes.record.team2);
			}
			bool flag2 = DlgBase<MobaEntranceView, MobaEntranceBehaviour>.singleton.m_MobaBattleRecordHandler != null;
			if (flag2)
			{
				DlgBase<MobaEntranceView, MobaEntranceBehaviour>.singleton.m_MobaBattleRecordHandler.RefreshDetail(data);
			}
		}
	}
}