summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/UI/HolidayHandler.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-01-25 14:28:30 +0800
committerchai <chaifix@163.com>2021-01-25 14:28:30 +0800
commit6eb915c129fc90c6f4c82ae097dd6ffad5239efc (patch)
tree7dd2be50edf41f36b60fac84696e731c13afe617 /Client/Assets/Scripts/XMainClient/UI/HolidayHandler.cs
+scripts
Diffstat (limited to 'Client/Assets/Scripts/XMainClient/UI/HolidayHandler.cs')
-rw-r--r--Client/Assets/Scripts/XMainClient/UI/HolidayHandler.cs134
1 files changed, 134 insertions, 0 deletions
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<XGameUI>.singleton.m_uiTool);
+
+ private XLeftTimeCounter m_LeftTime;
+
+ protected override void Init()
+ {
+ base.Init();
+ this.doc = XDocuments.GetSpecificDocument<XOperatingActivityDocument>(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<XStringTable>.singleton.GetString("HOLIDAY_TIP3"));
+ }
+ else
+ {
+ this.m_LeftTime.SetLeftTime(this.doc.GetFestivalLeftTime(), -1);
+ this.m_LeftTime.SetFormatString(XSingleton<XStringTable>.singleton.GetString("HOLIDAY_TIP1"));
+ }
+ this.m_Tip2.SetText(string.Format(XSingleton<XStringTable>.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<XItemDrawerMgr>.singleton.normalItemDrawer.DrawItem(gameObject, (int)festivalRewardList[i], 0, false);
+ ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(XSingleton<UiUtility>.singleton.OnItemClick));
+ }
+ }
+ }
+
+ public override void OnUpdate()
+ {
+ base.OnUpdate();
+ this.m_LeftTime.Update();
+ }
+ }
+}