summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/TitleItemDisplay.cs
blob: fd57cb57682317c32ea448c7730c3f864bd70e1e (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
using System;
using UILib;
using UnityEngine;
using XMainClient;
using XMainClient.UI;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

public class TitleItemDisplay
{
	public Transform transform { get; private set; }

	public GameObject gameObject
	{
		get
		{
			return this.transform.gameObject;
		}
	}

	private Transform m_ItemGo;

	private IXUILabel m_PPTLabel;

	private IXUILabel m_RunLabel;

	private IXUILabel m_itemNum;

	private IXUILabel m_itemName;

	private Transform m_ItemIcon;

	public void Init(Transform go)
	{
		this.transform = go;
		this.m_ItemGo = this.transform.Find("Item");
		this.m_ItemIcon = this.transform.Find("Item/Icon");
		this.m_itemNum = (this.transform.Find("Item/Num").GetComponent("XUILabel") as IXUILabel);
		this.m_itemName = (this.transform.Find("Item/ItemName").GetComponent("XUILabel") as IXUILabel);
		this.m_PPTLabel = (this.transform.Find("PPT").GetComponent("XUILabel") as IXUILabel);
		this.m_RunLabel = (this.transform.Find("Leave").GetComponent("XUILabel") as IXUILabel);
		this.m_RunLabel.RegisterLabelClickEventHandler(new LabelClickEventHandler(this.OnClickLableHandler));
	}

	private void OnClickLableHandler(IXUILabel label)
	{
		bool flag = label.ID == 0UL;
		if (flag)
		{
			DlgBase<XFpStrengthenView, XFPStrengthenBehaviour>.singleton.ShowContent(FunctionDef.ZHANLI);
		}
		else
		{
			XSingleton<UiUtility>.singleton.ShowItemAccess((int)label.ID, null);
		}
		DlgBase<TitleDlg, TitleDlgBehaviour>.singleton.SetVisibleWithAnimation(false, null);
	}

	public void SetVisible(bool visible)
	{
		this.gameObject.SetActive(visible);
	}

	public void Set(uint data0, uint data1, string desc)
	{
		this.m_RunLabel.ID = (ulong)data0;
		bool flag = data0 == 0u;
		if (flag)
		{
			this.SetFightValue(data1);
		}
		else
		{
			this.SetItemValue(data0, data1, desc);
		}
	}

	private void SetFightValue(uint value)
	{
		this.m_ItemGo.gameObject.SetActive(false);
		this.m_PPTLabel.gameObject.SetActive(true);
		double attr = XSingleton<XAttributeMgr>.singleton.XPlayerData.GetAttr(XAttributeDefine.XAttr_POWER_POINT_Basic);
		int num = (int)(value - (uint)((int)attr));
		bool flag = value <= attr;
		if (flag)
		{
			this.m_RunLabel.Alpha = 0f;
			this.m_PPTLabel.SetText(XStringDefineProxy.GetString("COMMON_COUNT_TOTAL_FMT", new object[]
			{
				(int)attr,
				value
			}));
		}
		else
		{
			this.m_RunLabel.Alpha = 1f;
			this.m_RunLabel.SetText(XStringDefineProxy.GetString("TITLE_RUN_LABEL_1"));
			this.m_PPTLabel.SetText(XStringDefineProxy.GetString("COMMON_COUNT_TOTAL_NOTENOUGH_FMT", new object[]
			{
				(int)attr,
				value
			}));
		}
	}

	private void ShowTooltipDialog(IXUISprite sprite)
	{
		bool flag = sprite.ID > 0UL;
		if (flag)
		{
			XSingleton<UiUtility>.singleton.ShowTooltipDialog((int)sprite.ID, null, 0u);
		}
	}

	private void SetItemValue(uint itemID, uint value, string desc)
	{
		this.m_ItemGo.gameObject.SetActive(true);
		this.m_PPTLabel.gameObject.SetActive(false);
		ItemList.RowData itemConf = XBagDocument.GetItemConf((int)itemID);
		int num = (int)XBagDocument.BagDoc.GetItemCount((int)itemID);
		this.m_itemName.SetText(desc);
		XItemDrawerMgr.Param.IconType = 1u;
		XSingleton<XItemDrawerMgr>.singleton.normalItemDrawer.DrawItem(this.m_ItemIcon.gameObject, itemConf, 0, false);
		IXUISprite ixuisprite = this.m_ItemIcon.Find("Icon").GetComponent("XUISprite") as IXUISprite;
		ixuisprite.ID = (ulong)((long)itemConf.ItemID);
		ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.ShowTooltipDialog));
		bool flag = (long)num < (long)((ulong)value);
		if (flag)
		{
			this.m_RunLabel.Alpha = 1f;
			this.m_RunLabel.SetText(XStringDefineProxy.GetString("TITLE_RUN_LABEL_1"));
			this.m_itemNum.SetText(XStringDefineProxy.GetString("COMMON_COUNT_TOTAL_NOTENOUGH_FMT", new object[]
			{
				num,
				value
			}));
		}
		else
		{
			this.m_RunLabel.Alpha = 0f;
			this.m_itemNum.SetText(XStringDefineProxy.GetString("COMMON_COUNT_TOTAL_FMT", new object[]
			{
				num,
				value
			}));
		}
	}
}