/// #pkgName FGUI包名
/// #panelName UIPanel名字
/// #UIName = $"{#pkgName}{#panelName}" UIKey名字
/// 该脚本由模板创建
/// created by cb 2024
using FairyGUI;
using FL.Data;
using XGame;
using XGame.Database;
using XGame.Framework.UI;
namespace FL.FGUI
{
///
/// UI逻辑处理类
///
///
public partial class PartnerEpiBagListItemCtrl : UIController
{
protected override void OnEnable(object intent)
{
AddUIListenres();
}
protected override void OnDisable()
{
RemoveUIListenres();
}
#region UI事件
private void AddUIListenres()
{
VM.EpiIcon.VM.PanelEvent.Add(OnClickBagEpigraph);
}
private void RemoveUIListenres()
{
VM.EpiIcon.VM.PanelEvent.Remove(OnClickBagEpigraph);
}
#endregion
#region 点击事件
private void OnClickBagEpigraph(EventContext eventContext)
{
Context.UI.OpenAsync(
UIKeys.PartnerEpiDetailInfo,
new PartnerEpiDetailInfoParam()
{
EpigraphId = _id,
}
);
}
#endregion
#region 属性
private int _id;
#endregion
public void OnRefresh(int index, EpigraphTable table)
{
_id = table.Id;
VM.EpiIcon.Ctrl.SetEpiIcon(_id, true);
var info = EpigraphData.Instance.GetEpigraphAttrByTableId(_id);
if (info != null)
{
if (info.PartnerId > 0)
{
var partnerTable = PartnerTableRepo.Get(info.PartnerId);
if(partnerTable == null)
{
Log.Error($"圣兵表不存在,${info.PartnerId}");
return;
}
VM.IsBind.selectedIndex = 0;
VM.PzLoader.url = AddressableDefine.EpigraphTypePz(table.Quality);
VM.IconLoader.url = partnerTable?.Icon2;
}
else
{
VM.IsBind.selectedIndex = 1;
}
}
else
{
VM.IsBind.selectedIndex = 1;
}
OnUpdateProgress();
}
private void OnUpdateProgress()
{
var info = EpigraphData.Instance.GetEpigraphAttrByTableId(_id);
var curlv = info != null ? info.StarLv : 1;
var table = epigraphUpTableRepo.GetEpiragphUp(_id, curlv);
if (table == null)
{
Log.Error($"铭文升级表不存在,id:{_id}, lv:{curlv}");
return;
}
VM.ChipPbar.max = table.LevelUpCost;
VM.ChipPbar.value = ItemData.Instance.GetItemNum(table.PetId);
}
}
}