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

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

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

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

	private IXUILabel m_FightValue;

	private IXUISpriteAnimation m_TitleName;

	private IXUISprite m_TitleSprite;

	private IXUITexture m_TitleTexture;

	private XFx m_titleEffect;

	private int m_selectTitle = -1;

	public void Init(Transform go)
	{
		this.transform = go;
		this.m_FightValue = (this.transform.Find("Fight/FightValue").GetComponent("XUILabel") as IXUILabel);
		this.m_TitleName = (this.transform.Find("TitleName").GetComponent("XUISpriteAnimation") as IXUISpriteAnimation);
		this.m_TitleSprite = (this.transform.Find("TitleName").GetComponent("XUISprite") as IXUISprite);
		this.m_TitleTexture = (this.transform.Find("TitleIcon").GetComponent("XUITexture") as IXUITexture);
		Transform transform = this.transform.Find("Att/AttTmpl");
		this.m_ItemPool.SetupPool(transform.parent.gameObject, transform.gameObject, 2u, true);
	}

	public void Set(TitleTable.RowData rowData)
	{
		bool flag = rowData == null;
		if (flag)
		{
			this.gameObject.SetActive(false);
		}
		else
		{
			bool flag2 = this.m_selectTitle == (int)rowData.RankID;
			if (!flag2)
			{
				this.Reset();
				this.m_selectTitle = (int)rowData.RankID;
				this.gameObject.SetActive(true);
				this.m_ItemPool.FakeReturnAll();
				double num = 0.0;
				int i = 0;
				int count = rowData.Attribute.Count;
				while (i < count)
				{
					GameObject gameObject = this.m_ItemPool.FetchGameObject(false);
					num += XSingleton<XPowerPointCalculator>.singleton.GetPPT(rowData.Attribute[i, 0], rowData.Attribute[i, 1], null, -1);
					IXUILabel ixuilabel = gameObject.transform.Find("Value").GetComponent("XUILabel") as IXUILabel;
					IXUILabel ixuilabel2 = gameObject.transform.Find("Label").GetComponent("XUILabel") as IXUILabel;
					ixuilabel2.SetText(XStringDefineProxy.GetString((XAttributeDefine)rowData.Attribute[i, 0]));
					ixuilabel.SetText(XSingleton<XCommon>.singleton.StringCombine("+", rowData.Attribute[i, 1].ToString()));
					gameObject.transform.localPosition = new Vector3(0f, (float)(-(float)i * 30 - 10), 0f);
					i++;
				}
				this.m_ItemPool.ActualReturnAll(false);
				this.m_FightValue.SetText(XSingleton<XCommon>.singleton.StringCombine("+", ((uint)num).ToString()));
				this.m_TitleName.SetNamePrefix(rowData.RankAtlas, rowData.RankIcon);
				this.m_TitleName.SetFrameRate(XTitleDocument.TITLE_FRAME_RATE);
				this.m_TitleName.MakePixelPerfect();
				this.m_TitleTexture.SetTexturePath(rowData.RankPath);
				bool flag3 = string.IsNullOrEmpty(rowData.AffectRoute);
				if (!flag3)
				{
					this.m_titleEffect = XSingleton<XFxMgr>.singleton.CreateUIFx(rowData.AffectRoute, this.m_TitleTexture.gameObject.transform, false);
				}
			}
		}
	}

	public void Reset()
	{
		bool flag = this.m_titleEffect != null;
		if (flag)
		{
			XSingleton<XFxMgr>.singleton.DestroyFx(this.m_titleEffect, true);
		}
		this.m_TitleTexture.SetTexturePath("");
	}
}