TO SQUASH:

Added eye ball
This commit is contained in:
2026-08-04 21:23:39 -04:00
parent b3d28dd2c9
commit 7fcbd5a38a
18 changed files with 1375 additions and 9 deletions
+2 -1
View File
@@ -41,6 +41,7 @@ public class BallSpawner : MonoBehaviour
ballQueue.Enqueue(() => SpawnBall(glassBallPrefab));
ballQueue.Enqueue(() => SpawnBall(glassBallPrefab));
ballQueue.Enqueue(() => SpawnBall(glassBallPrefab));
ballQueue.Enqueue(() => SpawnBall(eyeBallPrefab));
StartCoroutine(SpawnBalls());
}
@@ -121,7 +122,7 @@ public class BallSpawner : MonoBehaviour
bounds = boardRenderer.bounds;
}
const float edgeInset = 0.05f;
const float edgeInset = 0.1f;
float randomX = Random.Range(bounds.min.x + edgeInset, bounds.max.x - edgeInset);
float randomY = Random.Range(bounds.min.y + edgeInset, bounds.max.y - edgeInset);
+46
View File
@@ -0,0 +1,46 @@
using UnityEngine;
public class EyeBall : MonoBehaviour
{
private Animator animator;
public AudioClip spawnSound;
public AudioClip bounceSound;
public AudioClip hitSound;
private AudioSource audioSource;
private Vector2 speed;
// 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.05f, 0.05f), Random.Range(-0.05f, 0.05f));
audioSource.PlayOneShot(spawnSound);
}
// Update is called once per frame
void FixedUpdate()
{
AnimatorStateInfo stateInfo = animator.GetCurrentAnimatorStateInfo(0);
if (stateInfo.IsName("EyeBallMove")) {
transform.Translate(speed);
}
}
void OnCollisionEnter2D(Collision2D collision)
{
// EyeBall only bounces off walls, not other balls
if (collision.gameObject.CompareTag("Wall"))
{
ContactPoint2D contact = collision.GetContact(0);
speed = Vector2.Reflect(speed, contact.normal);
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 90794e12b080d5a0eb07eec901ace3a5
+1 -7
View File
@@ -2,9 +2,7 @@ using UnityEngine;
public class NukeBall : MonoBehaviour
{
private Animator animator;
private static float gravity = 0.5f;
private Animator animator;
public AudioClip spawnSound;
@@ -28,8 +26,6 @@ private Animator animator;
private float height;
private float verticalVelocity = 0.0f;
private Collider2D selfCollider;
private bool isBouncingToHeight = false;
@@ -80,7 +76,6 @@ private Animator animator;
{
isBouncingToHeight = false;
bounceTimer = 0.0f;
verticalVelocity = 0.0f;
currentPosition.y = height;
UpdateFallTargetFromCurrentPosition();
}
@@ -137,7 +132,6 @@ private Animator animator;
bounceTimer = 0.0f;
bounceStartY = contact.point.y;
fallTargetY = bounceStartY;
verticalVelocity = 0.0f;
Vector3 currentPosition = transform.position;
currentPosition.y = bounceStartY;