From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Assets/Scripts/XMainClient/UI/TitanbarView.cs | 123 +++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/UI/TitanbarView.cs (limited to 'Client/Assets/Scripts/XMainClient/UI/TitanbarView.cs') diff --git a/Client/Assets/Scripts/XMainClient/UI/TitanbarView.cs b/Client/Assets/Scripts/XMainClient/UI/TitanbarView.cs new file mode 100644 index 00000000..76074963 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/UI/TitanbarView.cs @@ -0,0 +1,123 @@ +using System; +using System.Collections.Generic; +using UnityEngine; +using XMainClient.UI.UICommon; +using XUtliPoolLib; + +namespace XMainClient.UI +{ + internal class TitanbarView : DlgBase + { + 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.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.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 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.singleton.GetSysData(XFastEnumIntEqualityComparer.ToInt(sys)); + bool flag = sysData == null; + int[] result; + if (flag) + { + result = this.m_DefaultItemID; + } + else + { + result = sysData.TitanItems; + } + return result; + } + } +} -- cgit v1.1-26-g67d0