Esempio n. 1
0
    /// <summary>
    /// Controlar movimiento del chef en un solo lado de la cocina. Mientras camina el chef, activar la animación de caminar.
    /// Si el jugador presiona espacio, el refri abre. Jugar minijuego. Poner ingrediente en emplatado.
    /// Controls same-side movement of chef. When moving, activate walking animation.
    /// If player presses space, open refrigerador. Play minigames. Put ingredient at plating station.
    /// </summary>
    public void Move()
    {
        //  Movimiento horizontal.
        //  Horizontal movement.
        float horizontal = Input.GetAxis("Horizontal");

        if (Mathf.Abs(horizontal) > 0)
        {
            this.transform.Translate(horizontal * Time.deltaTime * speed, 0, 0);
            anim.SetBool("walking", true);
        }
        else
        {
            anim.SetBool("walking", false);
        }

        // Abrir el refri.
        // Open fridge.
        if (Input.GetKeyDown("down"))
        {
            if (ingredientsManager.CanPlay())
            {
                Debug.Log("Ya tienes un ingrediente.");
                return;
            }
            else
            {
                master.OpenRefri();
            }
        }

        // Empezar minijuego si el chef lleva un ingrediente crudo. Dejar un ingrediente preparado en la estación
        // de emplatado si el chef está en esa estación.
        // Enter minigame if chef is holding a raw ingredient. Leave a prepared ingredient at plating station if the
        // chef is at that station.
        if (Input.GetKeyDown("space"))
        {
            if (ingredientsManager.CanPlay())
            {
                // si ingredient está crudo, entra minijuego
                // if ingredient is raw, enter minigame
                if (currentIngredient.state == Ingredient.IngredientState.RAW)
                {
                    master.PlayMinigame();
                }

                // si ingredient está preparado y el chef está en la estación de emplatado, poner ingrediente.
                // if ingredient is prepared and the chef is at the plating state, put down ingredient at the station.
                else if (currentIngredient.state == Ingredient.IngredientState.COOKED)
                {
                    if (enPlatos)
                    {
                        //llenar plaza en emplatado con el ingrediente preparado
                        //fill spot at plating station with prepared ingredient
                        UI.FillSlot(currentIngredient);
                        master.AddIngredient(currentIngredient);

                        //corregir color, correct color
                        currentIngredient.state = Ingredient.IngredientState.RAW;

                        //vaciar ingrediente actual, make current ingredient null
                        currentIngredient = null;
                        ingredientsManager.ResetIngredient();
                    }
                }
            }
            else
            {
                Debug.Log("No tienes un ingrediente.");
            }
        }

        // Jugar minijuego Emplatado.
        // Play plating minigame.
        if (Input.GetKeyDown("q"))
        {
            if (enPlatos)
            {
                mealToDeliver = master.CheckMeal(mealsManager.mealsInLevel);

                if (mealToDeliver != null)
                {
                    master.PlateMinigame();
                }
                else
                {
                    Debug.Log("Eso no es un platillo.");
                }
            }
        }

        // Throw away ingredient & Clean Plate.
        if (Input.GetKeyDown("x"))
        {
            //si está en frente de emplatado, borrar ingredientes
            //if in front of plating station, erase ingredients
            if (enPlatos && currentIngredient == null)
            {
                UI.EmptySlots();
                master.currentIngredientsOnPlate.Clear();
                Debug.Log("Ingredientes de la estación emplatado tirados.");
            }

            //tirar ingrediente
            //throw away ingrediente
            else if (currentIngredient != null)
            {
                currentIngredient = null;
                ingredientsManager.ResetIngredient();
                source.PlayOneShot(basurero);
                Debug.Log("Ingrediente tirado.");
            }

            //EMPTY PLATILLO
        }
    }