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