public void LiftRubbish(RubbishController rubbishController)
    {
        if (rubbishController.IsLifted())
        {
            rubbishController.ThrowFromAnyBubble();
            PlayManager.Score      += BubbleController.SkillScore;
            PlayManager.SkillScore += BubbleController.SkillScore;
        }

        DistanceJoint2D djSampah = rubbishController.gameObject.AddComponent <DistanceJoint2D>();

        djSampah.connectedBody    = rigidbody2D;
        djSampah.distance         = 0f;
        djSampah.collideConnected = false;
        djSampah.maxDistanceOnly  = true;
        rubbishes.Add(rubbishController);


        DistanceJoint2D djGelembung = gameObject.AddComponent <DistanceJoint2D>();

        djGelembung.connectedBody    = rubbishController.rigidbody2D;
        djGelembung.distance         = 0f;
        djGelembung.collideConnected = false;
        djGelembung.maxDistanceOnly  = true;
        distanceJoints.Add(djGelembung);

        if (HaveBeenBouncing && !HaveBeenLiftRubbish)
        {
            PlayManager.Score      += BubbleController.RedSkillScore;
            PlayManager.SkillScore += BubbleController.RedSkillScore;
            HaveBeenLiftRubbish     = true;
        }
    }
Exemple #2
0
 void OnTriggerEnter2D(Collider2D coll)
 {
     if (coll.gameObject.GetComponent <BarrierController>() && coll.gameObject.GetComponent <BarrierController>().isSpicky)
     {
         bubble.BrokenOut();
     }
     else if (coll.gameObject.GetComponent <RubbishController>())
     {
         RubbishController sampahController = coll.gameObject.GetComponent <RubbishController>();
         if (!sampahController.IsLifted() && bubble.CanLift(sampahController) && !bubble.thrownRubbishes.Contains(sampahController))
         {
             bubble.LiftRubbish(sampahController);
         }
         else if (!sampahController.IsLifted() && bubble.CanLiftWithThrowFirst(sampahController) && !bubble.thrownRubbishes.Contains(sampahController))
         {
             bubble.ThrowFirstRubbish();
             bubble.LiftRubbish(sampahController);
         }
     }
 }