void Start() { Recipe r = Recipe.LoadRecipe(recipeNameToLoad); foreach (Action a in r.GetActions()) { if (a is Chop) { Chop c = (Chop)a; print(c); } } foreach (Food f in r.GetInitialFoods()) { print(f.GetFoodIdentifier()); } }
public void ParseRecipe() { var culture = new CultureInfo("de-DE"); recipe = new RecipeModule.Recipe("DEMO_RECIPE_" + DateTime.Now.ToString(culture).Replace(":", "_").Replace(" ", "_")); // Reorder steps List <Step> orderedSteps = new List <Step>(steps.Count); foreach (Step s in steps) { orderedSteps.Insert(s.GetStepNumber() - 1, s); } foreach (Step s in orderedSteps) { if (s.GetInput() is FoodState) { FoodState inputItem = (FoodState)(s.GetInput()); // This is initial food if (!inputItem.GetComponent <Text>().text.Contains("Output") && !inputItem.GetComponent <Text>().text.Contains("Group")) { string foodIdentifier = inputItem.GetComponent <Text>().text; PseudoAction action = s.GetPseudoAction(); RecipeModule.Food f = null; switch (action.GetActionType()) { case RecipeModule.Action.ActionType.Boil: f = recipe.DescribeNewBoilAction(s.GetStepNumber(), foodIdentifier, action.GetParameterValues()[0]); break; case RecipeModule.Action.ActionType.Break: f = recipe.DescribeNewBreakAction(s.GetStepNumber(), foodIdentifier); break; case RecipeModule.Action.ActionType.Chop: f = recipe.DescribeNewChopAction(s.GetStepNumber(), foodIdentifier, action.GetParameterValues()[0]); break; case RecipeModule.Action.ActionType.Cook: f = recipe.DescribeNewCookAction(s.GetStepNumber(), foodIdentifier, action.GetParameterValues()[0], action.GetParameterValues()[1]); break; case RecipeModule.Action.ActionType.Fry: f = recipe.DescribeNewFryAction(s.GetStepNumber(), foodIdentifier, action.GetParameterValues()[0]); break; case RecipeModule.Action.ActionType.Peel: f = recipe.DescribeNewPeelAction(s.GetStepNumber(), foodIdentifier); break; case RecipeModule.Action.ActionType.Smash: f = recipe.DescribeNewSmashAction(s.GetStepNumber(), foodIdentifier); break; case RecipeModule.Action.ActionType.Squeeze: f = recipe.DescribeNewSqueezeAction(s.GetStepNumber(), foodIdentifier); break; default: f = null; break; } ContinueOnSteps(f, s); } } } print("Parsing Completed"); recipe.ReorderActions(); print("Reordering Completed"); foreach (RecipeModule.Action a in recipe.GetActions()) { print(a.GetStepNumber() + ": " + a.GetActionType()); print("In: " + a.GetInvolvedFood().GetFoodIdentifier()); print("Out: " + a.GetResultedFood().GetFoodIdentifier()); print("\n"); } print("Initial Foods"); foreach (RecipeModule.Food f in recipe.GetInitialFoods()) { print(f.GetFoodIdentifier()); } RecipeModule.Recipe.SaveRecipe(recipe); }