TO SQUASH: Started ooze ball.
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user