summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/AncientBox.cs
blob: 041bd1c2fb0c942cdbf273a7746c60f873b9f907 (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
using System;
using UILib;
using UnityEngine;
using XMainClient.UI;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

namespace XMainClient
{
	internal class AncientBox : DlgBase<AncientBox, AnicientBoxBahaviour>
	{
		public override string fileName
		{
			get
			{
				return "OperatingActivity/AncientBox";
			}
		}

		public override bool autoload
		{
			get
			{
				return true;
			}
		}

		public override bool hideMainMenu
		{
			get
			{
				return false;
			}
		}

		public override bool pushstack
		{
			get
			{
				return false;
			}
		}

		public override bool fullscreenui
		{
			get
			{
				return true;
			}
		}

		private AncientTimesTable.RowData row;

		protected override void OnShow()
		{
			base.OnShow();
			base.uiBehaviour.m_sprRed.SetVisible(false);
		}

		public override void RegisterEvent()
		{
			base.RegisterEvent();
			base.uiBehaviour.m_btnClaim.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnClick));
			base.uiBehaviour.m_black.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnClose));
		}

		public void Show(AncientTimesTable.RowData r)
		{
			this.row = r;
			this.SetVisible(true, true);
			this.RefreshPoint();
			this.RefreshRwd();
		}

		private void RefreshPoint()
		{
			base.uiBehaviour.m_title.SetText(this.row.Title);
			base.uiBehaviour.m_point.SetText(XStringDefineProxy.GetString("AncientPoint", new object[]
			{
				this.row.nPoints[1]
			}));
		}

		private void RefreshRwd()
		{
			base.uiBehaviour.m_rwdpool.ReturnAll(false);
			int tplWidth = base.uiBehaviour.m_rwdpool.TplWidth;
			int i = 0;
			int count = (int)this.row.Items.count;
			while (i < count)
			{
				GameObject gameObject = base.uiBehaviour.m_rwdpool.FetchGameObject(false);
				XSingleton<UiUtility>.singleton.AddChild(base.uiBehaviour.itemTpl.transform.parent.gameObject, gameObject);
				XSingleton<XItemDrawerMgr>.singleton.normalItemDrawer.DrawItem(gameObject, (int)this.row.Items[i, 0], (int)this.row.Items[i, 1], false);
				Vector3 localPosition = base.uiBehaviour.itemTpl.transform.localPosition;
				localPosition.x = (float)((count % 2 == 0) ? ((int)((float)i - (float)count / 2f) * tplWidth + tplWidth / 2) : ((int)((float)i - (float)(count - 1) / 2f) * tplWidth));
				gameObject.transform.localPosition = localPosition;
				IXUISprite ixuisprite = gameObject.transform.Find("Icon").GetComponent("XUISprite") as IXUISprite;
				ixuisprite.ID = (ulong)this.row.Items[i, 0];
				ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(XSingleton<UiUtility>.singleton.OnItemClick));
				i++;
			}
		}

		private bool OnClick(IXUIButton btn)
		{
			XAncientDocument specificDocument = XDocuments.GetSpecificDocument<XAncientDocument>(XAncientDocument.uuID);
			specificDocument.ReqPoint(this.row.ID);
			return true;
		}

		private void OnClose(IXUISprite spr)
		{
			this.SetVisible(false, true);
		}
	}
}