basic fire sound. very loud
This commit is contained in:
parent
819741ba6a
commit
95603a9a12
5 changed files with 188 additions and 0 deletions
48
Assets/_Project/Scripts/Combat/TeslaTowerFireSound.cs
Normal file
48
Assets/_Project/Scripts/Combat/TeslaTowerFireSound.cs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
// Assets/_Project/Scripts/Combat/TeslaTowerFireSound.cs
|
||||
using UnityEngine;
|
||||
|
||||
namespace TD.Combat
|
||||
{
|
||||
/// <summary>
|
||||
/// Local-only audio for the Tesla Coil tower. Subscribes to
|
||||
/// <see cref="TowerCombat.OnAreaFired"/> and plays a one-shot fire sound
|
||||
/// on every peer each time the coil discharges.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Pure client-side — nothing here is networked. Add additional
|
||||
/// <see cref="AudioClip"/> fields and <see cref="AudioSource"/> calls here
|
||||
/// as the Tesla Coil gains more audio (idle hum, charge-up, etc.).
|
||||
/// </remarks>
|
||||
[RequireComponent(typeof(TowerCombat))]
|
||||
[RequireComponent(typeof(AudioSource))]
|
||||
public class TeslaTowerFireSound : MonoBehaviour
|
||||
{
|
||||
[Tooltip("Sound played each time the coil discharges.")]
|
||||
[SerializeField] private AudioClip fireClip;
|
||||
|
||||
private TowerCombat combat;
|
||||
private AudioSource audioSource;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
combat = GetComponent<TowerCombat>();
|
||||
audioSource = GetComponent<AudioSource>();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (combat != null) combat.OnAreaFired += HandleAreaFired;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (combat != null) combat.OnAreaFired -= HandleAreaFired;
|
||||
}
|
||||
|
||||
private void HandleAreaFired(Vector3[] positions)
|
||||
{
|
||||
if (fireClip != null)
|
||||
audioSource.PlayOneShot(fireClip);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue