// Update is called once per frame
    void Update()
    {
        gameTime += Time.deltaTime;
        UpdateChargingAnimation();

        if (selectedPiece != null)
        {
            pieceControlCheck = selectedPiece.GetComponent <PieceController>();
        }


        if (cameraRotateActive && pieceControlCheck.turnEnded)
        {
            rotationTime -= Time.deltaTime;
            cameraRotator.Rotate();
            if (rotationTime <= 0.0f)
            {
                cameraRotator.HandleOffset(rotationTime);
                rotationTime                = 1.5f;
                cameraRotateActive          = false;
                pieceControlCheck.turnEnded = false;
            }
        }

        if ((Input.GetMouseButtonDown(1) || Input.GetKeyDown(KeyCode.Escape)) && selectedPiece != null)
        {
            DeselectPiece(selectedPiece.GetComponent <BasePiece>());
        }
    }
Exemple #2
0
    void Update()
    {
        if (cameraRotator.isRotating)
        {
            return;
        }

        if (Input.GetKeyDown(KeyCode.Return))
        {
            ChooseOption();
            return;
        }

        float rotateDirection = -Input.GetAxis("Horizontal");

        if (rotateDirection != 0f)
        {
            if (rotateDirection > 0f)           // Anticlockwise rotation
            {
                rotateDirection = 1f;
                menuOption     += 3;
                menuOption     %= 4;
            }
            else                                // Clockwise rotation
            {
                rotateDirection = -1f;
                menuOption++;
                menuOption %= 4;
            }

            cameraRotator.isRotating = true;
            IEnumerator coroutine = cameraRotator.Rotate(rotateDirection);
            StartCoroutine(coroutine);
        }
    }
Exemple #3
0
    void Update()
    {
        /*
         * Vector3 accel = Input.acceleration - startPosition;
         *
         * if(accel.magnitude > sensityvity)
         * {
         *  Vector3 direction = accel.normalized;
         *  //direction = direction.normalized;
         *
         *  camRot.xRotation -= direction.z * rotSpeed * Time.deltaTime;
         *  camRot.yRotation += direction.x * rotSpeed * Time.deltaTime;
         * }
         */

        // Quaternion angle = Quaternion.Euler(Input.acceleration);
        Vector3 input = Input.acceleration;

        //textField.text = input.ToString();

        input -= startPosition;
        // textField.text += ", to " + input + ", angle " + Vector3.Angle(input, startPosition);



        if (input.y > sensityvity)
        {
            camRot.Rotate(rotSpeed, 0);
            //camRot.xRotation += rotSpeed * Time.deltaTime;
        }
        else if (input.y < -sensityvity)
        {
            camRot.Rotate(-rotSpeed, 0);
        }

        if (input.x > sensityvity)
        {
            camRot.Rotate(0, -rotSpeed);
        }
        else if (input.x < -sensityvity)
        {
            camRot.Rotate(0, rotSpeed);
        }
    }