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]); } } } }