示例#1
0
    public void UpdateBackpack()
    {
        if (localPlayerInventory == null)
        {
            return;
        }

        ClearBackpack();

        int backpackSlotIndexCounter = 0;

        foreach (InventorySlot slot in localPlayerInventory.inventorySlots)
        {
            BackpackSlot newBackpackSlot = AddBackpackSlot(slot);

            newBackpackSlot.backpackSlotId = backpackSlotIndexCounter;
            backpackSlotIndexCounter++;

            newBackpackSlot.item = slot.InventoryItem;
            if (!slot.IsEmpty)
            {
                BackpackInventoryItem newItem = InstantiateBackpackInventoryItem(slot.InventoryItem);
                newItem.SetPositionTo(newBackpackSlot);
            }
        }

        UpdateGoldAmount();
        UpdateSlotCount();
    }
示例#2
0
    private BackpackInventoryItem InstantiateBackpackInventoryItem(InventoryObject inventoryObject)
    {
        GameObject            newItem = GameObject.Instantiate(backpackInventoryItemPrefab);
        BackpackInventoryItem bii     = newItem.GetComponent <BackpackInventoryItem>();

        bii.transform.SetParent(draggableArea.transform);
        bii.SetImage(inventoryObject.inventoryIcon);
        return(bii);
    }