From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Scripts/XMainClient/XFoodSelectorHandler.cs | 128 +++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XFoodSelectorHandler.cs (limited to 'Client/Assets/Scripts/XMainClient/XFoodSelectorHandler.cs') diff --git a/Client/Assets/Scripts/XMainClient/XFoodSelectorHandler.cs b/Client/Assets/Scripts/XMainClient/XFoodSelectorHandler.cs new file mode 100644 index 00000000..337def8c --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XFoodSelectorHandler.cs @@ -0,0 +1,128 @@ +using System; +using System.Collections.Generic; +using UILib; +using UnityEngine; +using XMainClient.UI; +using XMainClient.UI.UICommon; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XFoodSelectorHandler : DlgHandlerBase + { + private XPetDocument _PetDoc; + + private XBagWindow m_BagWindow; + + private IXUIButton m_BtnOpenBag; + + private Transform m_NoFeed; + + protected override void Init() + { + base.Init(); + this._PetDoc = XDocuments.GetSpecificDocument(XPetDocument.uuID); + GameObject gameObject = base.PanelObject.transform.Find("ItemPanel").gameObject; + this.m_BagWindow = new XBagWindow(gameObject, new ItemUpdateHandler(this._WrapContentItemUpdated), new GetItemHandler(this._PetDoc.GetFood)); + this.m_BagWindow.Init(); + this.m_BtnOpenBag = (base.PanelObject.transform.Find("BtnFeed").GetComponent("XUIButton") as IXUIButton); + this.m_NoFeed = gameObject.transform.Find("NoFeed"); + } + + public override void RegisterEvent() + { + base.RegisterEvent(); + this.m_BtnOpenBag.RegisterClickEventHandler(new ButtonClickEventHandler(this._OnOpenClicked)); + } + + public override void OnUnload() + { + this._PetDoc = null; + base.OnUnload(); + } + + private void _WrapContentItemUpdated(Transform t, int index) + { + t = t.Find("Item"); + IXUISprite ixuisprite = t.Find("Icon").GetComponent("XUISprite") as IXUISprite; + IXUILabel ixuilabel = t.Find("FullDegree").GetComponent("XUILabel") as IXUILabel; + IXUILabel ixuilabel2 = t.Find("Exp").GetComponent("XUILabel") as IXUILabel; + bool flag = this.m_BagWindow.m_XItemList == null || index >= this.m_BagWindow.m_XItemList.Count || index < 0; + if (flag) + { + XSingleton.singleton.DrawItem(t.gameObject, null); + ixuilabel.SetText(""); + ixuilabel2.SetText(""); + } + else + { + XItem xitem = this.m_BagWindow.m_XItemList[index]; + XSingleton.singleton.DrawItem(t.gameObject, xitem); + ItemList.RowData itemConf = XBagDocument.GetItemConf(xitem.itemID); + IXUILabel ixuilabel3 = t.Find("Name").GetComponent("XUILabel") as IXUILabel; + ixuilabel3.SetColor(XSingleton.singleton.GetItemQualityColor((int)itemConf.ItemQuality)); + PetFoodTable.RowData petFood = XPetDocument.GetPetFood((uint)xitem.itemID); + ixuilabel.SetText(XSingleton.singleton.NumberFormat((ulong)petFood.hungry)); + ixuilabel2.SetText(XSingleton.singleton.NumberFormat((ulong)petFood.exp)); + ixuisprite.ID = (ulong)((long)xitem.itemID); + ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this._OnFeedClicked)); + } + this.m_NoFeed.gameObject.SetActive(this.m_BagWindow.m_XItemList.Count == 0); + } + + private List _GetFood() + { + return null; + } + + public void ShowBag(bool bShow) + { + if (bShow) + { + bool flag = this._PetDoc.CanHasRedPoint && this._PetDoc.CurSelectedPet.UID == this._PetDoc.CurFightUID; + if (flag) + { + this._PetDoc.CanHasRedPoint = false; + XSingleton.singleton.RecalculateRedPointState(XSysDefine.XSys_Horse, true); + DlgBase.singleton.RefreshPage(false); + } + this.m_BagWindow.PanelObject.SetActive(true); + this.m_BagWindow.OnShow(); + } + else + { + this.m_BagWindow.PanelObject.SetActive(false); + } + } + + public void UpdateContent() + { + this.m_BagWindow.UpdateBag(); + } + + private void _OnCloseClicked(IXUISprite iSp) + { + this.ShowBag(false); + } + + private bool _OnOpenClicked(IXUIButton btn) + { + bool activeSelf = this.m_BagWindow.PanelObject.activeSelf; + if (activeSelf) + { + this.ShowBag(false); + } + else + { + this.ShowBag(true); + } + return true; + } + + private void _OnFeedClicked(IXUISprite iSp) + { + XPetDocument specificDocument = XDocuments.GetSpecificDocument(XPetDocument.uuID); + specificDocument.ReqFeed((int)iSp.ID); + } + } +} -- cgit v1.1-26-g67d0