summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/UI/XShowGetItemUIView.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-01-25 14:28:30 +0800
committerchai <chaifix@163.com>2021-01-25 14:28:30 +0800
commit6eb915c129fc90c6f4c82ae097dd6ffad5239efc (patch)
tree7dd2be50edf41f36b60fac84696e731c13afe617 /Client/Assets/Scripts/XMainClient/UI/XShowGetItemUIView.cs
+scripts
Diffstat (limited to 'Client/Assets/Scripts/XMainClient/UI/XShowGetItemUIView.cs')
-rw-r--r--Client/Assets/Scripts/XMainClient/UI/XShowGetItemUIView.cs200
1 files changed, 200 insertions, 0 deletions
diff --git a/Client/Assets/Scripts/XMainClient/UI/XShowGetItemUIView.cs b/Client/Assets/Scripts/XMainClient/UI/XShowGetItemUIView.cs
new file mode 100644
index 00000000..79b96ed0
--- /dev/null
+++ b/Client/Assets/Scripts/XMainClient/UI/XShowGetItemUIView.cs
@@ -0,0 +1,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]);
+ }
+ }
+ }
+}