Advertisement
HrvojeH

No Audio

Aug 22nd, 2019
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using UnityEditor;
  6. using UnityEngine.EventSystems;
  7. using TMPro;
  8. using System;
  9. using Random = UnityEngine.Random;
  10.  
  11.  
  12. public class CircleBehaviour : MonoBehaviour
  13. {
  14. public float timeElapsed;
  15. public Vector3 curScale;
  16. public Vector3 firstScale;
  17. public float offset;
  18. public GameObject Controller;
  19.  
  20. public AudioClip GoodClip;
  21. public AudioClip BadClip;
  22.  
  23. public AudioSource MusicSource;
  24.  
  25. // Start is called before the first frame update
  26. void Start()
  27. {
  28. offset = 0.025f;
  29. Controller = GameObject.Find("Controller");
  30. MusicSource = gameObject.transform.GetComponent<AudioSource>();
  31.  
  32. }
  33.  
  34. // Update is called once per frame
  35. void Update()
  36. {
  37. timeElapsed += Time.deltaTime;
  38.  
  39. if (timeElapsed < 1)
  40. {
  41. curScale = transform.localScale;
  42. firstScale = transform.localScale;
  43. }
  44. else
  45. {
  46. float x = curScale.x - offset * timeElapsed;
  47. curScale.x = x;
  48. curScale.y = x;
  49. transform.localScale = curScale;
  50. }
  51. if (transform.localScale.x <= 0)
  52. {
  53.  
  54. Controller.GetComponent<GameBehaviour>().missed += 1;
  55. MusicSource.clip = BadClip;
  56. MusicSource.Play();
  57. Destroy(gameObject);
  58. }
  59. }
  60. void OnMouseDown()
  61. {
  62.  
  63. Controller.GetComponent<GameBehaviour>().clicked += 1;
  64. MusicSource.clip = GoodClip;
  65. MusicSource.Play();
  66. Destroy(gameObject);
  67.  
  68.  
  69. }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement