using System.Collections; using System.Collections.Generic; using UnityEngine; public class SoundManagerScript : MonoBehaviour { public static AudioClip jumpSound, screamSound, wrongButtonSound, bugLaughSound, drinkSound, eatSound, punchSound, hardPunchSound, slapSound, hardSlapSound, winSound; public static AudioSource audioSrc; // Start is called before the first frame update void Start() { jumpSound = Resources.Load("Audio/Jump"); screamSound = Resources.Load("Audio/GirlyScream"); wrongButtonSound = Resources.Load("Audio/WrongButton"); bugLaughSound = Resources.Load("Audio/BugLaugh"); drinkSound = Resources.Load("Audio/Drink"); eatSound = Resources.Load("Audio/Eat"); punchSound = Resources.Load("Audio/Punch"); hardPunchSound = Resources.Load("Audio/HardPunch"); slapSound = Resources.Load("Audio/Slap"); hardSlapSound = Resources.Load("Audio/HardSlap"); winSound = Resources.Load("Audio/Win"); audioSrc = GetComponent(); } // Update is called once per frame void Update() { } public static void PlaySound(string clip) { AudioClip sound = null; switch (clip) { case "jump": sound = jumpSound; break; case "scream": sound = screamSound; break; case "wrong": sound = wrongButtonSound; break; case "bug laugh": sound = bugLaughSound; break; case "drink": sound = drinkSound; break; case "eat": sound = eatSound; break; case "punch": sound = punchSound; break; case "hard punch": sound = hardPunchSound; break; case "slap": sound = slapSound; break; case "hard slap": sound = hardSlapSound; break; case "win": sound = winSound; break; } audioSrc.clip = sound; audioSrc.PlayOneShot(sound); } }