TO SQUASH: Started ooze ball.

This commit is contained in:
2026-08-03 00:45:40 -04:00
parent bc4fe8fc80
commit 378efa16ef
20 changed files with 2036 additions and 1 deletions
+1
View File
@@ -32,6 +32,7 @@ public class BallSpawner : MonoBehaviour
ballQueue.Enqueue(() => SpawnBall(basicBallPrefab));
ballQueue.Enqueue(() => SpawnBall(fruitBallPrefab));
ballQueue.Enqueue(() => SpawnBall(fruitBallPrefab));
ballQueue.Enqueue(() => SpawnBall(oozeBallPrefab));
StartCoroutine(SpawnBalls());
}
+85
View File
@@ -0,0 +1,85 @@
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<AudioSource>();
animator = GetComponent<Animator>();
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.
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 376e5687442580381aa67f431fce81c4