public void ContinueOnSteps(RecipeModule.Food relatedFood, Step relatedStep) { Step nextStep = GetNextRelatedStep(relatedStep); if (nextStep != null) { PseudoAction action = nextStep.GetPseudoAction(); RecipeModule.Food f = null; switch (action.GetActionType()) { case RecipeModule.Action.ActionType.Boil: f = recipe.DescribeNewBoilAction(nextStep.GetStepNumber(), relatedFood, action.GetParameterValues()[0]); break; case RecipeModule.Action.ActionType.Break: f = recipe.DescribeNewBreakAction(nextStep.GetStepNumber(), relatedFood); break; case RecipeModule.Action.ActionType.Chop: f = recipe.DescribeNewChopAction(nextStep.GetStepNumber(), relatedFood, action.GetParameterValues()[0]); break; case RecipeModule.Action.ActionType.Cook: f = recipe.DescribeNewCookAction(nextStep.GetStepNumber(), relatedFood, action.GetParameterValues()[0], action.GetParameterValues()[1]); break; case RecipeModule.Action.ActionType.Fry: f = recipe.DescribeNewFryAction(nextStep.GetStepNumber(), relatedFood, action.GetParameterValues()[0]); break; case RecipeModule.Action.ActionType.Peel: f = recipe.DescribeNewPeelAction(nextStep.GetStepNumber(), relatedFood); break; case RecipeModule.Action.ActionType.Smash: f = recipe.DescribeNewSmashAction(nextStep.GetStepNumber(), relatedFood); break; case RecipeModule.Action.ActionType.Squeeze: f = recipe.DescribeNewSqueezeAction(nextStep.GetStepNumber(), relatedFood); break; case RecipeModule.Action.ActionType.Empty: // Do nothing, use same food object f = relatedFood; break; default: f = null; break; } ContinueOnSteps(f, nextStep); } }
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); }