/// #pkgName FGUI包名
/// #panelName UIPanel名字
/// #UIName = $"{#pkgName}{#panelName}" UIKey名字
/// 该脚本由模板创建
/// created by cb 2024
using System.Collections.Generic;
using FairyGUI;
using FL.Data;
using FL.Data.Items;
using XGame.Database;
using XGame.Framework.UI;
namespace FL.FGUI
{
///
/// UI逻辑处理类
///
///
public partial class PartnerBookDetailListItemCtrl : UIController
{
protected override void OnEnable(object intent)
{
AddUIListenres();
}
protected override void OnDisable()
{
RemoveUIListenres();
}
#region UI事件
private void AddUIListenres()
{
VM.GotoBtn.onClick.Add(OnClickGotoBtn);
VM.GetBtn.onClick.Add(OnClickGetBtn);
}
private void RemoveUIListenres()
{
VM.GotoBtn.onClick.Remove(OnClickGotoBtn);
VM.GetBtn.onClick.Remove(OnClickGetBtn);
}
private void OnClickGotoBtn(EventContext context) { }
private void OnClickGetBtn(EventContext context)
{
PartnersService.Instance.RequestJibanRwdGet(_id);
}
#endregion
private int _id;
public void OnRefresh(int index, collect_rewardTable table)
{
_id = table.Id;
VM.DescLabel.text = table.Name;
var item = new ItemBase();
item.Init(table.Reward[0], table.Reward[1]);
VM.ItemBtn.Ctrl.ShowUI(item);
var list = new List();
for (int i = 0; i < table.Attribute.Length; i += 2)
{
list.Add(
new PartnerBookTextParam()
{
attrId = table.Attribute[i],
val = table.Attribute[i + 1],
}
);
}
VM.List.BindDatas(list);
var collect = collectTableRepo.Get(table.CollectId);
XGame.Framework.Assert.IsNotNull(collect);
var starLv = 0;
foreach (var id in collect.Param)
{
if (
collect.Type == 1
&& PartnersData.Instance.TryGetPartnerAttrByTableId(id, out var attr)
)
{
starLv += attr.RisingStarLv;
}
else if (
collect.Type == 2
&& EpigraphData.Instance.TryGetEpigraphAttrByTableId(id, out var epi)
)
{
starLv += epi.StarLv;
}
}
if (starLv >= table.Unlock)
{
if (collect.Type == 1)
{
if (PartnersData.Instance.GetJibaIsActive(table.CollectId, table.Level))
{
VM.State.selectedIndex = 2;
}
else
{
VM.State.selectedIndex = 1;
}
}
else if (collect.Type == 2)
{
if (EpigraphData.Instance.GetJibaIsActive(table.CollectId, table.Level))
{
VM.State.selectedIndex = 2;
}
else
{
VM.State.selectedIndex = 1;
}
}
}
else
{
VM.State.selectedIndex = 0;
}
}
}
}