2
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
4.0 KiB
C#

2 years ago
using Game.Battle;
namespace Game
{
public class PageBlessList : UIPageBase<ViewBlessList>
{
private bool _isShowSub = false;
public PageBlessList()
{
}
protected override void OnCreate()
{
CreateUI(false);
}
protected override void OnDestroy()
{
}
protected override void OnOpen()
{
OnOpen(false);
}
protected override void OnOpen(params object[] values)
{
_isShowSub = false;
if (values.Length > 0 && (bool)values[0])
{
_isShowSub = true;
}
var uiBless = View.m_UI_Bless;
uiBless.m_c1.selectedIndex = _isShowSub ? 1 : 0;
}
protected override void OnClose()
{
}
protected override void OnCreateBind()
{
var master = Util.GetMaster();
BindMainBless(master); //绑定主要祝福
BindSubBlessNum(master); //绑定次要祝福数量
if (_isShowSub)
{
BindSubBless(master); //绑定次要祝福
}
}
public override void Update()
{
}
private void BindMainBless(GameEntity entity)
{
var bag = entity.bag;
var uiBless = View.m_UI_Bless;
// BindData(bag.mainBless, (_, now) =>
// {
// var blessList = uiBless.m_blessList;
// blessList.RemoveChildrenToPool();
// for (int i = (int)ESKillPerformance.Light; i < (int)ESKillPerformance.Max; i++)
// {
// var obj = blessList.AddItemFromPool() as Viewc_BlessItem;
// var key = (ESKillPerformance)i;
// var exsist = now.ContainsKey(key);
// obj.m_c2.selectedIndex = exsist ? 1 : 0;
// obj.m_c4.selectedIndex = 0;
// if (exsist)
// {
// var cfg = Util.GetBlessConfig(now[key]);
// obj.m_c1.selectedIndex = (int)cfg.Bless.Element;
// var texture = Texture(cfg.Bless.Icon);
// obj.m_blessIcon.texture = texture;
// obj.m_blessIconBack.texture = texture;
// }
// else
// {
// obj.m_c1.selectedIndex = 0;
// obj.m_c3.selectedIndex = i;
// }
// }
// });
}
private void BindSubBlessNum(GameEntity entity)
{
var bag = entity.bag;
var uiBless = View.m_UI_Bless;
BindData(bag.AllBless, (_, now) =>
{
var subBlessNum = Util.GetSubBlessNum(entity);
uiBless.m_subBlessNum.text = $"+{subBlessNum}";
});
}
private void BindSubBless(GameEntity entity)
{
var bag = entity.bag;
var uiBless = View.m_UI_Bless;
BindData(bag.AllBless, (_, now) =>
{
var blessList = uiBless.m_blessListSub;
blessList.RemoveChildrenToPool();
var count = 0;
foreach (var item in now)
{
var cfg = Util.GetBlessConfig(item.Key);
var obj = blessList.AddItemFromPool() as Viewc_BlessItem;
var texture = Texture(cfg.Bless.Icon);
obj.m_blessIcon.texture = texture;
obj.m_blessIconBack.texture = texture;
obj.m_c4.selectedIndex = (int)(count / 5) % 2 == 0 ? 0 : 1;
count++;
}
});
}
protected override void OnInput(PPlayerInput context)
{
}
}
}