Exemple #1
0
        /// <summary>
        /// Removes item from the character inventory.
        /// </summary>
        /// <param name="location">Location of item.</param>
        public void RemoveItem(InventoryLocation location)
        {
            if (!location.Valid)
            {
                Debug.LogError("SagaGUI: Can't remove item from inventory — specified inventory location is not valid.");
                return;
            }

            inventoryWindow.FreeSlot(inventoryWindow.FindSlot(location));
        }
Exemple #2
0
        /// <summary>
        /// Adds item to the character inventory at the specific location.
        /// </summary>
        /// <param name="item">The item to add.</param>
        /// <param name="location">Specific location to place item.</param>
        public void AddItem(Item item, InventoryLocation location)
        {
            var freeSlot = inventoryWindow.FindSlot(location);

            if (!freeSlot || freeSlot.InventoryItem != null)
            {
                Debug.LogError("SagaGUI: Can't add an item to the specific slot — it is not empty.");
                return;
            }

            freeSlot.InventoryItem = InventoryItem.Initialize(item);
        }
Exemple #3
0
        /// <summary>
        /// Moves item to another slot.
        /// Will swap items if moved to already occupied slot or stack them if possible.
        /// </summary>
        /// <param name="item">Item to move.</param>
        /// <param name="location">Target location.</param>
        public void MoveItem(Item item, InventoryLocation location)
        {
            var initialItemLocation = inventoryWindow.LocateItem(item);

            RemoveItem(item);

            if (!inventoryWindow.FindSlot(location).Empty)
            {
                var itemInTargetSlot = inventoryWindow.FindSlot(location).InventoryItem.Item;

                if (item.ID == itemInTargetSlot.ID && itemInTargetSlot.MaxStack > 1 &&
                    (itemInTargetSlot.CurStack + item.CurStack) <= item.MaxStack)
                {
                    itemInTargetSlot.CurStack += item.CurStack;
                    return;
                }

                AddItem(itemInTargetSlot, initialItemLocation);
                RemoveItem(location);
            }

            AddItem(item, location);
        }
Exemple #4
0
 internal void FireMoveItem(Item item, InventoryLocation location)
 {
     OnMoveItem(item, location);
 }
 public InventorySlot FindSlot(InventoryLocation location)
 {
     return(Slots[location]);
 }