快速使用相关
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user