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

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

		public uint PandoraID
		{
			get
			{
				return this._pandora_id;
			}
		}

		public PandoraHeart.RowData PandoraData
		{
			get
			{
				return this._pandora_data;
			}
		}

		public List<ItemBrief> ItemCache
		{
			get
			{
				return this._items_cache;
			}
		}

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

		public static XTableAsyncLoader AsyncLoader = new XTableAsyncLoader();

		private uint _pandora_id = 0u;

		private PandoraHeart.RowData _pandora_data = null;

		private List<ItemBrief> _items_cache = new List<ItemBrief>();

		private float _last_lottery_time = 0f;

		private static PandoraHeartReward _table = new PandoraHeartReward();

		public static List<uint> ItemList = new List<uint>();

		public static void Execute(OnLoadedCallback callback = null)
		{
			PandoraDocument.AsyncLoader.AddTask("Table/PandoraHeartReward", PandoraDocument._table, false);
			PandoraDocument.AsyncLoader.Execute(callback);
		}

		private void GetShowItemList()
		{
			PandoraDocument.ItemList.Clear();
			for (int i = 0; i < PandoraDocument._table.Table.Length; i++)
			{
				bool flag = this._pandora_id == PandoraDocument._table.Table[i].pandoraid;
				if (flag)
				{
					bool flag2 = (PandoraDocument._table.Table[i].showlevel[0] == 0u && PandoraDocument._table.Table[i].showlevel[1] == 0u) || (PandoraDocument._table.Table[i].showlevel[0] <= XSingleton<XAttributeMgr>.singleton.XPlayerData.Level && PandoraDocument._table.Table[i].showlevel[1] >= XSingleton<XAttributeMgr>.singleton.XPlayerData.Level);
					if (flag2)
					{
						bool flag3 = !PandoraDocument.ItemList.Contains(PandoraDocument._table.Table[i].itemid);
						if (flag3)
						{
							PandoraDocument.ItemList.Add(PandoraDocument._table.Table[i].itemid);
						}
					}
				}
			}
		}

		public void GetShowItemList(uint pandoraid)
		{
			PandoraDocument.ItemList.Clear();
			for (int i = 0; i < PandoraDocument._table.Table.Length; i++)
			{
				bool flag = pandoraid == PandoraDocument._table.Table[i].pandoraid;
				if (flag)
				{
					bool flag2 = (PandoraDocument._table.Table[i].showlevel[0] == 0u && PandoraDocument._table.Table[i].showlevel[1] == 0u) || (PandoraDocument._table.Table[i].showlevel[0] <= XSingleton<XAttributeMgr>.singleton.XPlayerData.Level && PandoraDocument._table.Table[i].showlevel[1] >= XSingleton<XAttributeMgr>.singleton.XPlayerData.Level);
					if (flag2)
					{
						bool flag3 = !PandoraDocument.ItemList.Contains(PandoraDocument._table.Table[i].itemid);
						if (flag3)
						{
							PandoraDocument.ItemList.Add(PandoraDocument._table.Table[i].itemid);
						}
					}
				}
			}
		}

		public void SendPandoraLottery(bool isOneLottery)
		{
			bool flag = Time.time - this._last_lottery_time < 2f;
			if (!flag)
			{
				this._last_lottery_time = Time.time;
				RpcC2G_PandoraLottery rpcC2G_PandoraLottery = new RpcC2G_PandoraLottery();
				rpcC2G_PandoraLottery.oArg.pandoraid = this._pandora_id;
				rpcC2G_PandoraLottery.oArg.isOneLottery = isOneLottery;
				XSingleton<XClientNetwork>.singleton.Send(rpcC2G_PandoraLottery);
			}
		}

		public void GetPandoraLotteryResult(List<ItemBrief> items)
		{
			this._items_cache.Clear();
			for (int i = 0; i < items.Count; i++)
			{
				this._items_cache.Add(items[i]);
			}
			bool flag = DlgBase<PandoraView, PandoraBehaviour>.singleton.IsVisible();
			if (flag)
			{
				DlgBase<PandoraView, PandoraBehaviour>.singleton.PlayOpenFx();
			}
		}

		public void ShowPandoraLotteryView(uint itemID, PandoraHeart.RowData data)
		{
			bool flag = data == null;
			if (flag)
			{
				XSingleton<XDebug>.singleton.AddErrorLog("Pandora Data is Null!!!", null, null, null, null, null);
			}
			else
			{
				this._pandora_id = itemID;
				this._pandora_data = data;
				this.GetShowItemList();
				DlgBase<PandoraView, PandoraBehaviour>.singleton.SetVisible(true, true);
			}
		}

		public XFx CreateAndPlayFx(string path, Transform parent)
		{
			XFx xfx = XSingleton<XFxMgr>.singleton.CreateFx(path, null, true);
			bool flag = xfx == null;
			XFx result;
			if (flag)
			{
				result = null;
			}
			else
			{
				xfx.Play(parent, Vector3.zero, Vector3.one, 1f, true, false);
				result = xfx;
			}
			return result;
		}

		public void DestroyFx(XFx fx)
		{
			bool flag = fx == null;
			if (!flag)
			{
				XSingleton<XFxMgr>.singleton.DestroyFx(fx, true);
			}
		}

		protected override void OnReconnected(XReconnectedEventArgs arg)
		{
		}
	}
}