public void PlaySoundEffect(SoundEffectName effectName, float vol = -1) { if (isSoundEffectsMuted == 0) // if the sound effects aren't muted, play it { for (int i = 0; i < soundEffectAudios.Length; i++) { if (soundEffectAudios[i].effectName == effectName) { // set the audio source volume if specified, if not set the default volume vol = (vol != -1f) ? vol : startingVol; audioSrc.PlayOneShot(soundEffectAudios[i].effectAudio, vol); break; } } } }
/// <summary> /// SE取得 /// </summary> /// <param name="_name">SE名</param> /// <returns>SEのオーディオソース</returns> public AudioSource GetSoundEffect(SoundEffectName _name) { return(this.audioSourceList_[(int)_name]); }
public static void Play(SoundEffectName name) { if (!enabled) return; switch (name) { case SoundEffectName.Aspect: aspect.Play(); break; case SoundEffectName.Boom: boom.Play(); break; case SoundEffectName.Die: if (hurtInst.State == SoundState.Playing) hurtInst.Stop(); die.Play(); break; case SoundEffectName.Jump: if (jumpInst.State != SoundState.Playing) jumpInst.Play(); break; case SoundEffectName.Hurt: if (hurtInst.State != SoundState.Playing) hurtInst.Play(); break; case SoundEffectName.Enter: enter.Play(); break; case SoundEffectName.Drown: if (drowInst.State != SoundState.Playing) drowInst.Play(); break; case SoundEffectName.Key: if (keysInst.State != SoundState.Playing) keysInst.Play(); break; case SoundEffectName.Pew: if (pewwInst.State != SoundState.Playing) pewwInst.Play(); break; case SoundEffectName.Leave: leave.Play(); break; case SoundEffectName.Pause: pause.Play(); break; case SoundEffectName.Special: special.Play(); break; case SoundEffectName.Coin: coin.Play(); break; case SoundEffectName.Heal: heal.Play(); break; case SoundEffectName.Laser: laser.Play(); break; } }