Beispiel #1
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Escape) && menu == false && INSTRUCTION.activeSelf == false)
     {
         menu = true;
         menuInt.SetActive(true);
         Menu_Esc.enabled = true;
     }
     else if (Input.GetKeyDown(KeyCode.Escape) && menu == true && INSTRUCTION.activeSelf == false)
     {
         menu = false;
         menuInt.SetActive(false);
         Menu_Esc.enabled = false;
     }
     //Menu ESC ATIVO------------------------------------------------------------------------------------
     if (Menu_Esc.enabled == false)
     {
         Interface.enabled = true;
         Robo_Ref.SetActive(true);
         Robo_Corpo.SetActive(true);
     }
     else
     {
         Interface.enabled = false;
         Robo_Ref.SetActive(false);
         Robo_Corpo.SetActive(false);
     }
     //FIM Menu ESC ATIVO--------------------------------------------------------------------------------
     if (restInt.activeSelf == true)
     {
         menuInt.SetActive(false);
         Robo_Ref.SetActive(false);
         Robo_Corpo.SetActive(false);
         Interface.enabled = false;
     }
 }    //UPDATE
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        //TEMPO DE JOGO-------------------------------------------------------------------------------------
        if (int_timer_sec <= 00f && int_timer_min >= 0f)
        {
            int_timer_min -= 1f; int_timer_sec = 59f;
        }
        if (int_timer_sec < 10f && int_timer_min >= 0f)
        {
            int_timer.text = "0" + (int)int_timer_min + ":" + "0" + (int)int_timer_sec;
        }
        else if (int_timer_sec >= 10f && int_timer_min >= 0f)
        {
            int_timer.text = "0" + (int)int_timer_min + ":" + (int)int_timer_sec;
        }

        int_timer_sec -= Time.deltaTime * 2;      // DIMINUIÇAO DO TEMPO.

        // TEMPO ESGOTADO-------------------------------------------------------------

        /*	if (int_timer_min <= 0f && int_timer_sec <= 0f) {
         *              txt_noTime.enabled = true;
         *              txt_noTime.gameObject.SetActive(true);
         *              Menu_Morte.SetActive (true);
         *              Robo_Corpo.SetActive (false);
         *              Robo_Ref.SetActive (false);
         *              Interface.enabled = false;
         *      }//FIM TEMPO ESGOTADO-------------------------------------------------------------
         */
        //SEM ENERGIA------------------------------------------------------------------------

        /*if (Fuel.value <= 0f) {
         *      txt_energy.enabled = true;
         *      txt_energy.gameObject.SetActive(true);
         *      Menu_Morte.SetActive (true);
         *      Robo_Corpo.SetActive (false);
         *      Robo_Ref.SetActive (false);
         *      Interface.enabled = false;
         * }*/
        //FIM SEM ENERGIA--------------------------------------------------------------------

        //FIM TEMPO DE JOGO---------------------------------------------------------------------------------
        //MOVEMENT------------------------------------------------------------------------------------------
        horizontalSpeed = Input.GetAxis("Horizontal");
        verticalSpeed   = Input.GetAxis("Vertical");
        speed           = new Vector2(horizontalSpeed, verticalSpeed).sqrMagnitude;

        if (rb.velocity.z >= 10f)
        {
            rb.velocity = new Vector3(rb.velocity.x, rb.velocity.y, 10f);
        }
        if (rb.velocity.z <= -10f)
        {
            rb.velocity = new Vector3(rb.velocity.x, rb.velocity.y, -10f);
        }
        if (rb.velocity.x >= 10f)
        {
            rb.velocity = new Vector3(10f, rb.velocity.y, rb.velocity.z);
        }
        if (rb.velocity.x <= -10f)
        {
            rb.velocity = new Vector3(-10f, rb.velocity.y, rb.velocity.z);
        }

        if (verticalSpeed > 0.25f && rb.velocity.z <= 10f)
        {
            rb.AddForce(Person.transform.forward * (speed / Time.deltaTime), ForceMode.Acceleration);
        }
        if (verticalSpeed < -0.25f && rb.velocity.z >= -10f)
        {
            rb.AddForce(-Person.transform.forward * (speed / Time.deltaTime), ForceMode.Acceleration);
        }

        /*if (Input.GetKey (KeyCode.UpArrow) || Input.GetKey (KeyCode.W) && !Dash && !pular1) {
         *      rb.AddForce(Person.transform.forward * ( speed/Time.deltaTime),ForceMode.Acceleration);
         *      Fuel.value -= Time.deltaTime * 10F;
         *
         *      if(Robot.transform.eulerAngles.z <= 360f && Robot.transform.eulerAngles.z >= 345f && !Dash && !pular1){
         *              Robot.transform.eulerAngles -= new Vector3(0f,0f,1f);
         *      }
         * }
         * if (Input.GetKey (KeyCode.DownArrow) || Input.GetKey (KeyCode.S) && !Dash && !pular1) {
         *      rb.AddForce (-Person.transform.forward * (speed / Time.deltaTime),ForceMode.Acceleration);
         *      Fuel.value -= Time.deltaTime * 10F;
         *
         *      if(Robot.transform.eulerAngles.z <= 358f && Robot.transform.eulerAngles.z >= 320f && !Dash && !pular1){
         *              Robot.transform.eulerAngles += new Vector3(0f,0f,1f);
         *      }
         * }*/
        //FIM MOVEMENT--------------------------------------------------------------------------------------
        //PULO----------------------------------------------------------------------------------------------
        if (Input.GetKeyDown(KeyCode.Space) && pular1 == false && puloCont == 0)
        {
            pular1   = true;
            puloCont = 1;
        }

        if (pular1 == true && puloCont == 1)
        {
            rb.AddForce(Person.transform.up * puloSpeed, ForceMode.Impulse);
            pular1 = false;
        }
        //FIM PULO-------------------------------------------------------------------------------------------
        //GRAVITY--------------------------------
        rb.AddForce(Person.transform.up * -50f, ForceMode.Force);
        //END GRAVITY----------------------------
        //DASH------------------------------------------------------------------------------------------
        if (Input.GetKeyDown(KeyCode.LeftShift) && pular1 == false && puloCont == 1)
        {
            pular2   = true;
            puloCont = 2;
            Dash     = true;
        }

        if (pular2 == true && puloCont == 2)
        {
            Fuel.value    -= 12f;         // CUSTO DASH NA ENERGIA--------------------------------------------------
            timer          = 0.35f;
            rb.constraints = RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezePositionY;
            rb.AddForce(Person.transform.forward * 1.5f, ForceMode.Impulse);
            pular2 = false;
        }
        if (timer >= 0f)
        {
            timer = timer - Time.deltaTime;
        }
        if (timer <= 0.00000f)
        {
            rb.constraints = RigidbodyConstraints.None;
            Dash           = false;
        }
        Person.transform.eulerAngles = Pivot.transform.eulerAngles;
        //FIM DASH------------------------------------------------------------------------------------------

        //CODICAO DE MORTE----------------------------------------------------------------------------------
        if (Person.position.y < -45.5f || Robot.position.y < -45.5f)
        {
            sfx.Death_Sound_Effect();
            txt_death.enabled = true;
            txt_death.gameObject.SetActive(true);
            Menu_Morte.SetActive(true);
            Robo_Corpo.SetActive(false);
            Robo_Ref.SetActive(false);
        }
        //FIM CODICAO DE MORTE------------------------------------------------------------------------------
    }    //Fim Update