Exemple #1
0
    // Update is called once per frame.
    // Handles controls.
    void Update()
    {
        // if message is not shown, execute game...
        if (!message.IsShown())
        {
            if (currentReaction)
            {
                Destroy(currentReaction);
            }

            if (exit)
            {
                SceneManager.LoadScene("Menu", LoadSceneMode.Single);
            }

            if (showEducation1)
            {
                ShowEducation1();
            }
            else if (showEducation2)
            {
                ShowEducation2();
            }
            else if (showEducation3)
            {
                ShowEducation3();
            }


            // Update Steps
            if (timeToStep <= 0f)
            {
                timeToStep = stepRate;
                Step();
            }
            timeToStep -= Time.deltaTime;

            // Update Fires
            if (timeToFire <= 0f)
            {
                timeToFire = fireRate;
                randomizePosition(currentFire);
            }
            timeToFire -= Time.deltaTime;

            // Check input keys, can't move in opposite direction.
            if (Input.GetKeyDown(KeyCode.RightArrow) && transform.eulerAngles.z != 90)
            {
                newDirection = new Vector3(0, 0, 270);
                forceStep();
            }
            else if (Input.GetKeyDown(KeyCode.UpArrow) && transform.eulerAngles.z != 180)
            {
                newDirection = new Vector3(0, 0, 0);
                forceStep();
            }
            else if (Input.GetKeyDown(KeyCode.DownArrow) && transform.eulerAngles.z != 0)
            {
                newDirection = new Vector3(0, 0, 180);
                forceStep();
            }
            else if (Input.GetKeyDown(KeyCode.LeftArrow) && transform.eulerAngles.z != 270)
            {
                newDirection = new Vector3(0, 0, 90);
                forceStep();
            }

            if (Input.GetKeyDown(KeyCode.Escape))
            {
                exit = true;
            }
            else if (Input.GetKeyDown(KeyCode.P))
            {
                message.ShowMessage("Pausa\n");
            }


            if (lost || score < MINIMUM_SCORE)
            {
                lost = false;
                ShowOutroMessage();
                exit = true;
            }
        }
    }