快速使用相关

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

@@ -14,24 +14,26 @@ namespace NBF
{
private List<ItemInfo> _items = new List<ItemInfo>();
private RoleBag _roleBag;
protected override void OnInit()
{
// List.SetVirtual();
}
protected override void OnShow()
{
var role = App.Main.GetComponent<Role>();
_roleBag = role.GetComponent<RoleBag>();
SetList();
SetSlotList();
}
#region
private void SetList()
{
var role = App.Main.GetComponent<Role>();
var roleBag = role.GetComponent<RoleBag>();
_items.Clear();
foreach (var roleBagItem in roleBag.Items)
foreach (var roleBagItem in _roleBag.Items)
{
if (CanShow(roleBagItem))
{
@@ -51,9 +53,41 @@ namespace NBF
if (obj is BagItem bagItem)
{
bagItem.SetData(itemData);
bagItem.draggable = true;
}
}
#endregion
#region
private void SetSlotList()
{
SlotList.RemoveChildrenToPool();
for (int index = 0; index < 7; index++)
{
if (SlotList.AddItemFromPool() is BagSlotItem slotItem)
{
slotItem.SetData(index, _roleBag.GetSlotItem(index));
slotItem.OnChangeSlot = OnChangeSlotItem;
}
}
}
private void OnChangeSlotItem(int index, long id)
{
_roleBag.SetSlot(index, id).OnCompleted(OnChangeSlotItemDone);
}
private void OnChangeSlotItemDone()
{
SetSlotList();
// SlotList.RefreshVirtualList();
}
#endregion
private bool CanShow(ItemInfo itemInfo)
{
if (itemInfo.ItemType == ItemType.Rod)