summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/UI/WelfareGrowthFundItem.cs
blob: e4e0bd80247a9f235f5e0fe5fb49b523a2f73ce9 (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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
using System;
using UILib;
using UnityEngine;
using XUtliPoolLib;

namespace XMainClient.UI
{
	public class WelfareGrowthFundItem
	{
		private Transform m_transform;

		private IXUIButton m_getBtn;

		private IXUILabel m_contentLabel;

		private IXUILabel m_valueLabel;

		private IXUILabel m_messageLabel;

		private IXUISprite m_hasBuySprite;

		private int m_type;

		private int m_key;

		private int m_value;

		public void Init(Transform tf)
		{
			this.m_transform = tf;
			this.m_getBtn = (tf.Find("Recharge").GetComponent("XUIButton") as IXUIButton);
			this.m_contentLabel = (tf.Find("Content").GetComponent("XUILabel") as IXUILabel);
			this.m_valueLabel = (tf.Find("Value").GetComponent("XUILabel") as IXUILabel);
			this.m_messageLabel = (tf.Find("Message").GetComponent("XUILabel") as IXUILabel);
			this.m_hasBuySprite = (tf.Find("HasBuy").GetComponent("XUISprite") as IXUISprite);
			this.m_getBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnClickGetHandler));
		}

		private bool OnClickGetHandler(IXUIButton btn)
		{
			bool flag = this.m_type == 0;
			bool result;
			if (flag)
			{
				result = true;
			}
			else
			{
				XWelfareDocument specificDocument = XDocuments.GetSpecificDocument<XWelfareDocument>(XWelfareDocument.uuID);
				specificDocument.GetGrowthFundAward(this.m_type, this.m_key);
				result = true;
			}
			return result;
		}

		public void Set(int type, int key, int value)
		{
			this.m_type = type;
			this.m_key = key;
			this.m_value = value;
			this.m_valueLabel.SetText(this.m_value.ToString());
			bool flag = this.m_type == 0;
			if (flag)
			{
				this.m_contentLabel.SetText(XStringDefineProxy.GetString("WELFARE_GROWTHFUND_CONTENT"));
			}
			else
			{
				this.m_contentLabel.SetText(XStringDefineProxy.GetString(XSingleton<XCommon>.singleton.StringCombine("WELFARE_GROWTHFUND_CONTENT", this.m_type.ToString()), new object[]
				{
					this.m_key
				}));
			}
		}

		public void Refresh()
		{
			XWelfareDocument specificDocument = XDocuments.GetSpecificDocument<XWelfareDocument>(XWelfareDocument.uuID);
			bool flag = !specificDocument.HasBuyGrowthFund;
			if (flag)
			{
				this.m_messageLabel.SetText(XStringDefineProxy.GetString("WELFARE_GROWTHFUND_ERROR"));
				this.m_getBtn.SetVisible(false);
				this.m_hasBuySprite.SetVisible(false);
			}
			else
			{
				bool flag2 = this.m_type == 0;
				if (flag2)
				{
					this.m_hasBuySprite.SetVisible(true);
					this.m_getBtn.SetVisible(false);
					this.m_messageLabel.SetText(string.Empty);
				}
				else
				{
					bool flag3 = specificDocument.HasGrowthFundGet(this.m_type, this.m_key);
					if (flag3)
					{
						this.m_hasBuySprite.SetVisible(true);
						this.m_messageLabel.SetText(string.Empty);
						this.m_getBtn.SetVisible(false);
					}
					else
					{
						this.m_hasBuySprite.SetVisible(false);
						bool flag4 = this.m_type == 1;
						if (flag4)
						{
							int level = (int)XSingleton<XAttributeMgr>.singleton.XPlayerData.Level;
							bool flag5 = level < this.m_key;
							if (flag5)
							{
								this.m_messageLabel.SetText(XStringDefineProxy.GetString("WELFARE_GROWTHFUND_MESSAGE1", new object[]
								{
									this.m_key - level
								}));
								this.m_getBtn.SetVisible(false);
							}
							else
							{
								this.m_messageLabel.SetText(string.Empty);
								this.m_getBtn.SetVisible(true);
							}
						}
						else
						{
							bool flag6 = this.m_type == 2;
							if (flag6)
							{
								int loginDayCount = specificDocument.LoginDayCount;
								bool flag7 = loginDayCount < this.m_key;
								if (flag7)
								{
									this.m_messageLabel.SetText(XStringDefineProxy.GetString("WELFARE_GROWTHFUND_MESSAGE2", new object[]
									{
										this.m_key - loginDayCount
									}));
									this.m_getBtn.SetVisible(false);
								}
								else
								{
									this.m_messageLabel.SetText(string.Empty);
									this.m_getBtn.SetVisible(true);
								}
							}
							else
							{
								this.m_messageLabel.SetText(string.Empty);
								this.m_getBtn.SetVisible(false);
							}
						}
					}
				}
			}
		}
	}
}