Lists within lists to make a crafting system

Hi,

So I created this class called recipe…All I am trying to do for now is to make a few lists with the different recipe’s for items…

so for example…I want a list that contains the stick, rock and vine items and this list will be called ‘axeRecipe’ because these three things are needed to make an axe.

I have another list with the items my player currently has called ‘items1’…so I want to basically go through these items and check if they are in any of the lists such as ‘axeRecipe’…But right now I can’t even get the lists to work. I am pretty inexperienced.

So how do I create a list containing the three items in the class below?

And then how can I make it so that the script checks my ‘items1’ list (list of items in players inventory) and goes through them to see if they are in the axeRecipe list?

public class recipe
{
public Item stick;
public Item rock;
public Item vine;

public recipe(Item item1, Item item2, Item item3)
{
	Debug.Log ("hello");
}

}

Thanks

Philip

You would have to setup if statements to check for the items individually, its not so effective to do it your way.

You would have an Inventory list which contains all the items
and you would probably use a for loop to iterate through it,
grab the necessary items, remove them and add an axe for example.

and set that up in some kind of method. Here’s an example.
Note: This is only an example, as I don’t know how you have your inventory code set up.

void makeItem(int itemToMake, int item1, int item2, int item3) {
 //add more if you want more items to be in the recipe
if (findItem(Inventory, item1) && findItem(Inventory, item2) && findItem(Inventory, item3)) {
//delete the items from list
//add new item to the list
}
}

bool findItem(List<int> list, int item) {
for (int i=0; i < list.Count; i++) {
if (list *== item) {*

return true;
}
}
return false;
}