/// #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,
PlanId = PartnersData.Instance.UsePlanId,
SlotId = -1,
PartnerId = 0
}
);
}
#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);
VM.IsBind.selectedIndex = 0;
VM.PzLoader.url = AddressableDefine.EpigraphTypePz(table.Quality);
VM.IconLoader.url = partnerTable?.Icon;
}
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 : 0;
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);
}
}
}