Add SFX to dialogue, revamp control scheme (broken world map camera)
This commit is contained in:
64
Assets/Scripts/Audio/SFXManager.cs
Normal file
64
Assets/Scripts/Audio/SFXManager.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
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";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user