Exemple #1
0
 private void Start()
 {
     foreach (Slot slot in inventoryReference.Slots)
     {
         DisplaySlot   displaySlot   = Instantiate(displaySlotPrefab, Vector2.zero, Quaternion.identity, group.transform);
         RectTransform rectTransform = displaySlot.gameObject.GetComponent <RectTransform>();
         rectTransform.sizeDelta = group.cellSize;
         displaySlot.Setup(inventoryReference, slot);
     }
 }
    private void GrabItem(DisplaySlot displaySlot, int grabAmount = 0)
    {
        lastItemSlot = displaySlot;

        Slot newSlot = displaySlot.CurrentSlot;
        Item item    = newSlot.Item;

        if (item.IsEmpty)
        {
            return;
        }

        Inventory inventory = displaySlot.Inventory;

        HoldingSlot.SetItem(item.Transfer(grabAmount));
        grabDisplay.Setup(playerInventory.CompoundedInventory, HoldingSlot);

        inventory.OnChanged?.Invoke();
    }