/// #pkgName FGUI包名
/// #panelName UIPanel名字
/// #UIName = $"{#pkgName}{#panelName}" UIKey名字
/// 该脚本由模板创建
/// created by cb 2024
using FairyGUI;
using FL.Data;
using XGame.Database;
using XGame.Framework.UI;
namespace FL.FGUI
{
///
/// UI逻辑处理类
///
///
public partial class PartnerPartnerListItemCtrl : UIController
{
private int _lineupPlanIndex;
private long _partnerId;
protected override void OnEnable(object intent)
{
AddUIListenres();
}
protected override void OnDisable()
{
RemoveUIListenres();
}
#region UI事件
private void AddUIListenres()
{
VM.ClickBtn.onClick.Add(OnClickBtn);
}
private void RemoveUIListenres()
{
VM.ClickBtn.onClick.Remove(OnClickBtn);
}
private void OnClickBtn(EventContext context)
{
EventSingle.Instance.Notify(EventDefine.ShowTips, "显示圣兵替换界面");
Context.UI.OpenAsync(UIKeys.PartnerReplacePartnerPanel, new PartnerParam()
{
partnerId = _partnerId,
lineupPlanIndex = _lineupPlanIndex
});
}
#endregion
public void OnRefresh(int index, PartnerParam param)
{
_partnerId = param.partnerId;
_lineupPlanIndex = param.lineupPlanIndex;
VM.StateCtrl.selectedIndex = _partnerId > 0 ? 1 : 0;
if (_partnerId > 0)
{
PartnerAttributes partnerData = PartnersData.Instance.PartnersMap[_partnerId];
if (partnerData != null)
{
VM.PartnerItem.Ctrl.ShowUI(partnerData.TableId);
}
}
}
}
}