123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- /// #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
- {
- /// <summary>
- /// UI逻辑处理类
- /// </summary>
- /// <typeparam name=""></typeparam>
- public partial class DragonEggEquipmentUICtrl : UIController<DragonEggEquipmentUIVM>
- {
- private List<CommonItemBaseView> _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<CommonItemBaseView>()
- {
- VM.Weapon,VM.Helmet,VM.Clothes,VM.Hand,VM.Pants,VM.Boots
- };
- }
- }
- /// <summary>
- /// 显示装备UI
- /// </summary>
- 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++;
- });
- }
- /// <summary>
- /// 更换装备
- /// </summary>
- /// <param name="type"></param>
- /// <param name="id"></param>
- 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);
- }
- }
- }
- }
|