Exemple #1
0
 void UpdateHintBool()
 {
     is_stick_hold = stick_ctrl.IsHoldStick();
     is_rolling    = stick_ctrl.IsHoldStick() &&
                     (Mathf.Abs(stick_ctrl.NowRotate().z) > 10f);
     is_pitching = stick_ctrl.IsHoldStick() &&
                   (Mathf.Abs(stick_ctrl.NowRotate().x) > 10f);
     is_yawing = user_input.IsGripPress(UserInput.HAND_ID.Left) ||
                 user_input.IsGripPress(UserInput.HAND_ID.Right);
     is_accelerating = user_input.IsTrackpadPress(UserInput.HAND_ID.Left) &&
                       (plane_ctrl.SpeedChange() > 15f);
     is_decelerating = user_input.IsTrackpadPress(UserInput.HAND_ID.Left) &&
                       (plane_ctrl.SpeedChange() < -15f);
     is_fire = user_input.IsTriggerPress(UserInput.HAND_ID.Left) ||
               user_input.IsTriggerPress(UserInput.HAND_ID.Right);
     is_pause_press = GameController.GetGameSTAT() == GameController.GAME_STAT.Pause;
 }
Exemple #2
0
    /* Control plane movement. */
    private void LateUpdate()
    {
        // Only work in the game.
        if (GameController.GetGameSTAT() != GameController.GAME_STAT.Game &&
            GameController.GetGameSTAT() != GameController.GAME_STAT.Tutorial)
        {
            return;
        }

        /* Rotation */
        // How we are going to rotate the plane.
        Vector3 rotate_angle = GeneralizedEularAngle.Generalized(stick_ctrl.NowRotate());
        // The plane rotation now.
        Vector3 plane_rotate = GeneralizedEularAngle.Generalized(transform.rotation);

        // x axis
        if (rotate_angle.x > 0 && plane_rotate.x > 80f)
        {
            rotate_angle.x = 0;
        }
        // y axis
        float rotate_y = plane_rotate.z / 2f;

        if (plane_rotate.z * rotate_angle.z < 0)
        {
            rotate_y /= 2f;
        }
        if (user_input.IsGripPress(UserInput.HAND_ID.Left))
        {
            rotate_y += 2;
        }
        if (user_input.IsGripPress(UserInput.HAND_ID.Right))
        {
            rotate_y -= 2;
        }
        // Apply rotation.
        transform.Rotate(new Vector3(rotate_angle.x, rotate_angle.y - rotate_y, rotate_angle.z) * Time.deltaTime);

        // Move forward.
        transform.Translate(transform.forward * speed * Time.deltaTime, Space.World);
        // Falling.
        if (speed < 30f)
        {
            transform.Translate(Vector3.down * (30f - speed) * 2f * Time.deltaTime, Space.World);
            if (plane_rotate.x < 80f)
            {
                transform.Rotate(new Vector3((30f - speed), 0, 0) * Time.deltaTime);
            }
        }
    }
Exemple #3
0
 // Update is called once per frame
 void Update()
 {
     /* Move the stick. */
     Vector3[] vertices = new Vector3[mesh.vertexCount];
     System.Array.Copy(origin_vertices, vertices, mesh.vertexCount);
     for (int i = StickController.base_id; i < StickController.limit_id; i++)
     {
         // Move to origin.
         vertices[i] -= offset;
         // Rotate.
         vertices[i] = stick_ctrl.NowRotate() * vertices[i];
         // Move back.
         vertices[i] += offset;
     }
     mesh.vertices = vertices;
 }