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

namespace XMainClient.UI
{
	internal class XShowGetItemUIView : DlgBase<XShowGetItemUIView, XShowGetItemUIBehaviour>
	{
		public override string fileName
		{
			get
			{
				return "GameSystem/ShowGetItemDlg";
			}
		}

		public override bool autoload
		{
			get
			{
				return true;
			}
		}

		public override bool needOnTop
		{
			get
			{
				return true;
			}
		}

		public override bool isHideChat
		{
			get
			{
				return false;
			}
		}

		private XShowGetItemDocument _doc = null;

		private List<XItem> m_items = new List<XItem>();

		private uint m_token = 0u;

		private OnTweenFinishEventHandler mAnimEnd;

		public bool isPlaying = false;

		protected override void OnHide()
		{
			XSingleton<XTimerMgr>.singleton.KillTimer(this.m_token);
			base.OnHide();
		}

		protected override void OnUnload()
		{
			XSingleton<XTimerMgr>.singleton.KillTimer(this.m_token);
			base.OnUnload();
		}

		protected override void Init()
		{
			base.Init();
			bool flag = this._doc == null;
			if (flag)
			{
				this._doc = XDocuments.GetSpecificDocument<XShowGetItemDocument>(XShowGetItemDocument.uuID);
			}
		}

		protected override void OnShow()
		{
		}

		private void Print(List<XItem> _items, string tag)
		{
			for (int i = 0; i < _items.Count; i++)
			{
				XSingleton<XDebug>.singleton.AddGreenLog(XSingleton<XCommon>.singleton.StringCombine(tag, string.Concat(new object[]
				{
					" itemid:",
					_items[i].itemID,
					" cnt:",
					_items[i].itemCount
				})), null, null, null, null, null);
			}
		}

		public void ShowItems(List<XItem> _items, OnTweenFinishEventHandler _end)
		{
			bool flag = this._doc == null;
			if (flag)
			{
				this._doc = XDocuments.GetSpecificDocument<XShowGetItemDocument>(XShowGetItemDocument.uuID);
			}
			bool flag2 = XEquipCreateDocument.Doc.IsForbidGetItemUI || this._doc.IsForbidByLua;
			if (flag2)
			{
				this.SetVisible(false, true);
				XShowGetItemDocument.ItemUIQueue.Clear();
			}
			else
			{
				bool flag3 = !base.IsVisible();
				if (flag3)
				{
					this.SetVisibleWithAnimation(true, null);
				}
				this.isPlaying = true;
				this.mAnimEnd = _end;
				this.m_items = _items;
				base.uiBehaviour.m_ShowItemPool.ReturnAll(false);
				this.GridItems();
				base.uiBehaviour.m_tweenBg.ResetTween(true);
				base.uiBehaviour.m_tweenBg.PlayTween(true, -1f);
				XSingleton<XTimerMgr>.singleton.KillTimer(this.m_token);
				XSingleton<XDebug>.singleton.AddGreenLog(base.uiBehaviour.m_tweener.Duration.ToString(), null, null, null, null, null);
				this.m_token = XSingleton<XTimerMgr>.singleton.SetTimer(base.uiBehaviour.m_tweener.Duration, new XTimerMgr.ElapsedEventHandler(this.OnPlayEnd), base.uiBehaviour.m_tweenBg);
			}
		}

		public void OnPlayEnd(object o = null)
		{
			bool flag = o != null;
			if (flag)
			{
				IXUITweenTool tween = o as IXUITweenTool;
				this.isPlaying = false;
				bool flag2 = this.mAnimEnd != null;
				if (flag2)
				{
					XSingleton<XDebug>.singleton.AddLog("play end!", null, null, null, null, null, XDebugColor.XDebug_None);
					this.mAnimEnd(tween);
				}
			}
			XSingleton<XDebug>.singleton.AddGreenLog("the end event", null, null, null, null, null);
		}

		public void OnPlayEnd(IXUITweenTool tween)
		{
			this.isPlaying = false;
			bool flag = this.mAnimEnd != null;
			if (flag)
			{
				XSingleton<XDebug>.singleton.AddLog("play end!", null, null, null, null, null, XDebugColor.XDebug_None);
				this.mAnimEnd(tween);
			}
		}

		public void HandlePlayEnd()
		{
			bool flag = base.uiBehaviour != null && base.uiBehaviour.m_ShowItemPool != null;
			if (flag)
			{
				base.uiBehaviour.m_ShowItemPool.ReturnAll(false);
			}
		}

		private void GridItems()
		{
			int count = this.m_items.Count;
			Vector3 localPosition;
			localPosition= new Vector3(200f, -12f, 0f);
			base.uiBehaviour.m_sprBgTip.spriteHeight = ((count > 5) ? 300 : 250);
			for (int i = 0; i < count; i++)
			{
				bool flag = count > 5;
				if (flag)
				{
					int num = (count % 2 == 0) ? (count / 2) : (count / 2 + 1);
					bool flag2 = i < num;
					if (flag2)
					{
						localPosition.x = 100f * ((float)i - (float)(num - 1) / 2f);
						localPosition.y = -120f;
					}
					else
					{
						localPosition.x = 100f * ((float)(i - num) - (float)(count - num - 1) / 2f);
						localPosition.y = -220f;
					}
				}
				else
				{
					localPosition.x = 100f * ((float)i - (float)(count - 1) / 2f);
					localPosition.y = -145f;
				}
				GameObject gameObject = base.uiBehaviour.m_ShowItemPool.FetchGameObject(false);
				gameObject.name = "item" + i;
				gameObject.transform.localPosition = localPosition;
				XSingleton<XItemDrawerMgr>.singleton.DrawItem(gameObject, this.m_items[i]);
			}
		}
	}
}