예제 #1
0
    void UpdateHotPadLight()
    {
        Color hotPadColor = new Color(1, 0, 0);

        if (currentFoodItem != null && currentFoodItem.isBurrito)
        {
            Tortilla tortilla = currentFoodItem.tortilla;
            if (tortilla.timeCooked > tortilla.cookTime)
            {
                hotPadColor = new Color(0, 1, 0);
            }
        }
        hotPadLight.GetComponent <Renderer>().material.color = hotPadColor;
    }
예제 #2
0
    void Update()
    {
        int index = currentIngredient.index;

        if (Input.GetKeyDown("left"))
        {
            index++;
        }
        if (Input.GetKeyDown("right"))
        {
            index--;
        }
        if (index >= ingredients.Length)
        {
            index = ingredients.Length - 1;
        }
        if (index < 0)
        {
            index = 0;
        }
        if (currentIngredient.index != index)
        {
            currentIngredient = ingredients[index];
        }

        if (Input.GetKeyDown("space"))
        {
            // Tortilla stack
            if (currentIngredient.index == 0)
            {
                if (currentFoodItem != null)
                {
                    Destroy(currentFoodItem.gameObject);
                }
                currentFoodItem = Instantiate(foodItemPrefab);
                Tortilla tortilla = Instantiate(tortillaPrefab);
                tortilla.transform.parent        = currentFoodItem.transform;
                tortilla.transform.localPosition = new Vector3(0, 0, 0);

                Customer customer = Instantiate(customerPrefab);
                customer.foodItem        = currentFoodItem;
                currentFoodItem.customer = customer;
            }
            // Hot plate
            else if (currentIngredient.index == 1)
            {
                HotPlate hotPlate = currentIngredient.GetComponent <HotPlate>();
                if (currentFoodItem == null)
                {
                    currentFoodItem          = hotPlate.currentFoodItem;
                    hotPlate.currentFoodItem = null;
                }
                else if (currentFoodItem != null && currentFoodItem.isBurrito)
                {
                    FoodItem temp = hotPlate.currentFoodItem;
                    hotPlate.currentFoodItem = currentFoodItem;
                    currentFoodItem          = temp;
                }
            }
            // Cash register
            else if (currentIngredient.index == ingredients.Length - 1)
            {
                if (currentFoodItem != null)
                {
                    UpdateScore(currentFoodItem);
                    Destroy(currentFoodItem.customer.gameObject);
                    Destroy(currentFoodItem.gameObject);
                }
            }
            // Ingredients that are scooped into burrito (i.e. actual ingredients)
            else
            {
                IngredientServing serving = Instantiate(ingredientServingPrefab);
                serving.transform.position  = transform.position + servingOffset;
                serving.transform.position += new Vector3(UnityEngine.Random.value * 0.04f - 0.02f,
                                                          0.0f, UnityEngine.Random.value * 0.05f - 0.02f);

                // Inherit properties from ingredient bin
                // This will change when graphics are improved
                serving.type  = currentIngredient.type;
                serving.color = currentIngredient.color;
            }
        }

        if (Input.GetKey("q"))
        {
            Application.Quit();
        }
    }