示例#1
0
        public Food DescribeNewBoilAction(int stepNumber, Food foodToBeBoiled, float requiredTime)
        {
            Boil action = new Boil(stepNumber, foodToBeBoiled, requiredTime);

            _actions.Add(action);

            totalStepCount++;

            return(action.GetResultedFood());
        }
示例#2
0
        public Food DescribeNewBoilAction(int stepNumber, string identifier, float requiredTime)
        {
            Food f = new Food(identifier);

            _initialFoods.Add(f);

            Boil action = new Boil(stepNumber, f, requiredTime);

            _actions.Add(action);

            totalStepCount++;

            return(action.GetResultedFood());
        }
示例#3
0
        public Food DescribeNewBoilAction(int stepNumber, GameObject foodObject, float requiredTime)
        {
            Food f = new Food(foodObject.GetComponent <FoodStatus>().foodIdentifier);

            _initialFoods.Add(f);

            Boil action = new Boil(stepNumber, f, requiredTime);

            _actions.Add(action);

            totalStepCount++;

            return(action.GetResultedFood());
        }
示例#4
0
        // 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();
            }
        }
示例#5
0
        void UseActionList(List <Action> actionList)
        {
            Food b;

            foreach (Action a in actionList)
            {
                if (a.GetInvolvedFood().GetPrev() == null)
                {
                    b = a.GetInvolvedFood();
                }
                else
                {
                    b = a.GetInvolvedFood();
                    while (b.GetPrev() != null)
                    {
                        b = b.GetPrev();
                    }
                }
                GameObject prefab = GetComponent <FindPrefab>().GetPrefab(b.GetFoodIdentifier());
                if (a.GetActionType().ToString().Equals("Chop"))
                {
                    Chop chop = (Chop)a;
                    if (prefab.GetComponent <CanBePeeled>())
                    {
                        /* if (prefab.transform.GetChild(0).GetComponent<CanBeChopped>()==null)
                         * {
                         *  prefab.transform.GetChild(0).gameObject.AddComponent<CanBeChopped>();
                         * }*/
                        prefab.transform.GetChild(0).GetComponent <CanBeChopped>().maximumChopCount = chop.GetRequiredPieceCount();
                    }
                    else
                    {
                        /*if (prefab.GetComponent<CanBeChopped>()==null)
                         * {
                         *  prefab.AddComponent<CanBeChopped>();
                         * }*/
                        prefab.GetComponent <CanBeChopped>().maximumChopCount = chop.GetRequiredPieceCount();
                    }
                }

                /*else if (a.GetActionType().ToString().Equals("Peel"))
                 * {
                 *  Peel peel = (Peel)a;
                 *  if (prefab.GetComponent<CanBePeeled>() == null)
                 *  {
                 *      prefab.AddComponent<CanBePeeled>();
                 *  }
                 * }*/
                else if (a.GetActionType().ToString().Equals("Cook"))
                {
                    Cook cook = (Cook)a;
                    if (prefab.GetComponent <CanBePeeled>())
                    {
                        /*if (prefab.transform.GetChild(0).GetComponent<CanBeCooked>() == null)
                         * {
                         *  prefab.transform.GetChild(0).gameObject.AddComponent<CanBeCooked>();
                         * }*/
                        prefab.transform.GetChild(0).GetComponent <CanBeCooked>().requiredCookHeat = (int)cook.GetRequiredHeat();
                        prefab.transform.GetChild(0).GetComponent <CanBeCooked>().requiredCookTime = (int)cook.GetRequiredTime();
                    }
                    else
                    {
                        /*if (prefab.GetComponent<CanBeCooked>() == null)
                         * {
                         *  prefab.AddComponent<CanBeCooked>();
                         * }*/
                        prefab.GetComponent <CanBeCooked>().requiredCookHeat = (int)cook.GetRequiredHeat();
                        prefab.GetComponent <CanBeCooked>().requiredCookTime = (int)cook.GetRequiredTime();
                    }
                }
                else if (a.GetActionType().ToString().Equals("Fry"))
                {
                    Fry fry = (Fry)a;
                    if (prefab.GetComponent <CanBePeeled>())
                    {
                        /*if (prefab.transform.GetChild(0).GetComponent<CanBeFried>() == null)
                         * {
                         *  prefab.transform.GetChild(0).gameObject.AddComponent<CanBeFried>();
                         * }*/
                        prefab.transform.GetChild(0).GetComponent <CanBeFried>().fryingTimeInSeconds = fry.GetRequiredTime();
                    }
                    else
                    {
                        /*if (prefab.GetComponent<CanBeFried>() == null)
                         * {
                         *  prefab.AddComponent<CanBeFried>();
                         * }*/
                        prefab.GetComponent <CanBeFried>().fryingTimeInSeconds = fry.GetRequiredTime();
                    }
                }

                /*else if (a.GetActionType().ToString().Equals("Squeeze"))
                 * {
                 *  if (prefab.GetComponent<CanBeSqueezed>() == null)
                 *  {
                 *      prefab.AddComponent<CanBeSqueezed>();
                 *  }
                 * }
                 * else if (a.GetActionType().ToString().Equals("Smash"))
                 * {
                 *  continue;
                 * }
                 * else if (a.GetActionType().ToString().Equals("Break"))
                 * {
                 * //control the if break script is added to prefab
                 * }*/
                else if (a.GetActionType().ToString().Equals("Boil"))
                {
                    Boil boil = (Boil)a;

                    /*if (prefab.GetComponent<CanBeBoiled>() == null)
                     * {
                     *  prefab.AddComponent<CanBeBoiled>();
                     * }*/
                    prefab.GetComponent <CanBeBoiled>().requiredBoilingTime = (int)boil.GetRequiredTime();
                }
            }
            List <GameObject> f = new List <GameObject>();

            foreach (Action a in actionList)
            {
                if (a.GetInvolvedFood().GetPrev() == null)
                {
                    if (f.Count == 0)
                    {
                        f.Add(GetComponent <FindPrefab>().GetPrefab(a.GetInvolvedFood().GetFoodIdentifier()));
                    }
                    else if (f.Contains(GetComponent <FindPrefab>().GetPrefab(a.GetInvolvedFood().GetFoodIdentifier())))
                    {
                        f.Add(GetComponent <FindPrefab>().GetPrefab(a.GetInvolvedFood().GetFoodIdentifier()));
                    }
                    else
                    {
                        CreateObjectInScene(f[0], f.Count);
                        f.Clear();
                        f.Add(GetComponent <FindPrefab>().GetPrefab(a.GetInvolvedFood().GetFoodIdentifier()));
                    }
                }
            }
            if (f != null)
            {
                CreateObjectInScene(f[0], f.Count);
                f.Clear();
            }
        }