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); }
// Use this for initialization void Start() { scale = gameObject.transform.localScale; positionY = 150; isActive = true; Recipe r = objectSpawner.GetComponent <CreateRecipeScene>().GetRecipe(); List <Action> actions = r.GetActions(); GameObject a; int prevStepNumber = 0; foreach (Action action in actions) { a = Instantiate(taskUI); a.transform.SetParent(gameObject.transform); Vector3 pos = gameObject.transform.GetChild(0).GetComponent <RectTransform>().localPosition; pos.y = pos.y - positionY; a.GetComponent <RectTransform>().localPosition = pos; a.GetComponent <RectTransform>().localRotation = gameObject.transform.GetChild(0).GetComponent <RectTransform>().localRotation; a.GetComponent <RectTransform>().localScale = gameObject.transform.GetChild(0).GetComponent <RectTransform>().localScale; a.transform.GetChild(0).gameObject.SetActive(false); positionY = positionY + 50; string header = " "; if (prevStepNumber != action.GetStepNumber()) { header = action.GetStepNumber() + "- "; } if (action.GetActionType().ToString().Equals("Boil")) { Boil boil = (Boil)action; a.GetComponent <Text>().text = header + "Boil " + boil.GetInvolvedFood().GetFoodIdentifier() + " " + boil.GetRequiredTime() + " seconds"; } else if (action.GetActionType().ToString().Equals("Chop")) { Chop chop = (Chop)action; a.GetComponent <Text>().text = header + "Chop " + chop.GetInvolvedFood().GetFoodIdentifier() + " to " + chop.GetRequiredPieceCount() + " pieces"; } else if (action.GetActionType().ToString().Equals("Cook")) { Cook cook = (Cook)action; a.GetComponent <Text>().text = header + "Cook " + cook.GetInvolvedFood().GetFoodIdentifier() + " " + cook.GetRequiredTime() + " seconds in " + cook.GetRequiredHeat() + " celcius"; } else if (action.GetActionType().ToString().Equals("Fry")) { Fry fry = (Fry)action; a.GetComponent <Text>().text = header + "Fry " + fry.GetInvolvedFood().GetFoodIdentifier() + " " + fry.GetRequiredTime() + " seconds"; } else if (action.GetActionType().ToString().Equals("PutTogether")) { PutTogether puttogether = (PutTogether)action; a.GetComponent <Text>().text = "Put Together " + puttogether.GetInvolvedFood().GetFoodIdentifier() + " and " + puttogether.GetDestinationFood().GetFoodIdentifier(); } else { a.GetComponent <Text>().text = header + action.GetActionType() + " " + action.GetInvolvedFood().GetFoodIdentifier(); } prevStepNumber = action.GetStepNumber(); } }