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/HolidayHandler.cs | 134 +++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/UI/HolidayHandler.cs (limited to 'Client/Assets/Scripts/XMainClient/UI/HolidayHandler.cs') diff --git a/Client/Assets/Scripts/XMainClient/UI/HolidayHandler.cs b/Client/Assets/Scripts/XMainClient/UI/HolidayHandler.cs new file mode 100644 index 00000000..4fc8f2ce --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/UI/HolidayHandler.cs @@ -0,0 +1,134 @@ +using System; +using UILib; +using UnityEngine; +using XUtliPoolLib; + +namespace XMainClient.UI +{ + internal class HolidayHandler : DlgHandlerBase + { + protected override string FileName + { + get + { + return "OperatingActivity/HolidayFrame"; + } + } + + private XOperatingActivityDocument doc; + + private IXUILabel m_Tip1; + + private IXUILabel m_Tip2; + + private IXUIButton m_Enter; + + private IXUITexture m_Bg; + + private Transform m_AwardRoot; + + private XUIPool m_ItemPool = new XUIPool(XSingleton.singleton.m_uiTool); + + private XLeftTimeCounter m_LeftTime; + + protected override void Init() + { + base.Init(); + this.doc = XDocuments.GetSpecificDocument(XOperatingActivityDocument.uuID); + this.m_Tip1 = (base.PanelObject.transform.Find("Main/Tip1").GetComponent("XUILabel") as IXUILabel); + this.m_LeftTime = new XLeftTimeCounter(this.m_Tip1, true); + this.m_LeftTime.SetTimeFormat(0, 3, 4, false); + this.m_Tip2 = (base.PanelObject.transform.Find("Main/Tip2").GetComponent("XUILabel") as IXUILabel); + this.m_Enter = (base.PanelObject.transform.Find("Main/Btns/EnterBtn").GetComponent("XUIButton") as IXUIButton); + this.m_Bg = (base.PanelObject.transform.Find("Main/Bg").GetComponent("XUITexture") as IXUITexture); + this.m_AwardRoot = base.PanelObject.transform.Find("Main/Items"); + GameObject gameObject = base.PanelObject.transform.Find("Main/Items/Item").gameObject; + this.m_ItemPool.SetupPool(this.m_AwardRoot.gameObject, gameObject, 7u, false); + } + + protected override void OnShow() + { + base.OnShow(); + this.doc.SendQueryHolidayData(); + this.Refresh(); + } + + protected override void OnHide() + { + base.OnHide(); + this.m_Bg.SetTexturePath(""); + } + + public override void RegisterEvent() + { + base.RegisterEvent(); + this.m_Enter.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnEnterClicked)); + } + + public void Refresh() + { + bool flag = !base.IsVisible(); + if (!flag) + { + bool flag2 = this.doc.GetFestivalLeftTime() == 0u; + if (flag2) + { + this.m_LeftTime.SetLeftTime(1E+07f, -1); + this.m_LeftTime.SetFormatString(XSingleton.singleton.GetString("HOLIDAY_TIP3")); + } + else + { + this.m_LeftTime.SetLeftTime(this.doc.GetFestivalLeftTime(), -1); + this.m_LeftTime.SetFormatString(XSingleton.singleton.GetString("HOLIDAY_TIP1")); + } + this.m_Tip2.SetText(string.Format(XSingleton.singleton.GetString("HOLIDAY_TIP2"), this.doc.GetFestivalLeftCount())); + this.SetAwardsInfo(); + this.SetBG(); + } + } + + private bool OnEnterClicked(IXUIButton btn) + { + this.doc.EnterHolidayLevel(); + return true; + } + + private void SetBG() + { + string festivalPicPath = this.doc.GetFestivalPicPath(); + bool flag = string.IsNullOrEmpty(festivalPicPath); + if (!flag) + { + this.m_Bg.SetTexturePath(festivalPicPath); + } + } + + private void SetAwardsInfo() + { + this.m_ItemPool.ReturnAll(false); + uint[] festivalRewardList = this.doc.GetFestivalRewardList(); + bool flag = festivalRewardList == null; + if (!flag) + { + for (int i = 0; i < festivalRewardList.Length; i++) + { + GameObject gameObject = this.m_ItemPool.FetchGameObject(false); + gameObject.transform.parent = this.m_AwardRoot; + gameObject.name = i.ToString(); + gameObject.transform.localScale = Vector3.one; + gameObject.transform.localPosition = new Vector3((float)(this.m_ItemPool.TplWidth * i), 0f, 0f); + IXUISprite ixuisprite = gameObject.transform.Find("Icon").GetComponent("XUISprite") as IXUISprite; + ixuisprite.ID = (ulong)festivalRewardList[i]; + XSingleton.singleton.normalItemDrawer.DrawItem(gameObject, (int)festivalRewardList[i], 0, false); + ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(XSingleton.singleton.OnItemClick)); + } + } + } + + public override void OnUpdate() + { + base.OnUpdate(); + this.m_LeftTime.Update(); + } + } +} -- cgit v1.1-26-g67d0