123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- /// #pkgName FGUI包名
- /// #panelName UIPanel名字
- /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
- /// 该脚本由模板创建
- /// created by cb 2024
- using FairyGUI;
- using FL.Data.Items;
- using FL.Data;
- using XGame.Framework.UI;
- namespace FL.FGUI
- {
- /// <summary>
- /// UI逻辑处理类
- /// </summary>
- /// <typeparam name=""></typeparam>
- public partial class EquipEquipPanelCtrl : UIController<EquipEquipPanelVM>
- {
- private EquipAttr _newEquip;
- private EquipAttr _wearEquip;
- protected override void OnEnable(object intent)
- {
- AddUIListenres();
- ShowUI(intent as EquipItemBase);
- }
- protected override void OnDisable()
- {
- _newEquip = null;
- _wearEquip = null;
- RemoveUIListenres();
- }
- #region UI事件
- private void AddUIListenres()
- {
- VM.WearBtn.onClick.Add(OnClickWearBtn);
- }
- private void RemoveUIListenres()
- {
- VM.WearBtn.onClick.Remove(OnClickWearBtn);
- }
- #endregion
- /// <summary>
- /// 穿戴|替换按钮事件
- /// </summary>
- /// <param name="context"></param>
- private void OnClickWearBtn(EventContext context)
- {
- if (_newEquip == null) return;
- EquipData.Instance.BubblingEquipUid = 0;
- DragonEggService.Instance.OnChangeEquip(_newEquip.Id);
- ClosePanel();
- }
- private void ClosePanel()
- {
- Context.ClosePanel();
- }
- private void ShowUI(EquipItemBase equipBase)
- {
- if (equipBase == null) return;
- _wearEquip = EquipData.Instance.GetWearEquipData(equipBase.EquipType);
- if (_wearEquip != null)
- {
- ShowEquipInfo(_wearEquip);
- VM.WearEquipItem.Disable();
- }
- if (equipBase.Id == 0) // 身上穿戴的装备
- {
- return;
- }
- _newEquip = EquipData.Instance.GetBagEquipItem(equipBase.Id);
- if (_newEquip == null) return;
- bool bShowWear = _wearEquip != null;
- if (bShowWear)
- {
- VM.WearEquipItem.Enable(null);
- VM.WearEquipItem.Ctrl.ShowUI(_newEquip, _wearEquip, true);
- }
- else
- {
- VM.WearEquipItem.Disable();
- }
- VM.NewEquipItem.Ctrl.ShowUI(_newEquip, _wearEquip);
- ShowBtnUI(bShowWear);
- }
- private void ShowBtnUI(bool bWear)
- {
- VM.BtnState.selectedIndex = bWear ? 1 : 2; // 1_替换 2_穿戴
- }
- private void ShowEquipInfo(EquipAttr equip)
- {
- // 展示装备属性详情,不显示按钮
- VM.BtnState.selectedIndex = 0;
- VM.NewEquipItem.Ctrl.ShowUI(equip, equip, true);
- }
- }
- }
|