From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../XMainClient/UI/NestStarRewardHandler.cs | 120 +++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/UI/NestStarRewardHandler.cs (limited to 'Client/Assets/Scripts/XMainClient/UI/NestStarRewardHandler.cs') diff --git a/Client/Assets/Scripts/XMainClient/UI/NestStarRewardHandler.cs b/Client/Assets/Scripts/XMainClient/UI/NestStarRewardHandler.cs new file mode 100644 index 00000000..808c8f82 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/UI/NestStarRewardHandler.cs @@ -0,0 +1,120 @@ +using System; +using System.Collections.Generic; +using UILib; +using UnityEngine; +using XUtliPoolLib; + +namespace XMainClient.UI +{ + internal class NestStarRewardHandler : DlgHandlerBase + { + protected override string FileName + { + get + { + return "OperatingActivity/NestStarReward"; + } + } + + private IXUIButton m_Close; + + private GameObject m_itemParentGo; + + private XUIPool m_ItemPool1 = new XUIPool(XSingleton.singleton.m_uiTool); + + private XUIPool m_ItemPool2 = new XUIPool(XSingleton.singleton.m_uiTool); + + private XNestDocument m_doc; + + protected override void Init() + { + base.Init(); + this.m_Close = (base.transform.Find("Close").GetComponent("XUIButton") as IXUIButton); + this.m_itemParentGo = base.transform.Find("Panel/List").gameObject; + Transform transform = this.m_itemParentGo.transform.Find("Tpl"); + this.m_ItemPool1.SetupPool(this.m_itemParentGo, transform.gameObject, 5u, false); + this.m_ItemPool2.SetupPool(transform.gameObject, this.m_itemParentGo.transform.Find("Item").gameObject, 4u, false); + this.m_doc = XDocuments.GetSpecificDocument(XNestDocument.uuID); + } + + public override void RegisterEvent() + { + base.RegisterEvent(); + this.m_Close.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnCloseClicked)); + } + + protected override void OnShow() + { + base.OnShow(); + this.FillContent(); + } + + protected override void OnHide() + { + this.m_ItemPool1.ReturnAll(false); + this.m_ItemPool2.ReturnAll(false); + base.OnHide(); + } + + public override void StackRefresh() + { + base.StackRefresh(); + } + + public override void OnUnload() + { + this.m_ItemPool1.ReturnAll(false); + this.m_ItemPool2.ReturnAll(false); + base.OnUnload(); + } + + private void FillContent() + { + this.m_ItemPool1.ReturnAll(false); + this.m_ItemPool2.ReturnAll(false); + List nestStarRewards = this.m_doc.GetNestStarRewards(this.m_doc.NestType); + for (int i = 0; i < nestStarRewards.Count; i++) + { + NestStarReward.RowData rowData = nestStarRewards[i]; + bool flag = rowData == null; + if (!flag) + { + GameObject gameObject = this.m_ItemPool1.FetchGameObject(false); + gameObject.transform.parent = this.m_itemParentGo.transform; + gameObject.name = i.ToString(); + gameObject.transform.localScale = Vector3.one; + gameObject.transform.localPosition = new Vector3(0f, (float)(-(float)this.m_ItemPool1.TplHeight * i), 0f); + IXUILabel ixuilabel = gameObject.transform.Find("T").GetComponent("XUILabel") as IXUILabel; + ixuilabel.SetText(rowData.Tittle); + ixuilabel = (gameObject.transform.Find("ch").GetComponent("XUILabel") as IXUILabel); + ixuilabel.SetText(XStringDefineProxy.GetString("FirstPassPlayerTittle")); + ixuilabel.gameObject.SetActive(rowData.IsHadTittle == 1u); + ixuilabel = (gameObject.transform.Find("Image/Rank").GetComponent("XUILabel") as IXUILabel); + ixuilabel.SetText(rowData.Stars.ToString()); + this.FillItem(rowData, gameObject); + } + } + } + + private void FillItem(NestStarReward.RowData data, GameObject parentGo) + { + for (int i = 0; i < data.Reward.Count; i++) + { + GameObject gameObject = this.m_ItemPool2.FetchGameObject(false); + gameObject.transform.parent = parentGo.transform; + gameObject.transform.localScale = Vector3.one; + gameObject.transform.localPosition = new Vector3((float)(-170 + this.m_ItemPool2.TplWidth * i), -16f, 0f); + IXUISprite ixuisprite = gameObject.transform.Find("Icon").GetComponent("XUISprite") as IXUISprite; + ixuisprite.ID = (ulong)data.Reward[i, 0]; + XSingleton.singleton.normalItemDrawer.DrawItem(gameObject, (int)data.Reward[i, 0], (int)data.Reward[i, 1], false); + ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(XSingleton.singleton.OnItemClick)); + } + } + + public bool OnCloseClicked(IXUIButton sp) + { + base.SetVisible(false); + return true; + } + } +} -- cgit v1.1-26-g67d0