using System;
|
using System.Collections.Generic;
|
using UnityEngine;
|
|
public class EquipRecordWin : UIBase
|
{
|
[SerializeField] ScrollerController scroller;
|
[SerializeField] Transform transNo;
|
[SerializeField] TextEx txtTip;
|
EquipRecordManager manager { get { return EquipRecordManager.Instance; } }
|
protected override void OnPreOpen()
|
{
|
|
scroller.OnRefreshCell += OnRefreshCell;
|
manager.OnUpdateRecordListEvent += OnUpdateRecordListEvent;
|
txtTip.text = Language.Get("AutoFight17", manager.maxCnt);
|
scroller.lockType = EnhanceLockType.KeepVertical;
|
CreateScroller(isSort: true, isjump: true);
|
}
|
|
protected override void OnPreClose()
|
{
|
scroller.OnRefreshCell -= OnRefreshCell;
|
manager.OnUpdateRecordListEvent -= OnUpdateRecordListEvent;
|
}
|
|
private void OnUpdateRecordListEvent()
|
{
|
CreateScroller();
|
}
|
|
private void OnRefreshCell(ScrollerDataType type, CellView cell)
|
{
|
var _cell = cell.GetComponent<EquipRecordCell>();
|
_cell?.Display(cell.index, list);
|
}
|
List<EquipRecordManager.EquipRecordData> list;
|
|
private void CreateScroller(bool isSort = false, bool isjump = false)
|
{
|
scroller.Refresh();
|
list = manager.GetRecordList(isSort);
|
bool isNullOrEmpty = list.IsNullOrEmpty();
|
transNo.SetActive(isNullOrEmpty);
|
if (!isNullOrEmpty)
|
{
|
for (int i = list.Count - 1; i >= 0; i--)
|
{
|
scroller.AddCell(ScrollerDataType.Header, i);
|
}
|
}
|
scroller.Restart();
|
if (isjump)
|
{
|
scroller.JumpIndex(0);
|
}
|
|
}
|
}
|