Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.EventSystems;
- public class BurstBubble : MonoBehaviour
- {
- RandomNumber randomNumber;
- SpawnBalls spawnBalls;
- RaycastHit hit;
- void Awake ()
- {
- randomNumber = FindObjectOfType<RandomNumber> ();
- spawnBalls = FindObjectOfType<SpawnBalls> ();
- }
- void Update ()
- {
- if (Input.GetMouseButtonDown (0)) {
- Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
- if (Physics.Raycast (ray, out hit)) { //correct answer
- if (hit.collider.name == RandomNumber.result.ToString ()) {
- GameObject correctBubble = hit.collider.gameObject;
- PlayerData.playerData.userList.Insert (0, new playerData (PlayerData.currentUser, PlayerData.PlayerPoints++));
- Destroy (correctBubble);//DODAC ANIMACJE ZNISZCZENIA ODPOWIEDNIEJ BAŃKI
- StartCoroutine (Destroy ());
- } else {
- GameObject wrongBubble = hit.collider.gameObject;
- randomNumber.Results.Remove (int.Parse (wrongBubble.gameObject.name)); // remove number from List
- Destroy (wrongBubble);
- }
- }
- }
- }
- IEnumerator Destroy ()
- {
- for (int i = 0; i < spawnBalls.parentObject.transform.childCount; i++) {
- Destroy (spawnBalls.parentObject.transform.GetChild (i).gameObject, 1.3f);
- //Debug.Log (spawnBalls.parentObject.transform.GetChild (i));
- yield return new WaitForSeconds (.3f);
- }
- yield return new WaitForSeconds (2f);
- randomNumber.MathBubbles ();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement