basic fire sound. very loud

This commit is contained in:
Ian Woods 2026-06-28 15:07:31 -07:00
parent 819741ba6a
commit 95603a9a12
5 changed files with 188 additions and 0 deletions

View 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);
}
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: db643146344a08a639133638e4746a33