快速使用相关

This commit is contained in:
2025-11-19 00:08:25 +08:00
parent d18c32211c
commit dcd61c1a88
130 changed files with 687 additions and 58 deletions

View File

@@ -1,16 +1,78 @@
// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖
using System;
using UnityEngine;
using FairyGUI;
using Fantasy;
using NBC;
using NBF.Fishing2;
using NBF.Utils;
using Log = NBC.Log;
namespace NBF
{
public partial class BagSlotItem : GButton
{
public int Index { get; private set; }
public Action<int, long> OnChangeSlot;
private void OnInited()
{
onDrop.Add(context => { this.icon = (string)context.data; });
onDrop.Add(OnDrop);
BtnRemove.onClick.Set(OnRemove);
onClick.Add(OnClick);
}
private void OnClick()
{
if (showType.selectedIndex == 0)
{
// Notices.Info("拖拽放入");
}
}
private void OnRemove(EventContext context)
{
context.PreventDefault();
OnChangeSlot?.Invoke(Index, 0);
}
private void OnDrop(EventContext context)
{
var obj = context.initiator;
if (obj is BagItem bagItem)
{
Log.Info($"放下了:{bagItem.ItemInfo.Id}");
OnChangeSlot?.Invoke(Index, bagItem.ItemInfo.Id);
}
}
public void SetData(int index, ItemInfo itemInfo = null)
{
Index = index;
TextIndex.text = (index + 1).ToString();
if (itemInfo != null)
{
showType.selectedIndex = 1;
icon = itemInfo.ConfigId.GetIcon();
if (itemInfo.Count > 1)
{
TextCount.text = itemInfo.Count.ToString();
}
else
{
TextCount.text = string.Empty;
}
Quality.SetQuality(itemInfo.Config.Quality);
}
else
{
showType.selectedIndex = 0;
TextCount.text = string.Empty;
icon = string.Empty;
}
}
}
}