From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Assets/Scripts/XMainClient/UI/EmblemBagView.cs | 328 +++++++++++++++++++++ 1 file changed, 328 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/UI/EmblemBagView.cs (limited to 'Client/Assets/Scripts/XMainClient/UI/EmblemBagView.cs') diff --git a/Client/Assets/Scripts/XMainClient/UI/EmblemBagView.cs b/Client/Assets/Scripts/XMainClient/UI/EmblemBagView.cs new file mode 100644 index 00000000..45a6c528 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/UI/EmblemBagView.cs @@ -0,0 +1,328 @@ +using System; +using System.Collections.Generic; +using KKSG; +using UILib; +using UnityEngine; +using XMainClient.UI.UICommon; +using XUtliPoolLib; + +namespace XMainClient.UI +{ + internal class EmblemBagView : DlgHandlerBase + { + private XItemMorePowerfulTipMgr powerfullMgr + { + get + { + return DlgBase.singleton.RedPointMgr; + } + } + + private XItemMorePowerfulTipMgr newItemMgr + { + get + { + return DlgBase.singleton.NewItemMgr; + } + } + + private XBagWindow bagWindow + { + get + { + return DlgBase.singleton.BagWindow; + } + } + + public string IdentifyEffectPath + { + get + { + bool flag = string.IsNullOrEmpty(this.m_identifyEffectPath); + if (flag) + { + this.m_identifyEffectPath = XSingleton.singleton.GetValue("EmblemIdentifyEffectPath"); + } + return this.m_identifyEffectPath; + } + } + + protected override string FileName + { + get + { + return "ItemNew/EmblemListPanel"; + } + } + + public IXUIButton m_Help; + + private XEmblemDocument _doc; + + private IXUILabel m_bagNumLab; + + private Dictionary itemBtnDic = new Dictionary(); + + public IXUIButton m_expandBagBtn; + + private Transform EffectTra; + + private XFx m_identifyFx; + + private uint m_emblemIdentifyToken = 0u; + + private string m_identifyEffectPath = string.Empty; + + protected override void Init() + { + base.Init(); + this._doc = XDocuments.GetSpecificDocument(XEmblemDocument.uuID); + this._doc._BagHandler = this; + this.m_Help = (base.transform.Find("Help").GetComponent("XUIButton") as IXUIButton); + this.m_bagNumLab = (base.PanelObject.transform.Find("Panel/BagNum").GetComponent("XUILabel") as IXUILabel); + this.m_expandBagBtn = (base.PanelObject.transform.Find("add").GetComponent("XUIButton") as IXUIButton); + BagExpandItemListTable.RowData expandItemConfByType = XBagDocument.GetExpandItemConfByType((uint)XFastEnumIntEqualityComparer.ToInt(BagType.EmblemBag)); + this.m_expandBagBtn.gameObject.SetActive(expandItemConfByType != null); + this.EffectTra = base.PanelObject.transform.Find("Effect"); + } + + public override void RegisterEvent() + { + base.RegisterEvent(); + this.m_Help.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnHelpClicked)); + this.m_expandBagBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnBagExpandClicked)); + } + + public bool OnHelpClicked(IXUIButton button) + { + DlgBase.singleton.ShowHelp(XSysDefine.XSys_Char_Emblem); + return true; + } + + protected override void OnShow() + { + base.OnShow(); + this.Show(); + } + + private void Show() + { + this.bagWindow.ChangeData(new ItemUpdateHandler(this.WrapContentItemUpdated), new GetItemHandler(this._doc.GetEmblemItems)); + this.bagWindow.OnShow(); + this.SetBagNum(); + this._doc.NewItems.bCanClear = true; + } + + protected override void OnHide() + { + this.powerfullMgr.ReturnAll(); + this.newItemMgr.ReturnAll(); + this.bagWindow.OnHide(); + this._doc.NewItems.TryClear(); + this.itemBtnDic.Clear(); + XSingleton.singleton.KillTimer(this.m_emblemIdentifyToken); + this.HideEffect(this.m_identifyFx); + base.OnHide(); + } + + public override void StackRefresh() + { + base.StackRefresh(); + this.Show(); + } + + public override void OnUnload() + { + this._doc._BagHandler = null; + bool flag = this.m_identifyFx != null; + if (flag) + { + XSingleton.singleton.DestroyFx(this.m_identifyFx, true); + this.m_identifyFx = null; + } + base.OnUnload(); + } + + public void Refresh() + { + this.bagWindow.RefreshWindow(); + this.SetBagNum(); + } + + public void RefreshTips(ulong uid) + { + IXUISprite ixuisprite; + bool flag = this.itemBtnDic.TryGetValue(uid, out ixuisprite); + if (flag) + { + bool flag2 = ixuisprite != null; + if (flag2) + { + this.OnItemClicked(ixuisprite); + } + } + } + + private void SetBagNum() + { + int count = this._doc.GetEmblemItems().Count; + XRechargeDocument specificDocument = XDocuments.GetSpecificDocument(XRechargeDocument.uuID); + VIPTable.RowData byVIP = specificDocument.VIPReader.GetByVIP((int)specificDocument.VipLevel); + bool flag = byVIP != null; + if (flag) + { + uint num = byVIP.EmblemMax; + BagExpandData bagExpandData = XBagDocument.BagDoc.GetBagExpandData(BagType.EmblemBag); + bool flag2 = bagExpandData != null; + if (flag2) + { + num += bagExpandData.ExpandNum; + } + bool flag3 = (long)count >= (long)((ulong)num); + if (flag3) + { + this.m_bagNumLab.SetText(string.Format("[ff4366]{0}[-]/{1}", count, num)); + } + else + { + this.m_bagNumLab.SetText(string.Format("{0}[-]/{1}", count, num)); + } + } + } + + private void WrapContentItemUpdated(Transform t, int index) + { + Transform transform = t.Find("Icon/SupplementBrought"); + bool flag = transform != null; + if (flag) + { + transform.gameObject.SetActive(false); + } + IXUISprite ixuisprite = t.Find("Icon").GetComponent("XUISprite") as IXUISprite; + bool flag2 = this.bagWindow.m_XItemList == null || index >= this.bagWindow.m_XItemList.Count || index < 0; + if (flag2) + { + XSingleton.singleton.DrawItem(t.gameObject, null); + this.powerfullMgr.ReturnInstance(ixuisprite); + this.newItemMgr.ReturnInstance(ixuisprite); + t.gameObject.name = XSingleton.singleton.StringCombine("empty", index.ToString()); + } + else + { + t.gameObject.name = XSingleton.singleton.StringCombine("emblem", this.bagWindow.m_XItemList[index].itemID.ToString()); + XSingleton.singleton.DrawItem(t.gameObject, this.bagWindow.m_XItemList[index]); + ixuisprite.ID = this.bagWindow.m_XItemList[index].uid; + ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnItemClicked)); + bool flag3 = this.itemBtnDic.ContainsKey(ixuisprite.ID); + if (flag3) + { + this.itemBtnDic[ixuisprite.ID] = ixuisprite; + } + else + { + this.itemBtnDic.Add(ixuisprite.ID, ixuisprite); + } + XEmblemItem xemblemItem = this.bagWindow.m_XItemList[index] as XEmblemItem; + bool flag4 = this._doc.IsEmblemMorePowerful(ixuisprite.ID); + if (flag4) + { + this.powerfullMgr.SetTip(ixuisprite); + } + else + { + this.powerfullMgr.ReturnInstance(ixuisprite); + } + bool flag5 = this._doc.NewItems.IsNew(ixuisprite.ID); + if (flag5) + { + this.newItemMgr.SetTip(ixuisprite); + } + else + { + this.newItemMgr.ReturnInstance(ixuisprite); + } + } + } + + public void ShowEmblemIdentifyEffect() + { + bool flag = this.m_identifyFx == null; + if (flag) + { + this.m_identifyFx = XSingleton.singleton.CreateFx(this.IdentifyEffectPath, null, true); + } + else + { + this.m_identifyFx.SetActive(true); + } + this.m_identifyFx.Play(this.EffectTra, Vector3.zero, Vector3.one, 1f, true, false); + XSingleton.singleton.KillTimer(this.m_emblemIdentifyToken); + this.m_emblemIdentifyToken = XSingleton.singleton.SetTimerAccurate(5f, new XTimerMgr.AccurateElapsedEventHandler(this.OnEmblemIdentifyTimer), null); + } + + private void OnEmblemIdentifyTimer(object param, float delay) + { + this.HideEffect(this.m_identifyFx); + XSingleton.singleton.KillTimer(this.m_emblemIdentifyToken); + this.m_emblemIdentifyToken = 0u; + } + + private void HideEffect(XFx fx) + { + bool flag = fx != null; + if (flag) + { + fx.Stop(); + fx.SetActive(false); + } + } + + public void OnItemClicked(IXUISprite iSp) + { + XItem itemByUID = XSingleton.singleton.Doc.XBagDoc.GetItemByUID(iSp.ID); + bool flag = itemByUID == null; + if (!flag) + { + bool flag2 = this._doc.NewItems.RemoveItem(iSp.ID, itemByUID.Type, false); + if (flag2) + { + this.Refresh(); + } + CharacterEquipHandler.OnItemClicked(iSp); + } + } + + public void OnAddItem() + { + this.bagWindow.UpdateBag(); + this.SetBagNum(); + } + + public void OnRemoveItem() + { + this.bagWindow.UpdateBag(); + this.SetBagNum(); + } + + public void OnItemCountChanged(XItem item) + { + this.bagWindow.UpdateItem(item); + } + + public void OnSwapItem(XItem item1, XItem item2, int slot) + { + this.bagWindow.ReplaceItem(item1, item2); + } + + public void OnUpdateItem(XItem item) + { + this.bagWindow.UpdateItem(item); + } + + public bool OnBagExpandClicked(IXUIButton button) + { + XBagDocument.BagDoc.UseBagExpandTicket(BagType.EmblemBag); + return true; + } + } +} -- cgit v1.1-26-g67d0