65 lines
1.4 KiB
C#
65 lines
1.4 KiB
C#
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.PlayOneShot(audioClip);
|
|
}
|
|
|
|
public void StopSoundEffect()
|
|
{
|
|
_audioSource.Stop();
|
|
}
|
|
|
|
|
|
private AudioClip GetClipFromName(string desiredSoundEffect)
|
|
=> _soundEffects.SoundEffects.Where(x => x.name.Equals(desiredSoundEffect)).Single();
|
|
}
|
|
|
|
public class SoundEffect
|
|
{
|
|
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";
|
|
}
|
|
}
|