Пример #1
0
    public bool AddItem(ItemObject itemObject)
    {
        if (_items.Count < _space)
        {
            var item = itemObject.GetItem();
            if (_itemsInfo.ContainsKey(item._itemName))
            {
                Debug.Log("Already Exist item: " + item._itemName);
                _itemsInfo[item._itemName].count++;
            }
            else
            {
                _items.Add(item);
                InventoryInfo newInfo = new InventoryInfo();
                newInfo.count     = 1;
                newInfo.slotIndex = 0;
                _itemsInfo.Add(item._itemName, newInfo);
            }


            if (null != onItemChangedCallback)
            {
                onItemChangedCallback.Invoke();
            }

            return(true);
        }

        return(false);
    }