Example #1
0
    private bool increaseItemCountInInventory(ItemInfo itmInf)
    {
        ItemInfo inventoryItem = items.Find(x => x.itemName == itmInf.itemName);

        Debug.Log(inventoryItem.getAmount());
        inventoryItem.increaseAmountBy(itmInf.getAmount());
        Debug.Log(inventoryItem.getAmount());
        return(true);
    }
Example #2
0
    private bool increaseItemCountInInventory(ItemInfo itmInf, int inc)
    {
        ItemInfo inventoryItem = items.Find(x => x.itemName == itmInf.itemName);

        Debug.Log("before increase in inventory " + inventoryItem.getAmount());
        inventoryItem.increaseAmountBy(inc);
        Debug.Log("after increase in inventory " + inventoryItem.getAmount());
        return(true);
    }
Example #3
0
    public bool decreaseItemCountInInventoryByOne(ItemInfo itmInf)
    {
        ItemInfo inventoryItem = items.Find(x => x.itemName == itmInf.itemName);

        Debug.Log(inventoryItem.getAmount());
        bool errorInDecrease = inventoryItem.decreaseAmountBy(1);

        if (inventoryItem.getAmount() < 1)
        {
            removeItemFromInventoryList(inventoryItem);
        }

        Debug.Log(inventoryItem.getAmount());
        return(errorInDecrease);
    }
Example #4
0
    public bool Craft(IBlueprint bp)
    {
        Dictionary <string, int> mats  = bp.getMaterials();
        List <ItemInfo>          items = inventory.getItems();

        foreach (string mat in mats.Keys)
        {
            ItemInfo inventoryItem = items.Find(x => x.itemName == mat);

            if (inventoryItem == null)
            {
                return(false);
            }

            int neededAmount;
            mats.TryGetValue(mat, out neededAmount);

            if (!enoughMats(inventoryItem.getAmount(), neededAmount))
            {
                return(false);
            }

            inventory.decreaseItemCountInInventory(inventoryItem, neededAmount);
        }
        addCraftedToInventory(bp);
        return(true);
    }
Example #5
0
    public bool decreaseItemCountInInventory(ItemInfo itmInf, int dec)
    {
        ItemInfo inventoryItem = items.Find(x => x.itemName == itmInf.itemName);

        Debug.Log("before decrease in inventory " + inventoryItem.getAmount());
        bool itemsLeft = true;

        inventoryItem.decreaseAmountBy(dec);
        if (inventoryItem.getAmount() < 1)
        {
            removeItemFromInventoryList(inventoryItem);
            itemsLeft = false;
        }

        Debug.Log("after decrease in inventory " + inventoryItem.getAmount());
        return(itemsLeft);
    }
Example #6
0
 private bool increaseItemCountInInventory(ItemInfo itmInf)
 {
     ItemInfo inventoryItem = items.Find (x => x.itemName == itmInf.itemName);
     Debug.Log (inventoryItem.getAmount ());
     inventoryItem.increaseAmountBy (itmInf.getAmount ());
     Debug.Log (inventoryItem.getAmount ());
     return true;
 }
Example #7
0
    private void drawSlotWithItem(int row, int col, int slotW, int slotH)
    {
        ItemInfo   itmInf      = inventory.getItems() [slotInd(row, col)];
        GUIContent itemContent = new GUIContent(itmInf.itemName + "\n x " + itmInf.getAmount(), itmInf.description);

        setStyle(itmInf);               // Edit inventory slot text colors etc.
        if (GUI.Button(createSlotRect(row, col, slotW, slotH), itemContent, slotStyle))
        {
            itemButtonLogic(itmInf);
        }
    }
Example #8
0
 public bool addItem(ItemInfo itmInf)
 {
     if (!items.Contains(itmInf))
     {
         return(addItemToNewInventorySlot(itmInf));
     }
     else
     {
         return(increaseItemCountInInventory(itmInf, itmInf.getAmount()));
     }
 }
Example #9
0
    private void drawSlotWithItem(int row, int col, int slotW, int slotH)
    {
        ItemInfo   itmInf      = inventory.getItems() [slotInd(row, col)];
        GUIContent itemContent = new GUIContent("x " + itmInf.getAmount(), itmInf.description);

        GUI.BeginGroup(createSlotRect(row, col, slotW, slotH));
        float textRatio = 0.3f;
        float textH     = slotH * textRatio;

        GUI.Box(new Rect(0, 0, slotW, textH), itemContent);

        setStyle(itmInf);               // Edit inventory slot text colors etc.
        if (GUI.Button(new Rect(0, textH, slotW, slotH * (1 - textRatio)), "", slotStyle))
        {
            itemButtonLogic(itmInf);
        }
        GUI.EndGroup();
    }