void Awake() { // Register the singleton if (Instance != null) { Debug.LogError("Multiple instances of SoundEffects!"); Destroy(Instance.gameObject); } Instance = this; DontDestroyOnLoad(this); }
// private WMPLib.WindowsMediaPlayer soundEffectsPlayer; //public Sound() { // this.soundEffectsPlayer = new WMPLib.WindowsMediaPlayer(); //} public void playSound(soundEffects shortsound) { if (shortsound == soundEffects.ChipmunksBats){ System.Media.SoundPlayer player = new System.Media.SoundPlayer("ChipmunksBats.wav"); player.Play(); //soundEffectsPlayer.URL = "ChipmunksBats.wav"; } else if (shortsound == soundEffects.EvilLaughWumpusNear){ System.Media.SoundPlayer player = new System.Media.SoundPlayer("EvilLaugh.wav"); player.Play(); } else if (shortsound == soundEffects.AngryWumpusFar) { System.Media.SoundPlayer player = new System.Media.SoundPlayer("Anger.wav"); player.Play(); }else if (shortsound == soundEffects.JellyFishDoors) { System.Media.SoundPlayer player = new System.Media.SoundPlayer("JumpBounce.wav"); player.Play(); }else if (shortsound == soundEffects.movingForward) { System.Media.SoundPlayer player = new System.Media.SoundPlayer("largeBubble.wav"); player.Play(); }else if (shortsound == soundEffects.FallIntoPit) { System.Media.SoundPlayer player = new System.Media.SoundPlayer("Fall.wav"); player.Play(); }else if (shortsound == soundEffects.ShootArrow) { System.Media.SoundPlayer player = new System.Media.SoundPlayer("ShootArrow.wav"); player.Play(); } else if (shortsound == soundEffects.lost){ System.Media.SoundPlayer player = new System.Media.SoundPlayer("lost.wav"); player.Play(); } }
public void PlaySound(soundEffects sound) { source.clip = sounds[(int)sound]; source.Play(0); }