summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/ForgeSuccessHandler.cs
blob: 2217323fd9337e19a9729a059cd5855daab33345 (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
using System;
using UILib;
using UnityEngine;

namespace XMainClient
{
	internal class ForgeSuccessHandler : DlgHandlerBase
	{
		private XForgeDocument m_doc;

		private IXUISprite m_closeBtn;

		private IXUIButton m_gotoBtn;

		private IXUILabel m_attrNameLab;

		private IXUILabel m_attrValueLab;

		private IXUISprite m_checkBoxSpr;

		protected override void Init()
		{
			base.Init();
			this.m_doc = XForgeDocument.Doc;
			this.m_closeBtn = (base.PanelObject.transform.Find("Bg/Close").GetComponent("XUISprite") as IXUISprite);
			this.m_gotoBtn = (base.PanelObject.transform.Find("Bg/GotoBtn").GetComponent("XUIButton") as IXUIButton);
			this.m_checkBoxSpr = (base.PanelObject.transform.Find("Bg/Toggle").GetComponent("XUISprite") as IXUISprite);
			Transform transform = base.PanelObject.transform.Find("Bg/AttrItem");
			this.m_attrNameLab = (transform.Find("Name").GetComponent("XUILabel") as IXUILabel);
			this.m_attrValueLab = (transform.Find("NowValue").GetComponent("XUILabel") as IXUILabel);
		}

		public override void RegisterEvent()
		{
			base.RegisterEvent();
			this.m_closeBtn.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnCloseClicked));
			this.m_gotoBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnGotoClicked));
			this.m_checkBoxSpr.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnClickToggle));
		}

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

		protected override void OnHide()
		{
			base.OnHide();
		}

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

		private void FillContent()
		{
			GameObject gameObject = this.m_checkBoxSpr.transform.Find("selected").gameObject;
			bool isShowTips = this.m_doc.IsShowTips;
			if (isShowTips)
			{
				gameObject.SetActive(false);
				this.m_checkBoxSpr.ID = 0UL;
			}
			else
			{
				gameObject.SetActive(true);
				this.m_checkBoxSpr.ID = 1UL;
			}
			XItem itemByUID = XBagDocument.BagDoc.GetItemByUID(this.m_doc.CurUid);
			bool flag = itemByUID == null;
			if (!flag)
			{
				XEquipItem xequipItem = itemByUID as XEquipItem;
				bool flag2 = xequipItem.forgeAttrInfo.ForgeAttr.Count == 0;
				if (!flag2)
				{
					EquipSlotAttrDatas attrData = XForgeDocument.ForgeAttrMgr.GetAttrData((uint)itemByUID.itemID);
					bool flag3 = attrData == null;
					if (!flag3)
					{
						string color = attrData.GetColor(1, xequipItem.forgeAttrInfo.ForgeAttr[0]);
						string text = string.Format("[{0}]{1}[-]", color, XAttributeCommon.GetAttrStr((int)xequipItem.forgeAttrInfo.ForgeAttr[0].AttrID));
						this.m_attrNameLab.SetText(text);
						text = string.Format("[{0}]{1}[-]", color, xequipItem.forgeAttrInfo.ForgeAttr[0].AttrValue);
						this.m_attrValueLab.SetText(text);
					}
				}
			}
		}

		private void OnCloseClicked(IXUISprite spr)
		{
			base.SetVisible(false);
		}

		private bool OnGotoClicked(IXUIButton btn)
		{
			base.SetVisible(false);
			XSmeltDocument.Doc.SelectEquip(this.m_doc.CurUid);
			return true;
		}

		private void OnClickToggle(IXUISprite spr)
		{
			GameObject gameObject = spr.transform.Find("selected").gameObject;
			bool flag = spr.ID == 0UL;
			if (flag)
			{
				spr.ID = 1UL;
				gameObject.SetActive(true);
				this.m_doc.IsShowTips = false;
			}
			else
			{
				spr.ID = 0UL;
				gameObject.SetActive(false);
				this.m_doc.IsShowTips = true;
			}
		}
	}
}