From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Scripts/XMainClient/UI/XShowGetItemUIView.cs | 200 +++++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/UI/XShowGetItemUIView.cs (limited to 'Client/Assets/Scripts/XMainClient/UI/XShowGetItemUIView.cs') 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 + { + 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 m_items = new List(); + + private uint m_token = 0u; + + private OnTweenFinishEventHandler mAnimEnd; + + public bool isPlaying = false; + + protected override void OnHide() + { + XSingleton.singleton.KillTimer(this.m_token); + base.OnHide(); + } + + protected override void OnUnload() + { + XSingleton.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.uuID); + } + } + + protected override void OnShow() + { + } + + private void Print(List _items, string tag) + { + for (int i = 0; i < _items.Count; i++) + { + XSingleton.singleton.AddGreenLog(XSingleton.singleton.StringCombine(tag, string.Concat(new object[] + { + " itemid:", + _items[i].itemID, + " cnt:", + _items[i].itemCount + })), null, null, null, null, null); + } + } + + public void ShowItems(List _items, OnTweenFinishEventHandler _end) + { + bool flag = this._doc == null; + if (flag) + { + this._doc = XDocuments.GetSpecificDocument(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.singleton.KillTimer(this.m_token); + XSingleton.singleton.AddGreenLog(base.uiBehaviour.m_tweener.Duration.ToString(), null, null, null, null, null); + this.m_token = XSingleton.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.singleton.AddLog("play end!", null, null, null, null, null, XDebugColor.XDebug_None); + this.mAnimEnd(tween); + } + } + XSingleton.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.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.singleton.DrawItem(gameObject, this.m_items[i]); + } + } + } +} -- cgit v1.1-26-g67d0