using System.Linq; using UnityEngine; namespace Scampz.GameJam.Assets.Scripts.Audio { public class SFXManager : MonoBehaviour { public static SFXManager Instance; [SerializeField] private SFX _soundEffects; [SerializeField] private AudioSource _audioSource; private void Awake() { if (Instance != null && Instance != this) { Destroy(this); return; } Instance = this; } public void PlaySoundEffect(string soundEffect) { var audioClip = GetClipFromName(soundEffect); _audioSource.clip = audioClip; _audioSource.Play(); } public void StopSoundEffect() { _audioSource.Stop(); } private AudioClip GetClipFromName(string desiredSoundEffect) => _soundEffects.SoundEffects.Where(x => x.name.Equals(desiredSoundEffect)).Single(); } public class SoundEffectName { public static string ComputerTalk => "computer talk ed"; public static string Diety => "diety"; public static string LavaGuy => "lava guy ed"; public static string MenuUpDown => "menu up down"; public static string Narration => "narration"; public static string Ok => "ok"; public static string SandStep => "sand step ed"; public static string SnowStep => "snow step"; public static string TempleStep => "temple step ed"; public static string GrassStep => "grass step ed"; public static string Void => "void"; } }