Пример #1
0
 public static ItemSlot CreateSlots(string slotName, Item.ItemType slotType)
 {
     ItemSlot newSlot = new ItemSlot();
     newSlot.id = slotName;
     newSlot.slotType = slotType;
     return newSlot;
 }
Пример #2
0
        public Item GrabItem(string itemName)
        {
            Item grabbedItem = new Item();

            Item[] newItems = new Item[collection.Count];
            collection.Keys.CopyTo(newItems,0);

            foreach(Item item in newItems)
            {
                if(item.name == itemName)
                {
                    grabbedItem = item;
                    collection[item] -= 1;

                    if(collection[item] <= 0)
                    {
                        collection.Remove(item);
                    }

                    return grabbedItem;
                }
            }

            Debug.Log("Couldn't find item by name" + itemName + "returned empty item");
            return grabbedItem;
        }
Пример #3
0
 public void UseItem(Item item)
 {
     if(item.type == Item.ItemType.Consumable)
     {
         if(item.addStats != null)
         {
             foreach(Stat s in item.addStats)
             {
                 GetStat(s.id).baseValue += s.baseValue;
             }
         }
         if(item.multiStats != null)
         {
             foreach(Stat s in item.multiStats)
             {
                 GetStat(s.id).baseValue += (GetStat(s.id).baseValue * s.baseValue);
             }
         }
     }
 }
Пример #4
0
        public Item.ItemType getItemType(string itemName)
        {
            Item[] items = new Item[collection.Count];
            collection.Keys.CopyTo(items,0);

            foreach(Item item in items)
            {
                if(item.name == itemName)
                {
                    return item.type;
                }
            }
            Debug.Log("You trying to get type for item: " + itemName +", but it couldn't be found. Returned " + Item.ItemType.Quest);
            return Item.ItemType.Quest;
        }
Пример #5
0
        public void EquipItem(Item item)
        {
            foreach(ItemSlot inv in equipment)
            {
                if(inv.slotType != item.type) continue;

                inv.heldItem = item;

                for(int i = 0; i < item.addStats.Length; i++)
                {
                    for(int j = 0; j < stats.Length; j++)
                    {
                        if(inv.heldItem.addStats[i].id == stats[j].id)
                        {
                            stats[j].AdditiveModifier(
                                inv.heldItem.name,
                                inv.heldItem.addStats[i].baseValue);
                        }
                    }
                }

                for(int i = 0; i < item.multiStats.Length; i++)
                {
                    for(int j = 0; j < stats.Length; j++)
                    {
                        if(inv.heldItem.multiStats[i].id == stats[j].id)
                        {
                            stats[j].MultiplyModifier(
                                inv.heldItem.name,
                                inv.heldItem.multiStats[i].baseValue);
                        }
                    }
                }

                break;
            }
        }