using System; using System.Collections.Generic; using Cute; using UnityEngine; using Wizard; public class UserTicketCountDialog : MonoBehaviour { [SerializeField] private UIWrapContent _wrapContents; [SerializeField] private WrapContentsScrollBarSize _wrapScrollbarSize; [SerializeField] private UIScrollBarWrapContent _wrapScrollbarContents; [SerializeField] private GameObject _noItemObject; private List _loadFileList = new List(); private DialogBase _parentDialog; private List _itemList = new List(); public void Init(DialogBase parentDialog) { _parentDialog = parentDialog; UserTicketCountContents.ItemColumn item = default(UserTicketCountContents.ItemColumn); for (int i = 0; i < Data.Master.ItemList.Count; i++) { int itemNum = PlayerStaticData.GetItemNum(Data.Master.ItemList[i].UserGoodsId); if (itemNum > 0 && Item.IsTicket(UserGoods.Type.Item, Data.Master.ItemList[i].UserGoodsId)) { item.UserGoodsId = Data.Master.ItemList[i].UserGoodsId; item.IconTextureName = Data.Master.ItemList[i].thumbnail; item.PossetionNumber = itemNum; item.unitFormat = Data.Master.ItemList[i].unitFormat; string value = null; Data.Load.data.UserItemExpireTimeDictionary.TryGetValue(item.UserGoodsId, out value); item.TimeLimit = value; _itemList.Add(item); _loadFileList.Add(Toolbox.ResourcesManager.GetAssetTypePath(item.IconTextureName, ResourcesManager.AssetLoadPathType.Item)); } } if (_itemList.Count == 0) { _noItemObject.SetActive(value: true); _wrapContents.gameObject.SetActive(value: false); _wrapScrollbarContents.gameObject.SetActive(value: false); return; } UIScrollView component = _wrapContents.transform.parent.GetComponent(); UIPanel component2 = component.GetComponent(); _noItemObject.SetActive(value: false); _wrapContents.gameObject.SetActive(value: true); _wrapScrollbarContents.gameObject.SetActive(value: true); _wrapContents.onInitializeItem = _OnInitializeItem; _wrapContents.maxIndex = 0; _wrapScrollbarContents.m_WrapContents = _wrapContents; _wrapContents.minIndex = -(_itemList.Count - 1); component.ResetPosition(); if (component2.height > (float)(_itemList.Count * _wrapContents.itemSize)) { component.verticalScrollBar.gameObject.SetActive(value: false); component.enabled = false; } else { component.verticalScrollBar.gameObject.SetActive(value: true); component.enabled = true; } parentDialog.SetActive(inActive: false); UIManager.GetInstance().createInSceneCenterLoading(); UIManager.GetInstance().StartCoroutine(Toolbox.ResourcesManager.LoadAssetGroupAsync(_loadFileList, delegate { parentDialog.SetActive(inActive: true); UIManager.GetInstance().closeInSceneCenterLoading(); _wrapScrollbarSize.ContentUpdate(); _wrapContents.SortBasedOnScrollMovement(); })); } private void _OnInitializeItem(GameObject go, int wrapIndex, int realIndex) { int num = realIndex * -1; go.name = num.ToString(); Transform[] componentsInChildren = go.GetComponentsInChildren(includeInactive: true); Transform[] array; if (num >= _itemList.Count || num < 0) { array = componentsInChildren; for (int i = 0; i < array.Length; i++) { array[i].gameObject.SetActive(value: false); } return; } array = componentsInChildren; for (int i = 0; i < array.Length; i++) { array[i].gameObject.SetActive(value: true); } SetContents(num, go.GetComponent()); } private void SetContents(int ItemListIndex, UserTicketCountContents contents) { Action onClick = delegate { MoveSceneAction(); }; contents.SetData(_itemList[ItemListIndex], onClick); } private void MoveSceneAction() { GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE); _parentDialog.Close(); } private void OnDestroy() { Toolbox.ResourcesManager.RemoveAssetGroup(_loadFileList); } }