123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- /// #pkgName FGUI包名
- /// #panelName UIPanel名字
- /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
- /// 该脚本由模板创建
- /// created by cb 2024
- using FairyGUI;
- using FL.Data.Items;
- using XGame.Database;
- using XGame.Framework.UI;
- namespace FL.FGUI
- {
- /// <summary>
- /// UI逻辑处理类
- /// </summary>
- /// <typeparam name=""></typeparam>
- public partial class CommonItemBaseCtrl : UIController<CommonItemBaseVM>
- {
- 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);
- }
- }
- /// <summary>
- /// 简易的道具物品信息
- /// </summary>
- 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;
- if (item is ItemBase itemBase)
- {
- VM.LvLabel.visible = false;
- if (itemBase.Count > 0)
- {
- VM.CountLabel.text = itemBase.Count.ToString();
- VM.CountLabel.visible = true;
- }
- else
- {
- VM.CountLabel.visible = false;
- }
- }
- else if (item is EquipItemBase equipItemBase)
- {
- VM.LvLabel.text = $"Lv.{equipItemBase.Level}";
- VM.CountLabel.visible = false;
- VM.LvLabel.visible = true;
- }
- }
- /// <summary>
- /// 道具背包中的物品信息
- /// </summary>
- /// <param name="index"></param>
- /// <param name="itemData"></param>
- public void OnRefresh(int index, IItemBase itemData)
- {
- ShowUI(itemData);
- }
- }
- }
|