TO SQUASH: Added shooting bars.

This commit is contained in:
2026-08-05 01:23:47 -04:00
parent 2c7e02887c
commit c91a405227
30 changed files with 7987 additions and 98 deletions
+40
View File
@@ -0,0 +1,40 @@
using UnityEngine;
public class BallBase : MonoBehaviour
{
public AudioClip spawnSound;
public AudioClip bounceSound;
public AudioClip hitSound;
protected Animator animator;
protected AudioSource audioSource;
protected Vector2 speed;
void OnTriggerEnter2D(Collider2D other)
{
if(other.gameObject.CompareTag("Bar"))
{
audioSource.PlayOneShot(hitSound);
// Destroy all bar segments when the ball hits a bar.
var barSegments = GameObject.FindGameObjectsWithTag("Bar");
foreach (var barSegment in barSegments)
{
Destroy(barSegment);
}
// Notify the player that the bar has been hit.
var player = GameObject.FindGameObjectWithTag("Player");
if (player != null)
{
player.GetComponent<Player>().OnBarHit();
}
}
}
}