- Home /
Help integrating a category system
Allow me to explain my problem.
I'm trying to create a category system for food types. Basically, I have an ingredient class that is supposed to have a name and come categories. For example, you might have an Ingredient called "Bacon" that has the "Meat" category and also the "Pork" category. The user might want to select from meaty ingredients that don't contain pork, so bacon is not an option but steak is.
Right now, I have the category system set up as an enumerator, and everything works fine. The problem is that I need the player to be able to define their own categories. Here is ingredient class:
public enum categories { Meat, Pork };
public class Ingredient
{
public List<categories> itemCategory;
public string itemName;
public Ingredient(string newItemName, List<categories> newCategories = null)
{
itemName = newItemName;
itemCategory = newCategories;
}
}
And to make a new ingredient, I make a call to it like this: ingredients.Add(new Ingredient("Bacon, new List<categories>(){categories.Meat, categories.Pork}));
This creates a new ingredient called Bacon with the categories of Meat and Pork. It works just fine, but like I said I'd rather the user define the categories.
Note: This is my first time ever using enumerators, Lists, or not inheriting from MonoBehavior(It gives me grief about trying to create a new one using the 'new' keyword if I do). My point is that I'm a little bit over my head right now, and everything I do is an experiment, so if you have an idea, please be thorough.