Exemplo n.º 1
0
 private void OnTriggerExit(Collider other)
 {
     if (other.gameObject.tag == "Player")
     {
         gameManager.EndGame();
     }
 }
Exemplo n.º 2
0
    void Update()
    {
        //Mouse rotation
        lookInput.x = Input.mousePosition.x;
        lookInput.y = Input.mousePosition.y;

        mouseDistance.x = (lookInput.x - screenCenter.x) / screenCenter.y;
        mouseDistance.y = (lookInput.y - screenCenter.y) / screenCenter.y;

        mouseDistance = Vector2.ClampMagnitude(mouseDistance, 1f);

        rollInput = Mathf.Lerp(rollInput, Input.GetAxisRaw("Roll"), rollAcceleration * Time.deltaTime);

        transform.Rotate(-mouseDistance.y * lookRotateSpeed * Time.deltaTime, mouseDistance.x * lookRotateSpeed * Time.deltaTime, rollInput * rollSpeed * Time.deltaTime, Space.Self);

        //Movement with acceleration for good feeling
        activeForwardSpeed = Mathf.Lerp(activeForwardSpeed, Input.GetAxisRaw("Vertical") * forwardSpeed, forwardAcceleration * Time.deltaTime);
        activeStrafeSpeed  = Mathf.Lerp(activeStrafeSpeed, Input.GetAxisRaw("Horizontal") * strafeSpeed, strafeAcceleration * Time.deltaTime);
        activeHoverSpeed   = Mathf.Lerp(activeHoverSpeed, Input.GetAxisRaw("Hover") * hoverSpeed, hoverAcceleration * Time.deltaTime);

        transform.position += transform.forward * activeForwardSpeed * Time.deltaTime;
        transform.position += transform.right * activeStrafeSpeed * Time.deltaTime;
        transform.position += transform.up * activeHoverSpeed * Time.deltaTime;

        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            FindObjectOfType <AudioManager>().VolumnUp();
        }

        if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            FindObjectOfType <AudioManager>().VolumnDown();
        }

        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            FindObjectOfType <AudioManager>().PlayPrevious();
        }

        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            FindObjectOfType <AudioManager>().PlayNext();
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            gameManager.EndGame();
        }

        if (isBoost)
        {
            if (boostTimer > 0)
            {
                boostTimer -= Time.deltaTime;
                boosterRedLeft.SetActive(false);
                boosterRedRight.SetActive(false);
                boosterBlueLeft.SetActive(true);
                boosterBlueRight.SetActive(true);
            }
            else
            {
                isBoost      = false;
                forwardSpeed = initialSpeed;
                boosterRedLeft.SetActive(true);
                boosterRedRight.SetActive(true);
                boosterBlueLeft.SetActive(false);
                boosterBlueRight.SetActive(false);
            }
        }

        if (isSpin)
        {
            if (spinTimer > 0)
            {
                spinTimer -= Time.deltaTime;
                this.transform.Rotate(180 * Time.deltaTime, 0, 0, Space.Self);
            }
            else
            {
                isSpin = false;
            }
        }
    }