summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/UI/TitanbarView.cs
blob: 76074963cb12676bbf20dfca6b69ab64cf8d2f1e (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 System.Collections.Generic;
using UnityEngine;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

namespace XMainClient.UI
{
	internal class TitanbarView : DlgBase<TitanbarView, TitanBarBehaviour>
	{
		public override string fileName
		{
			get
			{
				return "Hall/TitanBar";
			}
		}

		public override int layer
		{
			get
			{
				return 1;
			}
		}

		public override bool autoload
		{
			get
			{
				return true;
			}
		}

		private int[] m_DefaultItemID;

		protected override void Init()
		{
			base.Init();
			string[] array = XSingleton<XGlobalConfig>.singleton.GetValue("DefaultTitanItems").Split(XGlobalConfig.ListSeparator);
			this.m_DefaultItemID = new int[array.Length];
			for (int i = 0; i < array.Length; i++)
			{
				this.m_DefaultItemID[i] = int.Parse(array[i]);
			}
		}

		public void SetTitanItems(XSysDefine sys)
		{
			int[] titanItems = this._GetItemIDs(sys);
			this.SetTitanItems(titanItems);
		}

		public void SetTitanItems(int[] itemids)
		{
			base.uiBehaviour.m_ItemPool.FakeReturnAll();
			for (int i = 0; i < base.uiBehaviour.m_ItemList.Count; i++)
			{
				base.uiBehaviour.m_ItemList[i].Recycle();
			}
			base.uiBehaviour.m_ItemList.Clear();
			bool flag = itemids != null;
			if (flag)
			{
				Vector3 tplPos = base.uiBehaviour.m_ItemPool.TplPos;
				for (int j = 0; j < itemids.Length; j++)
				{
					XTitanItem data = XDataPool<XTitanItem>.GetData();
					base.uiBehaviour.m_ItemList.Add(data);
					GameObject gameObject = base.uiBehaviour.m_ItemPool.FetchGameObject(false);
					gameObject.transform.localPosition = new Vector3(tplPos.x - (float)(base.uiBehaviour.m_ItemPool.TplWidth * (itemids.Length - 1 - j)), tplPos.y, tplPos.z);
					data.Set(itemids[j], gameObject);
				}
			}
			base.uiBehaviour.m_ItemPool.ActualReturnAll(false);
		}

		public void TryRefresh(List<int> itemids)
		{
			bool flag = !base.IsVisible();
			if (!flag)
			{
				for (int i = 0; i < itemids.Count; i++)
				{
					this.TryRefresh(itemids[i]);
				}
			}
		}

		public void TryRefresh(int itemid)
		{
			bool flag = !base.IsVisible();
			if (!flag)
			{
				for (int i = 0; i < base.uiBehaviour.m_ItemList.Count; i++)
				{
					bool flag2 = base.uiBehaviour.m_ItemList[i].ItemID == itemid;
					if (flag2)
					{
						base.uiBehaviour.m_ItemList[i].RefreshValue(true);
						break;
					}
				}
			}
		}

		private int[] _GetItemIDs(XSysDefine sys)
		{
			OpenSystemTable.RowData sysData = XSingleton<XGameSysMgr>.singleton.GetSysData(XFastEnumIntEqualityComparer<XSysDefine>.ToInt(sys));
			bool flag = sysData == null;
			int[] result;
			if (flag)
			{
				result = this.m_DefaultItemID;
			}
			else
			{
				result = sysData.TitanItems;
			}
			return result;
		}
	}
}