/// #pkgName FGUI包名
/// #panelName UIPanel名字
/// #UIName = $"{#pkgName}{#panelName}" UIKey名字
/// 该脚本由模板创建
/// created by cb 2024
using FL.Data;
using FL.Data.Items;
using System.Collections.Generic;
using XGame.Database;
using XGame.Framework.UI;
namespace FL.FGUI
{
///
/// UI逻辑处理类
///
///
public partial class DragonEggEquipmentUICtrl : UIController
{
private List _equipItemList;
protected override void OnEnable(object intent)
{
AddUIListenres();
EventSingle.Instance.AddListener(EventDefine.OnChangeEquip, OnChangeEquip);
Init();
ShowEquipUI();
}
protected override void OnDisable()
{
RemoveUIListenres();
EventSingle.Instance.RemoveListener(EventDefine.OnChangeEquip, OnChangeEquip);
if (_equipItemList != null)
{
_equipItemList.Clear();
_equipItemList = null;
}
}
#region UI事件
private void AddUIListenres()
{
}
private void RemoveUIListenres()
{
}
#endregion
private void Init()
{
if (_equipItemList == null)
{
_equipItemList = new List()
{
VM.Weapon,VM.Helmet,VM.Clothes,VM.Hand,VM.Pants,VM.Boots
};
}
}
///
/// 显示装备UI
///
private void ShowEquipUI()
{
UiParam _uiParam = new UiParam();
_uiParam.bShowBtn = true;
_uiParam.bShowLevel = true;
int index = 1;
_equipItemList.ForEach((item) =>
{
EquipItem equipData = ItemData.Instance.GetEquipData((EEquipType)index);
if (equipData != null)
{
item.Ctrl.ShowUI(ItemData.Instance.GetEquipData((EEquipType)index), _uiParam);
}
index++;
});
}
///
/// 更换装备
///
///
///
private void OnChangeEquip(int eventId, object args)
{
if (args == null)
{
return;
}
ChangeEquipParam param = (ChangeEquipParam)args;
CommonItemBaseView equipItem = _equipItemList[(int)param.equipType - 1];
if (equipItem != null)
{
UiParam _uiParam = new UiParam();
_uiParam.bShowBtn = true;
_uiParam.bShowLevel = true;
equipItem.Ctrl.ShowUI(ItemData.Instance.GetEquipData(param.equipType), _uiParam);
}
}
}
}