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; 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"); audioSrc = GetComponent(); } // Update is called once per frame void Update() { } public static void PlaySound(string clip) { switch (clip) { case "jump": audioSrc.PlayOneShot(jumpSound); break; case "scream": audioSrc.PlayOneShot(screamSound); break; case "wrong": audioSrc.PlayOneShot(wrongButtonSound); break; case "bug laugh": audioSrc.PlayOneShot(bugLaughSound); break; case "drink": audioSrc.PlayOneShot(drinkSound); break; case "eat": audioSrc.PlayOneShot(eatSound); break; case "punch": audioSrc.PlayOneShot(punchSound); break; case "hard punch": audioSrc.PlayOneShot(hardPunchSound); break; case "slap": audioSrc.PlayOneShot(slapSound); break; case "hard slap": audioSrc.PlayOneShot(hardSlapSound); break; case "win": audioSrc.PlayOneShot(winSound); break; } } }