Exemplo n.º 1
0
    //takes a parameter of ScriptObj_InvItem.InventoryType and returns a list of all InventoryItems of that Tag
    List <ScriptObj_InvItem> GetAllItems(ScriptObj_InvItem.Tag searchForInvType)
    {
        List <ScriptObj_InvItem> newInvItemList = new List <ScriptObj_InvItem>();

        foreach (ScriptObj_InvItem item in allItems)
        {
            if (item.itemTag == searchForInvType)
            {
                newInvItemList.Add(item);
            }
        }

        return(newInvItemList);
    }
Exemplo n.º 2
0
    //here, the inventory will be redisplayed using items of type "Tag" (if you want to view all weapons or potions, i.e.)
    public void ChangeItems(ScriptObj_InvItem.Tag itemType)
    {
        List <ScriptObj_InvItem> itemList = GetAllItems(itemType);

        //this "for" loop designates the numbers that we will take from the allItemSlots list
        //example: page 0 will display allItemSlots items 0 - 7, page 1 will display 8 - 15, etc
        for (int i = numItemSlots * pageNum; i < numItemSlots * (pageNum + 1); i++)
        {
            // do this if the itemList has at least i items
            if (itemList.Count > i)
            {
                //assign items to an inventory slot
                allItemSlots[i % numItemSlots].inventoryItem = itemList[i]; //(10 % 8 = 2 = 2nd slot)
                allItemSlots[i % numItemSlots].NewItemAssigned();
            }
            // do this if itemList doesn't have at least i items
            else
            {
                //remove the current item in the slot (if any) and make it null
                allItemSlots[i % numItemSlots].inventoryItem = null;
                allItemSlots[i % numItemSlots].ItemRemoved();
            }
        }
    }