summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/UI/EnhanceMasterHandler.cs
blob: fd403e2195b27bf8626ce6ecedafaed9395ead52 (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
{
	internal class EnhanceMasterHandler : DlgHandlerBase
	{
		private XEnhanceDocument m_doc
		{
			get
			{
				return XEnhanceDocument.Doc;
			}
		}

		protected override string FileName
		{
			get
			{
				return "ItemNew/EnhanceMaster";
			}
		}

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

		private IXUILabel m_HistoryMaxLevel;

		private IXUILabel m_NextStageLevel;

		private IXUILabel m_effectTipsLab;

		private IXUISprite m_closedSpr;

		private GameObject m_CurAttrListGo;

		private GameObject m_NextStageAttrListGo;

		private GameObject m_NoTipsGo;

		private GameObject m_MaxTipsGo;

		private readonly int m_gap = 30;

		protected override void Init()
		{
			base.Init();
			Transform transform = base.PanelObject.transform.Find("AttriTpl");
			this.m_AttrPool.SetupPool(base.PanelObject, transform.gameObject, 2u, false);
			this.m_CurAttrListGo = base.PanelObject.transform.Find("CurAttrList").gameObject;
			this.m_NextStageAttrListGo = base.PanelObject.transform.Find("NextStageAttrList").gameObject;
			this.m_NoTipsGo = base.PanelObject.transform.Find("NoTips").gameObject;
			this.m_MaxTipsGo = base.PanelObject.transform.Find("MaxTips").gameObject;
			this.m_HistoryMaxLevel = (base.PanelObject.transform.Find("HistoryLevel/Num").GetComponent("XUILabel") as IXUILabel);
			this.m_NextStageLevel = (base.PanelObject.transform.Find("NextStage/Num").GetComponent("XUILabel") as IXUILabel);
			this.m_effectTipsLab = (base.PanelObject.transform.Find("EffectTips").GetComponent("XUILabel") as IXUILabel);
			this.m_closedSpr = (base.PanelObject.transform.Find("Bg/Box").GetComponent("XUISprite") as IXUISprite);
			this.m_doc.enhanceMasterView = this;
		}

		public override void RegisterEvent()
		{
			base.RegisterEvent();
			this.m_closedSpr.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnClickClose));
		}

		protected override void OnShow()
		{
			base.OnShow();
			this.FillContent();
		}

		protected override void OnHide()
		{
			base.OnHide();
			this.m_AttrPool.ReturnAll(false);
		}

		public override void OnUnload()
		{
			base.OnUnload();
		}

		public void RefreshView()
		{
			this.FillContent();
		}

		private void FillContent()
		{
			this.m_HistoryMaxLevel.SetText(string.Format("{0}{1}", this.m_doc.HistoryMaxLevel, XStringDefineProxy.GetString("LevelName")));
			this.m_NextStageLevel.SetText("");
			this.m_effectTipsLab.SetText(XEquipDocument.GetTips(XSingleton<XAttributeMgr>.singleton.XPlayerData.BasicTypeID, this.m_doc.HistoryMaxLevel));
			this.m_AttrPool.ReturnAll(false);
			bool flag = this.m_doc.HistoryMaxLevel == 0u;
			if (flag)
			{
				this.m_NoTipsGo.SetActive(true);
			}
			else
			{
				this.m_NoTipsGo.SetActive(false);
				EnhanceMaster.RowData curStageEnhanceMasterRowData = this.m_doc.GetCurStageEnhanceMasterRowData(this.m_doc.HistoryMaxLevel);
				bool flag2 = curStageEnhanceMasterRowData != null;
				if (flag2)
				{
					for (int i = 0; i < curStageEnhanceMasterRowData.Attribute.Count; i++)
					{
						GameObject gameObject = this.m_AttrPool.FetchGameObject(false);
						gameObject.name = i.ToString();
						gameObject.transform.parent = this.m_CurAttrListGo.transform;
						gameObject.transform.localScale = Vector3.one;
						gameObject.transform.localPosition = new Vector3(0f, (float)(-(float)i * this.m_gap), 0f);
						this.FillAttrItem(gameObject, curStageEnhanceMasterRowData.Attribute[i, 0], curStageEnhanceMasterRowData.Attribute[i, 1]);
					}
				}
			}
			bool flag3 = this.m_doc.HistoryMaxLevel >= this.m_doc.TheMasterMaxLevel;
			if (flag3)
			{
				this.m_MaxTipsGo.SetActive(true);
			}
			else
			{
				this.m_MaxTipsGo.SetActive(false);
				EnhanceMaster.RowData nextStageEnhanceMasterRowData = this.m_doc.GetNextStageEnhanceMasterRowData(this.m_doc.HistoryMaxLevel);
				bool flag4 = nextStageEnhanceMasterRowData != null;
				if (flag4)
				{
					for (int j = 0; j < nextStageEnhanceMasterRowData.Attribute.Count; j++)
					{
						GameObject gameObject = this.m_AttrPool.FetchGameObject(false);
						gameObject.name = j.ToString();
						gameObject.transform.parent = this.m_NextStageAttrListGo.transform;
						gameObject.transform.localScale = Vector3.one;
						gameObject.transform.localPosition = new Vector3(0f, (float)(-(float)j * this.m_gap), 0f);
						this.FillAttrItem(gameObject, nextStageEnhanceMasterRowData.Attribute[j, 0], nextStageEnhanceMasterRowData.Attribute[j, 1]);
					}
					this.m_NextStageLevel.SetText(string.Format("{0}{1}", nextStageEnhanceMasterRowData.TotalEnhanceLevel, XStringDefineProxy.GetString("LevelName")));
				}
			}
		}

		private void FillAttrItem(GameObject go, uint id, uint value)
		{
			IXUILabel ixuilabel = go.transform.Find("Name").GetComponent("XUILabel") as IXUILabel;
			ixuilabel.SetText(XStringDefineProxy.GetString((XAttributeDefine)id));
			ixuilabel = (go.transform.Find("Num").GetComponent("XUILabel") as IXUILabel);
			ixuilabel.SetText(string.Format("+{0}", value));
		}

		private void OnClickClose(IXUISprite sp)
		{
			base.SetVisible(false);
		}
	}
}