Beispiel #1
0
    public void PlayButtonPressed()
    {
        if (GameData.currentGame.newGame)
        {
            if (inputField.GetComponent <InputField>().text != "")
            {
                audioScript.MakeClickSound(); //Genera sonido de click al clicar boton play cuando este permite crear partida

                Debug.Log(inputField.GetComponent <InputField>().text);
                GameData.currentGame.playerName = inputField.GetComponent <InputField>().text;
                loader.startLoad(1);
            }
            else
            {
                audioScript.MakeErrorSound();
            }                                     //Genera sonido de error al clicar boton play no funcional
            Debug.Log(inputField.GetComponent <InputField>().text);
        }
        else
        {
            loader.startLoad(1);

            audioScript.MakeClickSound(); //Genera sonido de click al clicar boton play
        }
    }
    void Update()
    {
        moneyText.text = "" + GameData.currentGame.coins;

        switch (sceneState)
        {
        case "Newspaper":
            newspaper.SetActive(true);

            break;

        case "Initial":
            if (Camera.main.transform.position.y > 0f)
            {
                Camera.main.transform.position -= new Vector3(0f, 1f, 0f) * Time.deltaTime;
                sueloFondo.transform.position  -= new Vector3(0f, 0.3f, 0f) * Time.deltaTime;
            }
            else
            {
                Camera.main.transform.position = new Vector3(0f, 0f, Camera.main.transform.position.z);

                sceneInterface.SetActiveGridButtons(true); //Habilito botones de gestión de la cuadricula

                SetActiveGrid(false);                      //Desactivamos las celdas cuando no tienen funcionalidad

                setSceneState("InGame");
            }
            break;


        case "InGame":

            if (visibleGrid)
            {
                showGrid(false); SetActiveGrid(false);
            }
            buildingBar.SetActive(false);

            break;


        case "Placing":

            if (!visibleGrid)
            {
                SetActiveGrid(true); showGrid(true);
            }
            buildingBar.SetActive(false);


            if (cellToOcupate && objectToMove)
            {
                adjustToTemporalCell();     //Ajusta objeto a la Z posicion de celda actual y le modifica el color.

                if (Input.GetMouseButtonUp(0))
                {
                    changeObjectCell();
                }
            }

            CheckObjectOutOfGrid();     //Función getiona las acciones en objetos arrastrados fuera de la cuadricula. (Papelera, reubicacion, destruccion)


            if (objectToMove)
            {
                adjustToTemporalScale();     //Ajusta el tamaño de los objetos a su posicion en el escenario.

                if (!btRemove.activeSelf)    //Condicion que habilita e inhabilita boton papelera de objetos.
                {
                    btRemove.SetActive(true);
                    btRemove.GetComponent <RemoveGridObject>().removable = false;
                }
            }
            else
            {
                btRemove.SetActive(false);
            }

            break;


        case "Building":

            if (visibleGrid)
            {
                showGrid(false);
            }
            buildingBar.SetActive(true);

            //Salida del modo 'Building' al tocar pantalla fuera del area de la barra de construccion.
            if (Input.GetMouseButtonDown(0) && (Input.mousePosition.y > Screen.height / 2f && Input.mousePosition.x < Screen.width * 9 / 10f))
            {
                setSceneState("InGame");
            }
            break;



        case "DecisionBox":

            if (!shadowSelection.activeSelf)
            {
                audioScript.MakeClickSound();     //Genera sonido al salir cuadro de acceder minijuego

                originalOrderSltdObj = decisionObject.GetComponent <SpriteRenderer>().sortingOrder;
                decisionObject.GetComponent <SpriteRenderer>().sortingOrder = shadowSelection.GetComponent <SpriteRenderer>().sortingOrder + 1;
                shadowSelection.transform.position = decisionObject.transform.position;

                if (decisionObject.tag == "Station")
                {
                    shadowSelection.transform.localScale = new Vector3(3.88f, 3.88f, 3.88f);
                }
                else
                {
                    shadowSelection.transform.localScale = new Vector3(3.35f, 3.35f, 3.35f);
                }

                shadowSelection.SetActive(true);

                //Inhabilito botones de gestión de la cuadricula
                sceneInterface.SetActiveGridButtons(false);
                btRemove.SetActive(false);
            }

            break;

        case "DecisionBoxEnd":

            decisionObject.GetComponent <SpriteRenderer>().sortingOrder = originalOrderSltdObj;
            shadowSelection.SetActive(false);


            sceneInterface.SetActiveGridButtons(true);     //Habilito botones de gestión de la cuadricula.

            setSceneState("InGame");

            break;
        }
    }