unified audio manager that limits the number of simultaneous sounds in certain categories
This commit is contained in:
parent
d53a2a47e2
commit
404c749a43
9 changed files with 154 additions and 110 deletions
|
|
@ -1,4 +1,5 @@
|
|||
// Assets/_Project/Scripts/Combat/TeslaTowerFireSound.cs
|
||||
using TD.Audio;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TD.Combat
|
||||
|
|
@ -14,7 +15,6 @@ namespace TD.Combat
|
|||
/// 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.")]
|
||||
|
|
@ -25,12 +25,10 @@ namespace TD.Combat
|
|||
[SerializeField] private float maxPitch = 1.07f;
|
||||
|
||||
private TowerCombat combat;
|
||||
private AudioSource audioSource;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
combat = GetComponent<TowerCombat>();
|
||||
audioSource = GetComponent<AudioSource>();
|
||||
combat = GetComponent<TowerCombat>();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
|
|
@ -45,12 +43,7 @@ namespace TD.Combat
|
|||
|
||||
private void HandleAreaFired(Vector3[] positions)
|
||||
{
|
||||
if (fireClip != null)
|
||||
{
|
||||
audioSource.pitch = Random.Range(minPitch, maxPitch);
|
||||
audioSource.clip = fireClip;
|
||||
audioSource.Play();
|
||||
}
|
||||
AudioManager.Instance?.Play(fireClip, AudioCategory.TowerFire, Random.Range(minPitch, maxPitch));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue