using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
///
/// 武将天赋总览界面
///
public class HeroGiftWin : UIBase
{
[SerializeField] ScrollerController scroller;
protected override void OnPreOpen()
{
scroller.OnRefreshCell += OnRefreshCell;
CreateScroller();
}
protected override void OnPreClose()
{
scroller.OnRefreshCell -= OnRefreshCell;
}
private List GetKeys()
{
List res = new List();
foreach (var config in HeroTalentConfig.GetValues())
{
if (config.InitWeight == 0 || config.WashWeight == 0 || config.AweakWeight == 0)
continue;
res.Add(config.TalentID);
}
return res;
}
List configList = new List();
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);
}
}