예제 #1
0
        public void RemoveItem(BaseObjectData baseObjectData)
        {
            //find the inventory slot for the item
            var index = Items.FindIndex(inventoryItem => inventoryItem.BaseObjectData == baseObjectData);

            //update
            if (index != -1)
            {
                Items[index].ChangeAmount(-1);
            }

            //notify listeners
            OnRemove?.Raise();
        }
예제 #2
0
        private GameEvent OnReset; //raised whenever we decrement the count for an inventory item (e.g. health)

        public void AddItem(BaseObjectData baseObjectData)
        {
            //find the inventory slot for the item
            var index = Items.FindIndex(inventoryItem => inventoryItem.BaseObjectData == baseObjectData);

            //update
            if (index != -1)
            {
                Items[index].ChangeAmount(1);
            }
            else
            {
                Items.Add(new InventoryItem(baseObjectData, 1, 100));
            }

            //notify listeners
            OnAdd?.Raise();
        }
예제 #3
0
 public InventoryItem(BaseObjectData baseObjectData, int amount, int maxAmount)
 {
     BaseObjectData = baseObjectData;
     Amount         = amount;
     MaxAmount      = maxAmount;
 }