Example #1
0
    public void ItemAddOrUpdate(Item item, bool toCount, bool isEmpty)
    {
        foreach (var UIItem in activeItems)
        {
            if (UIItem.item.ObjectSlug == item.ObjectSlug)
            {
                emptyItem = UIItem;
                break;
            }
        }

        if (isEmpty)
        {
            Debug.Log("Destroying " + item.ItemName + " item container");
            Destroy(emptyItem.gameObject);
            activeItems.Remove(emptyItem);
        }
        else
        {
            if (toCount)
            {
                Debug.Log(emptyItem.item.ObjectSlug);
                emptyItem.UpdateValues();
            }
            else
            {
                Debug.Log("Adding Item: " + item.ItemName);
                emptyItem = Instantiate(itemContainer);
                activeItems.Add(emptyItem);
                emptyItem.SetItem(item);
                emptyItem.transform.SetParent(scrollViewContent, false);
            }
        }
    }
Example #2
0
    public void sell(Item item, ShopUIItem UIitem, int count)
    {
        Debug.Log("Selling " + count + item.ItemName);
        int counter = 0;

        while (counter < count)
        {
            inventory.RemoveItem(item.ObjectSlug);
            playersystem.ChangeMoney((int)item.MonetaryValue, true);
            counter++;
        }
        UIitem.UpdateValues();
    }