When ever i Call this Function i get the Error:
“KeyNotFoundException: The given key was not present in the dictionary.
System.Collections.Generic.Dictionary`2[System.Int32,Item].get_Item (Int32 key)” on the line indicated by ****'s.
Code:
void CraftItem(int craftedItemID, int R1ID, int R2ID, int R1Amount, int R2Amount){
//Resource 1
for(int i = 0; i < PlayerInventory.Inventory.Count; i++){
if(PlayerInventory.Inventory_.ID == R1ID && PlayerInventory.Inventory*.currentStack >= R1Amount){*_
_ PlayerInventory.Inventory*.currentStack -= R1Amount;
} else if(PlayerInventory.Inventory.ID == R2ID && PlayerInventory.Inventory.currentStack >= R2Amount){
PlayerInventory.Inventory.currentStack -= R2Amount;
}
}
for(int cnt = 0; cnt < PlayerInventory.ItemDictionary.Count; cnt++){
if(PlayerInventory.ItemDictionary[cnt].ID == craftedItemID){**************
Item craftedItem = PlayerInventory.ItemDictionary[cnt];
AddItem(craftedItem);
}
}
}*
Whats wrong with what i am doing?_