Ejemplo n.º 1
0
    // Determine whether user clicked on right or left side of the screen
    public void sideTouched()
    {
        if (Input.GetTouch(0).phase == TouchPhase.Began && !BlockRaycast.IsPointerOverUIObject())
        {
            // Left = true right = false
            touch_position = Input.GetTouch(0).position;
            side_touched   = touch_position.x <= screen_width / 2;
            tap_valid      = Time.time > time_of_last_tap + minimum_tap_time || side_touched != pre_side_touched;
            avatar_controller_script.setTapValid(tap_valid);

            // Check if the player tapped too fast
            //tap_valid = Time.time > time_of_last_tap + minimum_tap_time;
            //avatar_controller_script.setTapValid(tap_valid);
            //touch_position = Input.GetTouch(0).position;

            // Left = turn ccw, Right = turn cw
            //if (touch_position.x <= screen_width / 2)
            if (side_touched)
            {
                avatar_controller_script.rotate_avatar(Mathf.PI / 2);
            }

            else
            {
                avatar_controller_script.rotate_avatar(-Mathf.PI / 2);
            }

            time_of_last_tap = Time.time;
            pre_side_touched = side_touched;
        }
    }
Ejemplo n.º 2
0
    //For testing in the editor
    public void editorSideTouched()
    {
        if (Input.GetMouseButtonDown(0) && !BlockRaycast.IsPointerOverUIObject())
        {
            mouse_position = Input.mousePosition;
            side_touched   = mouse_position.x <= screen_width / 2;
            tap_valid      = Time.time > time_of_last_tap + minimum_tap_time || side_touched != pre_side_touched;
            avatar_controller_script.setTapValid(tap_valid);

            //// Check if the player tapped too fast
            //tap_valid = Time.time > time_of_last_tap + minimum_tap_time;
            //avatar_controller_script.setTapValid(tap_valid);
            //mouse_position = Input.mousePosition;

            //if (mouse_position.x <= screen_width / 2)
            if (side_touched)
            {
                avatar_controller_script.rotate_avatar(Mathf.PI / 2);
            }

            else
            {
                avatar_controller_script.rotate_avatar(-Mathf.PI / 2);
            }

            time_of_last_tap = Time.time;
            pre_side_touched = side_touched;
        }
    }