コード例 #1
0
    public void SuperchargeWall(GestureDetector.SwipeDirection swipe)
    {
        int cost = 1;

        if (bouncer_left == null)
        {
            InitializeBouncers();
        }

        if (!ENABLE_CONSTRAINT || pm.TestSubtract(cost) && allow_supercharge)
        {
            pm.ExecuteSubtract(cost);
            audio_source.PlayOneShot(clip_wall_supercharged);
            bool successful_swipe = false;
            switch (swipe)
            {
            case GestureDetector.SwipeDirection.swipe_right:
                bouncer_right.SetSupercharge(SUPERCHARGE_BASE_TIME);
                successful_swipe = true;
                break;

            case GestureDetector.SwipeDirection.swipe_left:
                bouncer_left.SetSupercharge(SUPERCHARGE_BASE_TIME);
                successful_swipe = true;
                break;
            }

            if (tutorial_power_up != null && successful_swipe)
            {
                tutorial_power_up.ProceedSupercharge();
            }
        }
    }
コード例 #2
0
 public void SetTripleShot()
 {
     if (powerup_meter.TestSubtract(3))
     {
         next_is_triple_shot = true;
     }
 }
コード例 #3
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);
        //}
    }