示例#1
0
    void DetectDoubleClick()
    {
        float current_time = Time.time;

        Vector2       prev_click     = new Vector2(click_pos_x, click_pos_y);
        Vector2       curr_click     = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        SwipeLocation swipe_location = DetectSwipeLocation();

        if (current_time - last_click < 0.25f)
        {
            //print("double click detected at " + swipe_location);

            RaycastHit2D rhd = Physics2D.CircleCast(prev_click, 0.33f, curr_click);
            //print(rhd);
            //rhd.collider.GetComponent<PaddleController>().Reinforce();
            pum.ReinforcePaddle(rhd.collider.gameObject);
        }
    }
示例#2
0
    void DetectSwipe()
    {
        if (temporarily_disabled)
        {
            return;
        }
        float pos_x = Camera.main.ScreenToWorldPoint(Input.mousePosition).x;
        float pos_y = Camera.main.ScreenToWorldPoint(Input.mousePosition).y;

        if (powerup_meter == null)
        {
            powerup_meter = GameObject.FindObjectOfType <PowerupMeter>();
        }

        // Swipe location is determined by the first contact
        SwipeLocation  swipe_location  = DetectSwipeLocation();
        SwipeDirection swipe_direction = DetectSwipeDirection(pos_x, pos_y);

        print(swipe_direction + " | " + swipe_location);

        if (swipe_location == SwipeLocation.on_else)
        {
            switch (swipe_direction)
            {
            case SwipeDirection.swipe_up: pum.TripleShot(); break;

            case SwipeDirection.swipe_down: pum.ActivateSafetyNet(); break;

            case SwipeDirection.swipe_left:
            case SwipeDirection.swipe_right:
                bool inverse = PhotonNetwork.connected && PhotonNetwork.isMasterClient;

                SwipeDirection actual_swipe = swipe_direction;
                if (inverse)
                {
                    switch (swipe_direction)
                    {
                    case SwipeDirection.swipe_left:
                        actual_swipe = SwipeDirection.swipe_right;
                        break;

                    case SwipeDirection.swipe_right:
                        actual_swipe = SwipeDirection.swipe_left;
                        break;
                    }
                }

                if (powerup_meter.TestSubtract(2))
                {
                    if (!inverse && actual_swipe == SwipeDirection.swipe_right ||
                        inverse && actual_swipe == SwipeDirection.swipe_left)
                    {
                        animator.SetBool("isSliding", true);
                        animator.SetBool("isSlidingRight", true);
                    }
                    else
                    {
                        animator.SetBool("isSliding", true);
                        animator.SetBool("isSlidingRight", false);
                    }
                    pum.SuperchargeWall(actual_swipe); break;
                }

                break;
            }
        }
        //if (swipe != SwipeDirection.no_swipe) {
        //  //print("on callback");
        //  //pel.OnSwipeDetected(swipe);
        //  touch_detection.DisableForNextGesture(false);
        //}
    }