I watched the tutorials regarding Lists and Dictionaries but it was a bit confusing to me as I have never worked with classes before. I am sure the Unity Community is willing to help me out here.
I have set up two scripts, one for constructors and some functions, one for adding items to the list. My idea here is the script that adds to the list is like sending an ingredient to the pot. And the script that puts the items in the list through a function is like **cooking the ingredients inside the pot. **
Like:
public var ingredients = new List.<ingredientsToCook>();
function OnTriggerEnter (Col : Collider) {
if(Col. CompareTag("Pot"))
{
ingredients.Add("Potatoe", 60)
}
}
This will be in a public class called something like Ingredients.
And inside the pot:
public class items {
var itemName : String;
var cookTime : int;
public function items(newName : String, newTime : int){
itemName = newName;
cookTime = newTime;
}
for(var ingredient in ingredients)
{
//cooks the ingredients
}
}
Does this concept work? But what if each ingredient has a different time to cook? how do I access each item’s different var timeToCook : float = x
inside a list and cooks the food accordingly? I will look at some youtube videos in the meantime.
thanks so much.