Exemplo n.º 1
0
 void Close()
 {
     if (cursorItem != InventoryItemType.Empty)
     {
         if (!player.inventory.AddItemInEmptySlot(cursorItem))
         {
             if (lastSelectedEmptyCell != null)
             {
                 lastSelectedEmptyCell.SetItem(cursorItem);
             }
             else
             {
                 Debug.LogWarning("Couldn't replace item back into empty space. Oops!");
             }
         }
     }
     ResetScreen();
     gameObject.SetActive(false);
 }
Exemplo n.º 2
0
    void HandleGridCellClick(InventoryGridCell cell)
    {
        InventoryItemType oldItem = cursorItem;
        InventoryItemType newItem = cell.GetItem();

        if (oldItem != newItem)
        {
            // Select item into new cursor
            cursorItem    = newItem;
            cursor.sprite = iconRef.GetSpriteForItem(newItem);

            // Swap old cursor item into inventory
            cell.SetItem(oldItem);

            if (oldItem == InventoryItemType.Empty)
            {
                lastSelectedEmptyCell = cell;
            }
        }
    }