/// #pkgName FGUI包名
/// #panelName UIPanel名字
/// #UIName = $"{#pkgName}{#panelName}" UIKey名字
/// 该脚本由模板创建
/// created by cb 2024
using FairyGUI;
using FL.Data.Items;
using XGame.Framework.UI;
namespace FL.FGUI
{
///
/// UI逻辑处理类
///
///
public partial class CommonItemBaseCtrl : UIController
{
private IItemBase _data;
private bool _bShowBaseInfo;
protected override void OnEnable(object intent)
{
AddUIListenres();
}
protected override void OnDisable()
{
RemoveUIListenres();
}
#region UI事件
private void AddUIListenres()
{
VM.ItemBtn.onClick.Add(OnClickBtn);
}
private void RemoveUIListenres()
{
VM.ItemBtn.onClick.Remove(OnClickBtn);
}
#endregion
private void OnClickBtn(EventContext context)
{
if (_data == null)
return;
if (_data is ItemBase)
{
ShowItemInfoPanel();
}
else
{
Context.UI.OpenAsync(UIKeys.EquipEquipPanel, _data);
}
}
///
/// 简易的道具物品信息
///
private void ShowItemInfoPanel()
{
//Log.Debug($"显示道具:{data.Name}详情界面");
Context.UI.OpenAsync(UIKeys.ItemInformationPanel, _data);
}
public void ShowEmptyUI()
{
_data = null;
VM.QualityImg.icon = "daojukuang1";
}
public void ShowUI(IItemBase item)
{
_data = item;
VM.QualityImg.icon = AddressableDefine.ItemFrame(item.Quality);
VM.ItemIcon.icon = item.Icon;
VM.IsGetImg.visible = false;
if (item is ItemBase itemBase)
{
VM.LvLabel.visible = false;
if (itemBase.Count > 0)
{
VM.CountLabel.text = itemBase.Count.FormatNumber();
VM.CountLabel.visible = true;
}
else
{
VM.CountLabel.visible = false;
}
VM.IsGetImg.visible = itemBase.IsGet == true;
}
else if (item is EquipItemBase equipItemBase)
{
VM.LvLabel.text = $"LV.{equipItemBase.Level}";
VM.CountLabel.visible = false;
VM.LvLabel.visible = true;
}
else if (item is PartnerItemBase partnerItemBase)
{
VM.LvLabel.text = $"LV.{partnerItemBase.Level}";
VM.CountLabel.visible = false;
VM.LvLabel.visible = true;
}
}
///
/// 道具背包中的物品信息
///
///
///
public void OnRefresh(int index, IItemBase itemData)
{
ShowUI(itemData);
}
}
}