summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/Guild/XGuildJokerDocument.cs
blob: d4dfe1c9dd2fe52a6c9c62c8e81d3eb35b96a30b (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
285
286
287
288
using System;
using System.Collections.Generic;
using UnityEngine;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

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

		public uint CardResult { get; set; }

		public uint CardStore { get; set; }

		public int GameCount { get; set; }

		public int ChangeCount { get; set; }

		public int BuyChangeCount { get; set; }

		public List<string> RankNames
		{
			get
			{
				bool flag = this.m_RankNames == null;
				if (flag)
				{
					this.m_RankNames = new List<string>();
				}
				return this.m_RankNames;
			}
		}

		public List<int> RankScores
		{
			get
			{
				bool flag = this.m_RankScores == null;
				if (flag)
				{
					this.m_RankScores = new List<int>();
				}
				return this.m_RankScores;
			}
		}

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

		public static XTableAsyncLoader AsyncLoader = new XTableAsyncLoader();

		public static CardRewardTable _CardRewardTable = new CardRewardTable();

		public static CardStoreTable _CardStoreTable = new CardStoreTable();

		public List<uint> CurrentCard = new List<uint>();

		public List<uint> BestCard = new List<uint>();

		public string BestName;

		public uint JokerToken;

		public bool WaitRpc = false;

		private float guildJokerStartTime = 0f;

		private List<string> m_RankNames;

		private List<int> m_RankScores;

		public static void Execute(OnLoadedCallback callback = null)
		{
			XGuildJokerDocument.AsyncLoader.AddTask("Table/CardReward", XGuildJokerDocument._CardRewardTable, false);
			XGuildJokerDocument.AsyncLoader.AddTask("Table/CardStore", XGuildJokerDocument._CardStoreTable, false);
			XGuildJokerDocument.AsyncLoader.Execute(callback);
		}

		protected override void EventSubscribe()
		{
			base.EventSubscribe();
		}

		public override void OnEnterScene()
		{
			base.OnEnterScene();
			bool flag = XSingleton<XGame>.singleton.CurrentStage.Stage == EXStage.Hall;
			if (flag)
			{
				this.QueryGameCount();
			}
		}

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

		public void SendJokerRank(uint type)
		{
			PtcC2M_GuildCardRankReq ptcC2M_GuildCardRankReq = new PtcC2M_GuildCardRankReq();
			ptcC2M_GuildCardRankReq.Data.type = type;
			XSingleton<XClientNetwork>.singleton.Send(ptcC2M_GuildCardRankReq);
		}

		public void ReceiveJockerRank(List<string> names, List<int> scores)
		{
			this.m_RankNames = names;
			this.m_RankScores = scores;
			bool flag = DlgBase<XGuildJokerView, XGuildJokerBehaviour>.singleton.IsVisible();
			if (flag)
			{
				DlgBase<XGuildJokerView, XGuildJokerBehaviour>.singleton.SetRankData(names.Count);
			}
		}

		public void SendStartGame()
		{
			bool flag = Time.time - this.guildJokerStartTime < 2f;
			if (!flag)
			{
				this.guildJokerStartTime = Time.time;
				RpcC2G_StartGuildCard rpc = new RpcC2G_StartGuildCard();
				XSingleton<XClientNetwork>.singleton.Send(rpc);
			}
		}

		public void SendChangeCard(uint card)
		{
			bool waitRpc = this.WaitRpc;
			if (!waitRpc)
			{
				this.WaitRpc = true;
				RpcC2G_ChangeGuildCard rpcC2G_ChangeGuildCard = new RpcC2G_ChangeGuildCard();
				rpcC2G_ChangeGuildCard.oArg.card = card;
				XSingleton<XClientNetwork>.singleton.Send(rpcC2G_ChangeGuildCard);
			}
		}

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

		public void SetGameCount(uint gameCount, uint changeCount, uint buyChangeCount)
		{
			this.GameCount = (int)gameCount;
			this.ChangeCount = (int)changeCount;
			this.BuyChangeCount = (int)buyChangeCount;
			XGuildRelaxGameDocument specificDocument = XDocuments.GetSpecificDocument<XGuildRelaxGameDocument>(XGuildRelaxGameDocument.uuID);
			specificDocument.RefreshRedPoint();
			XSingleton<XGameSysMgr>.singleton.RecalculateRedPointState(XSysDefine.XSys_GuildRelax_Joker, true);
			bool flag = !DlgBase<XGuildJokerView, XGuildJokerBehaviour>.singleton.IsVisible();
			if (!flag)
			{
				DlgBase<XGuildJokerView, XGuildJokerBehaviour>.singleton.SetGameCount();
			}
		}

		public void ShowCard(List<uint> card, uint result, uint store)
		{
			this.CardResult = result;
			this.CardStore = store;
			this.GameCount = Math.Max(0, this.GameCount - 1);
			this.CurrentCard.Clear();
			for (int i = 0; i < card.Count; i++)
			{
				this.CurrentCard.Add(card[i]);
			}
			XGuildRelaxGameDocument specificDocument = XDocuments.GetSpecificDocument<XGuildRelaxGameDocument>(XGuildRelaxGameDocument.uuID);
			specificDocument.RefreshRedPoint();
			bool flag = !DlgBase<XGuildJokerView, XGuildJokerBehaviour>.singleton.IsVisible();
			if (!flag)
			{
				DlgBase<XGuildJokerView, XGuildJokerBehaviour>.singleton.RefreshCard();
				DlgBase<XGuildJokerView, XGuildJokerBehaviour>.singleton.SetCurrentReward();
				DlgBase<XGuildJokerView, XGuildJokerBehaviour>.singleton.SetGameTipStatus(true);
				DlgBase<XGuildJokerView, XGuildJokerBehaviour>.singleton.SetGameCount();
				DlgBase<XGuildJokerView, XGuildJokerBehaviour>.singleton.SetCardStore();
				bool flag2 = this.CardResult != 8u;
				if (flag2)
				{
					DlgBase<XGuildJokerView, XGuildJokerBehaviour>.singleton.SetButtonTip("GET_REWARD");
				}
				else
				{
					DlgBase<XGuildJokerView, XGuildJokerBehaviour>.singleton.SetButtonTip("END_GAME");
				}
			}
		}

		public void ChangeCard(uint oldCard, uint newCard, uint result)
		{
			this.WaitRpc = false;
			bool flag = this.ChangeCount != 0;
			if (flag)
			{
				this.ChangeCount--;
			}
			else
			{
				this.BuyChangeCount++;
			}
			this.CardResult = result;
			int cardNum = 0;
			for (int i = 0; i < this.CurrentCard.Count; i++)
			{
				bool flag2 = this.CurrentCard[i] != oldCard;
				if (!flag2)
				{
					this.CurrentCard[i] = newCard;
					cardNum = i;
				}
			}
			bool flag3 = !DlgBase<XGuildJokerView, XGuildJokerBehaviour>.singleton.IsVisible();
			if (!flag3)
			{
				DlgBase<XGuildJokerView, XGuildJokerBehaviour>.singleton.ChangeCard(oldCard, newCard, cardNum);
				DlgBase<XGuildJokerView, XGuildJokerBehaviour>.singleton.SetGameCount();
			}
		}

		public void EndCardGame(uint result)
		{
			bool flag = DlgBase<XGuildJokerView, XGuildJokerBehaviour>.singleton.IsVisible();
			if (flag)
			{
				DlgBase<XGuildJokerView, XGuildJokerBehaviour>.singleton.RefreshRank();
				bool flag2 = this.CardResult != 8u;
				if (flag2)
				{
					XSingleton<XAudioMgr>.singleton.PlayUISound("Audio/UI/pukeshenli", true, AudioChannel.Action);
					DlgBase<XGuildJokerView, XGuildJokerBehaviour>.singleton.JokerStatus(2);
					XSingleton<XTimerMgr>.singleton.KillTimer(this.JokerToken);
					this.JokerToken = XSingleton<XTimerMgr>.singleton.SetTimer(1f, DlgBase<XGuildJokerView, XGuildJokerBehaviour>.singleton.ResetJokerStatusCb, null);
				}
				else
				{
					XSingleton<XAudioMgr>.singleton.PlayUISound("Audio/UI/pukeshibai", true, AudioChannel.Action);
					DlgBase<XGuildJokerView, XGuildJokerBehaviour>.singleton.JokerStatus(3);
					XSingleton<XTimerMgr>.singleton.KillTimer(this.JokerToken);
					this.JokerToken = XSingleton<XTimerMgr>.singleton.SetTimer(1f, DlgBase<XGuildJokerView, XGuildJokerBehaviour>.singleton.ResetJokerStatusCb, null);
				}
			}
			this.CurrentCard.Clear();
			this.CardResult = 8u;
			this.CardStore = 5u;
			bool flag3 = !DlgBase<XGuildJokerView, XGuildJokerBehaviour>.singleton.IsVisible();
			if (!flag3)
			{
				DlgBase<XGuildJokerView, XGuildJokerBehaviour>.singleton.ClearCard();
				DlgBase<XGuildJokerView, XGuildJokerBehaviour>.singleton.SetGameTipStatus(false);
				DlgBase<XGuildJokerView, XGuildJokerBehaviour>.singleton.SetButtonTip("START_GAME");
				DlgBase<XGuildJokerView, XGuildJokerBehaviour>.singleton.SetCurrentReward();
				DlgBase<XGuildJokerView, XGuildJokerBehaviour>.singleton.SetCardStore();
			}
		}

		public void SetBestCard(List<uint> card, string name)
		{
			this.BestCard.Clear();
			for (int i = 0; i < card.Count; i++)
			{
				this.BestCard.Add(card[i]);
			}
			this.BestName = name;
			bool flag = !DlgBase<XGuildJokerView, XGuildJokerBehaviour>.singleton.IsVisible();
			if (!flag)
			{
				DlgBase<XGuildJokerView, XGuildJokerBehaviour>.singleton.SetupBestCard();
			}
		}

		protected override void OnReconnected(XReconnectedEventArgs arg)
		{
			this.WaitRpc = false;
		}
	}
}