Euras

BubblePop

Feb 1st, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.22 KB | None | 0 0
  1.     public void DestroyBubble(GameObject bubble, bool fishCaught, bool popNoise)
  2.     {
  3.         if(bubble.transform.childCount > 0)
  4.         {
  5.             fishInsideBubble = bubble.transform.GetChild(0).gameObject;
  6.  
  7.             if (fishCaught)
  8.             {
  9.                 fishInsideBubble.GetComponent<FishSwim>().isCaught = true;
  10.                 MainGlobals.lives--;
  11.                 PlayerLives.loseLife = true;
  12.             }
  13.             else
  14.             {
  15.                 fishInsideBubble.GetComponent<Rigidbody2D>().isKinematic = false;
  16.                 fishInsideBubble.GetComponent<CircleCollider2D>().enabled = true;
  17.                 ParticleSystem pS = fishInsideBubble.GetComponentInChildren<ParticleSystem>();
  18.                 ParticleSystem.EmissionModule eM = pS.emission;
  19.                 pS.Play();
  20.                 eM.enabled = true;
  21.                 pSource.PlayOneShot(pSound[1], 0.5F);
  22.                 MainGlobals.fishScore++;
  23.             }
  24.         }
  25.  
  26.         if (popNoise)
  27.         {
  28.             pSource.PlayOneShot(pSound[0], 1.0F);
  29.         }
  30.  
  31.         bubble.transform.DetachChildren();
  32.  
  33.         Destroy(bubble);
  34.         pop.transform.position = bubble.transform.position;
  35.         pSys.Play();
  36.     }
Advertisement
Add Comment
Please, Sign In to add comment