using System.Collections.Generic;
|
using System.Linq;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
|
/// <summary>
|
/// 武将天赋总览界面
|
/// </summary>
|
public class HeroGiftWin : UIBase
|
{
|
[SerializeField] ScrollerController scroller;
|
|
|
|
|
protected override void OnPreOpen()
|
{
|
scroller.OnRefreshCell += OnRefreshCell;
|
|
CreateScroller();
|
}
|
|
protected override void OnPreClose()
|
{
|
scroller.OnRefreshCell -= OnRefreshCell;
|
|
}
|
|
private List<int> GetKeys()
|
{
|
List<int> res = new List<int>();
|
foreach (var config in HeroTalentConfig.GetValues())
|
{
|
if (config.InitWeight == 0 || config.WashWeight == 0 || config.AweakWeight == 0)
|
continue;
|
res.Add(config.TalentID);
|
}
|
return res;
|
}
|
|
List<int> configList = new List<int>();
|
void CreateScroller()
|
{
|
configList = GetKeys();
|
var totalCount = configList.Count;
|
|
scroller.Refresh();
|
for (int i = 0; i < totalCount; i++)
|
{
|
if (i % 5 == 0)
|
{
|
scroller.AddCell(ScrollerDataType.Header, i);
|
}
|
}
|
scroller.Restart();
|
}
|
|
void OnRefreshCell(ScrollerDataType type, CellView cell)
|
{
|
var _cell = cell as HeroGiftLineCell;
|
_cell.Display(cell.index, configList);
|
}
|
|
|
}
|