using UnityEngine; public class OozeBall : MonoBehaviour { private Animator animator; public AudioClip spawnSound; public AudioClip bounceSound; public AudioClip hitSound; public AudioClip timerSound; public AudioClip splitSound; public AudioClip stoppedSound; private AudioSource audioSource; private Vector2 speed; private float splitTimer = 30.0f; private float tickTimer = 1.0f; // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() { audioSource = GetComponent(); animator = GetComponent(); speed = new Vector2(Random.Range(-0.005f, 0.005f), Random.Range(-0.005f, 0.005f)); audioSource.PlayOneShot(spawnSound); } // Update is called once per frame void Update() { AnimatorStateInfo stateInfo = animator.GetCurrentAnimatorStateInfo(0); if (stateInfo.IsName("OozeBallMove")) { transform.Translate(speed); } splitTimer -= Time.deltaTime; tickTimer -= Time.deltaTime; if (splitTimer <= 0.0f) { Split(); Destroy(gameObject); } if (tickTimer <= 0.0f) { tickTimer = 1.0f; audioSource.PlayOneShot(timerSound); } // TODO: Implement logic to halt the OozeBall's splitting behavior. } void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.CompareTag("Wall")) { ContactPoint2D contact = collision.GetContact(0); speed = Vector2.Reflect(speed, contact.normal); } } void Split() { animator.SetTrigger("split"); audioSource.PlayOneShot(splitSound); // TODO: Implement the logic for splitting the OozeBall into smaller balls } void Halt() { audioSource.PlayOneShot(stoppedSound); // TODO: Implement the logic for transforming the OozeBall into a basic ball. } }