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.UI;
- using UnityEditor;
- using UnityEngine.EventSystems;
- using TMPro;
- using System;
- using Random = UnityEngine.Random;
- public class CircleBehaviour : MonoBehaviour
- {
- public float timeElapsed;
- public Vector3 curScale;
- public Vector3 firstScale;
- public float offset;
- public GameObject Controller;
- public AudioClip GoodClip;
- public AudioClip BadClip;
- public AudioSource MusicSource;
- // Start is called before the first frame update
- void Start()
- {
- offset = 0.025f;
- Controller = GameObject.Find("Controller");
- MusicSource = gameObject.transform.GetComponent<AudioSource>();
- }
- // Update is called once per frame
- void Update()
- {
- timeElapsed += Time.deltaTime;
- if (timeElapsed < 1)
- {
- curScale = transform.localScale;
- firstScale = transform.localScale;
- }
- else
- {
- float x = curScale.x - offset * timeElapsed;
- curScale.x = x;
- curScale.y = x;
- transform.localScale = curScale;
- }
- if (transform.localScale.x <= 0)
- {
- Controller.GetComponent<GameBehaviour>().missed += 1;
- MusicSource.clip = BadClip;
- MusicSource.Play();
- Destroy(gameObject);
- }
- }
- void OnMouseDown()
- {
- Controller.GetComponent<GameBehaviour>().clicked += 1;
- MusicSource.clip = GoodClip;
- MusicSource.Play();
- Destroy(gameObject);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement