summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/UI/FlowerActivityHandler.cs
blob: ffbe4f6acca45390c46aa7e04178a67b0f8893f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using System;
using UILib;
using UnityEngine;
using XUtliPoolLib;

namespace XMainClient.UI
{
	internal class FlowerActivityHandler : DlgHandlerBase
	{
		protected override string FileName
		{
			get
			{
				return "OperatingActivity/FlowerActivityFrame";
			}
		}

		private IXUILabel m_Tip1;

		private IXUILabel m_Tip2;

		private IXUILabel m_AwardRankCount;

		private IXUIButton m_GoWeekRank;

		private Transform m_AwardRoot;

		private XUIPool m_ItemPool = new XUIPool(XSingleton<XGameUI>.singleton.m_uiTool);

		protected override void Init()
		{
			base.Init();
			this.m_Tip1 = (base.PanelObject.transform.Find("Main/Tip1").GetComponent("XUILabel") as IXUILabel);
			this.m_Tip2 = (base.PanelObject.transform.Find("Main/Tip2").GetComponent("XUILabel") as IXUILabel);
			this.m_AwardRankCount = (base.PanelObject.transform.Find("Main/Items/RankNum").GetComponent("XUILabel") as IXUILabel);
			this.m_GoWeekRank = (base.PanelObject.transform.Find("Main/Btns/ViewRewardBtn").GetComponent("XUIButton") as IXUIButton);
			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.m_Tip1.SetText(XSingleton<XStringTable>.singleton.GetString("FLOWER_ACTIVITY_TIP1"));
			this.m_Tip2.SetText(XSingleton<XStringTable>.singleton.GetString("FLOWER_ACTIVITY_TIP3"));
			this.m_AwardRankCount.SetText(XSingleton<XStringTable>.singleton.GetString("FLOWER_ACTIVITY_AWARD_RANK"));
			this.SetAwardsInfo();
		}

		public override void RegisterEvent()
		{
			base.RegisterEvent();
			this.m_GoWeekRank.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnGoWeekRankClicked));
		}

		private bool OnGoWeekRankClicked(IXUIButton btn)
		{
			XSingleton<XGameSysMgr>.singleton.OpenSystem(XSysDefine.XSys_Flower_Rank_Week, 0UL);
			return true;
		}

		private void SetAwardsInfo()
		{
			XFlowerRankDocument specificDocument = XDocuments.GetSpecificDocument<XFlowerRankDocument>(XFlowerRankDocument.uuID);
			SeqListRef<int> weekRankAward = specificDocument.GetWeekRankAward(1);
			this.m_ItemPool.ReturnAll(false);
			for (int i = 0; i < weekRankAward.Count; 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)((long)weekRankAward[i, 0]);
				XSingleton<XItemDrawerMgr>.singleton.normalItemDrawer.DrawItem(gameObject, weekRankAward[i, 0], weekRankAward[i, 1], false);
				ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(XSingleton<UiUtility>.singleton.OnItemClick));
			}
		}
	}
}