public static void PitchSoundEffect(SoundEffectType soundEffectType, float pitch) { if (instance) { instance.internalPitchSoundEffect(soundEffectType, pitch); } }
public static void StopSoundEffect(SoundEffectType soundEffectType) { if (instance) { instance.internalStopSoundEffect(soundEffectType); } }
public void PlayAudio(SoundEffectType effect) { int?soundId = null; switch (effect) { case SoundEffectType.FacebookAlert: soundId = IE.Mobile.Droid.Services.Resource.Raw.facebook_sound; break; case SoundEffectType.FacebookPop: soundId = IE.Mobile.Droid.Services.Resource.Raw.facebook_pop; break; case SoundEffectType.Notification: soundId = IE.Mobile.Droid.Services.Resource.Raw.facebook_pop; break; } //Dispose of the media Player on each call to avoid any memory leaks using (MediaPlayer _mediaPlayer = MediaPlayer.Create(global::Android.App.Application.Context, soundId.Value)) { _mediaPlayer.SetVolume(100, 100); _mediaPlayer.Start(); } }
public static void PauseSoundEffect(SoundEffectType soundEffectType) { if (instance) { instance.internalPauseSoundEffect(soundEffectType); } }
public void PlayAudio(SoundEffectType effect) { string fileName = ""; switch (effect) { case SoundEffectType.FacebookAlert: fileName = "~Assets/facebook_sound.mp3"; break; case SoundEffectType.FacebookPop: fileName = "~Assets/facebook_pop.mp3"; break; case SoundEffectType.Notification: fileName = ""; break; } //Platform Specific UWP code for running audio ISimpleAudioPlayer player = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current; player.Load(File.OpenRead(fileName)); player.Play(); }
public static void PlaySoundEffect(SoundEffectType soundEffectType, float length = -1f) { if (instance) { instance.internalPlaySoundEffect(soundEffectType, length); } }
public void LoadContent() { // Fonts. String fontsRoot = String.Format("{0}/{1}/", contentRoot, FONTS_DIRECTORY); Assets.EmulogicFont = contentFactory.LoadFont(fontsRoot + "Emulogic"); // Sounds. if (MyGame.Manager.ConfigManager.GlobalConfigData.LoadAudio) { String soundsRoot = String.Format("{0}/{1}/", contentRoot, SOUND_DIRECTORY); Assets.SongDictionary = new Dictionary <SongType, Song>(); for (SongType key = SongType.BossMusic1; key <= SongType.GameTitle; ++key) { String assetName = String.Format("{0}{1}", soundsRoot, key); Song value = contentFactory.LoadSong(assetName); Assets.SongDictionary.Add(key, value); } Assets.SoundEffectDictionary = new Dictionary <SoundEffectType, SoundEffectInstance>(); for (SoundEffectType key = SoundEffectType.Aaargh; key <= SoundEffectType.Wrong; ++key) { String assetName = String.Format("{0}{1}", soundsRoot, key); SoundEffectInstance value = contentFactory.LoadSoundEffectInstance(assetName); Assets.SoundEffectDictionary.Add(key, value); } } // Textures. Assets.SpriteSheet01Texture = contentFactory.LoadTexture(texturesRoot + "spritesheet01-1024"); Assets.SpriteSheet02Texture = contentFactory.LoadTexture(texturesRoot + "spritesheet02-1024"); }
//SongType GetBossMusic(Byte levelIndex) //{ // Byte index = (Byte)(levelIndex % Constants.BOSS_MUSIC); // return bossMusicList[index]; //} public void PlayBulletSoundEffect() { Byte index = (Byte)MyGame.Manager.RandomManager.Next(Constants.FIRE_SOUND); SoundEffectType key = bulletSoundList[index]; PlaySoundEffect(key); }
public void PlayAudio(SoundEffectType effect) { string fileName = ""; switch (effect) { case SoundEffectType.FacebookAlert: fileName = "facebook_sound.mp3"; break; case SoundEffectType.FacebookPop: fileName = "facebook_pop.mp3"; break; case SoundEffectType.Notification: fileName = ""; break; } var filePath = NSBundle.MainBundle.PathForResource(Path.GetFileNameWithoutExtension(fileName), Path.GetExtension(fileName)); NSError outError; NSUrl fileURL = new NSUrl(fileName); using (AVAudioPlayer audioPlayer = new AVAudioPlayer(url: fileURL, "video/mp4", outError: out outError)) { var url = NSUrl.FromString(filePath); audioPlayer.Play(); } }
/// <summary> /// Stop a specific sound effect. /// </summary> public void StopSound(SoundEffectType soundEffectType) { if (soundStatus == SoundStatus.SOUND_ON) { currentAudioSource = soundEffects[(int)soundEffectType]; currentAudioSource.Stop(); } }
/// <summary> /// Get audio clip /// </summary> /// <param name="type">Type of the sound effect</param> /// <returns>Desired audio clip</returns> public AudioClip GetSoundEffect(SoundEffectType type) { AudioClip audio; allSoundEffects.TryGetValue(type, out audio); return(audio); }
/// <summary> /// Play a sound effect with a specific pitch. /// </summary> public void PlaySoundWithPitch(SoundEffectType soundEffectType, float pitch) { if (soundStatus == SoundStatus.SOUND_ON) { currentAudioSource = soundEffects[(int)soundEffectType]; currentAudioSource.pitch = pitch; currentAudioSource.Play(); } }
public void StopSoundEffect(SoundEffectType type) { if (!IsPlaying(type)) { return; } m_allSoundEffect[(int)type].Stop(); }
private void internalPauseSoundEffect(SoundEffectType soundEffectType) { if (!audioSourcesByType.ContainsKey(soundEffectType)) { return; } audioSourcesByType[soundEffectType].Pause(); }
public void Play(SoundEffectType type) { if (!_soundEffects.ContainsKey(type)) { return; } _source.PlayOneShot(_soundEffects[type].AudioClip); }
public void PlaySoundEffect(SoundEffectType type) { if (IsPlaying(type)) { return; } m_allSoundEffect[(int)type].Play(); }
private void internalPitchSoundEffect(SoundEffectType soundEffectType, float pitch) { if (!audioSourcesByType.ContainsKey(soundEffectType)) { return; } audioSourcesByType[soundEffectType].pitch = pitch; }
private void PlaySoundEffect(SoundEffectType key) { if (!PlaySound) { return; } //SoundEffectInstance value = Assets.SoundEffectDictionary[key]; //value.Play(); }
/// <summary> /// Play a sound effect. /// </summary> public void PlaySound(SoundEffectType soundEffectType, bool randomPitch) { if (soundStatus == SoundStatus.SOUND_ON) { currentAudioSource = soundEffects[(int)soundEffectType]; if (randomPitch) { currentAudioSource.pitch = Random.Range(minRandomPitch, maxRandomPitch); } currentAudioSource.Play(); } }
private void internalStopSoundEffect(SoundEffectType soundEffectType) { if (!audioSourcesByType.ContainsKey(soundEffectType)) { return; } AudioSource audioSource = audioSourcesByType[soundEffectType]; audioSourcesByType.Remove(soundEffectType); Destroy(audioSource); }
private IEnumerator WaitForFinish(SoundEffectType soundEffectType, float length) { if (!audioSourcesByType.ContainsKey(soundEffectType)) { yield break; } AudioSource audioSource = audioSourcesByType[soundEffectType]; float currentTime = 0f; do { if (audioSource == null) { yield break; } if (audioSource.isPlaying) { currentTime += Time.deltaTime * (audioSource.pitch > 1f ? 5f : 1f); } yield return(null); } while(currentTime < length); audioSourcesByType.Remove(soundEffectType); /* * if( audioSource.loop ) * { * currentTime = 0f; * float lerp; * * do * { * if( audioSource == null ) * yield break; * * currentTime += Time.deltaTime; * lerp = currentTime / fadeOutDuration; * * audioSource.volume = Mathf.Lerp( ( isAudioOn ? 1f : 0f ), 0f, lerp ); * * yield return null; * * } while( currentTime < fadeOutDuration ); * } */ Destroy(audioSource); }
public void PlaySound(SoundEffectType type) { var spawnedSound = Instantiate(SoundEffectParticlePrefab); if (type != SoundEffectType.None) { AudioClip soundEffect = soundEffectsStorage.GetSoundEffect(type); AudioSource spawnedAudioSource = spawnedSound.GetComponent <AudioSource>(); spawnedAudioSource.clip = soundEffect; spawnedAudioSource.Play(); } }
public static string SoundEffectName(this SoundEffectType effectType) { switch (effectType) { case SoundEffectType.FacebookAlert: return("Facebook Alert"); case SoundEffectType.FacebookPop: return("Facebook Pop"); default: return("Standard Notification"); } }
public void StopSoundEffect(SoundEffectType key) { if (null == Assets.SoundEffectDictionary) { return; } if (!PlayAudio) { return; } SoundEffectInstance value = Assets.SoundEffectDictionary[key]; soundFactory.StopSoundEffect(value); }
public void PlaySound(SoundEffectType soundEffect, bool active) { AudioSource audioInit = _sources.Find(e => e.clip.name.Equals(soundEffect.ToString())); if (audioInit != null) { if (active) { audioInit.Play(); } else { audioInit.Stop(); } } }
private void internalPlaySoundEffect(SoundEffectType soundEffectType, float length) { if (audioSourcesByType.ContainsKey(soundEffectType) && !audioSourcesByType[soundEffectType].loop) { StopSoundEffect(soundEffectType); } if (!audioSourcesByType.ContainsKey(soundEffectType)) { AudioClip clip = null; switch (soundEffectType) { case SoundEffectType.Print: clip = printAudioClips[NextRandomIndex()]; break; case SoundEffectType.ButtonTap: clip = buttonTapAudioClip; break; case SoundEffectType.Swipe: clip = swipeAudioClip; break; case SoundEffectType.PrintFinish: clip = printFinishClip; break; } if (clip == null) { return; } AudioSource audioSource = CameraAgent.MainCameraObject.AddComponent <AudioSource>(); if (length == -1f) { length = clip.length; } else { audioSource.loop = true; } audioSource.clip = clip; audioSource.volume = (isAudioOn ? 1f : 0f); audioSourcesByType.Add(soundEffectType, audioSource); StartCoroutine(WaitForFinish(soundEffectType, length)); } audioSourcesByType[soundEffectType].Play(); }
public void Play(string name, SoundEffectType type, float delayedIn, float delayedOut, bool isLoop) { switch (type) { case SoundEffectType.Single: single.Play(name, delayedIn, delayedOut, isLoop); break; case SoundEffectType.Multi: multi.Play(name, delayedIn, delayedOut, isLoop); break; case SoundEffectType.WorldSingle: worldSingle.Play(name, delayedIn, delayedOut, isLoop); break; } }
public EffectSound(Dictionary <string, string> tmp) { if (tmp.ContainsKey("soundEffectType")) { _soundEffectType = tmp["soundEffectType"]; soundEffectType = GetSoundEffectType(_soundEffectType); } else { Debug.LogError("Sound Effect didn't get a soundEffectType"); } if (tmp.ContainsKey("audioSource")) { __audioSource = tmp["audioSource"]; _audioSource = Resources.Load <AudioSource>(__audioSource); } }
public void PlaySoundEffect(SoundEffectType type) { switch (type) { case SoundEffectType.Deposit: if (depositSound != null) { audioSource.PlayOneShot(depositSound); } break; case SoundEffectType.Explosion: if (explosionSound != null) { audioSource.PlayOneShot(explosionSound); } break; case SoundEffectType.PlayerSpawn: if (playerSpawnSound != null) { audioSource.PlayOneShot(playerSpawnSound); } break; case SoundEffectType.PickupSound: if (pickupSound != null) { audioSource.PlayOneShot(pickupSound); } break; default: break; } }
public void LoadContent() { // Fonts. String fonts = String.Format("{0}/{1}/", contentRoot, Constants.FONTS_DIRECTORY); Assets.EmulogicFont = Engine.Content.Load <SpriteFont>(fonts + FONT_NAME); // Textures. Assets.SpritesheetTexture = LoadTexture(SPRITE_NAME); // Songs. Assets.TitleMusicSong = Engine.Content.Load <Song>(soundRoot + TITLE_MUSIC_NAME); Assets.GameOverSong = Engine.Content.Load <Song>(soundRoot + GAME_OVER_NAME); // Sound effects. Assets.SoundEffectDictionary = new Dictionary <SoundEffectType, SoundEffectInstance>(); for (SoundEffectType key = SoundEffectType.Right; key <= SoundEffectType.Early; ++key) { SoundEffectInstance value = LoadSoundEffectInstance(key.ToString()); Assets.SoundEffectDictionary.Add(key, value); } }
public void PlaySFX(SoundEffectType sfxType) { AudioSource.PlayClipAtPoint(sfx[(int)sfxType], transform.position); }
public static void PlaySoundEffect(SoundEffectType type, CharacterType charType) { AudioSource source = null; switch (charType) { case CharacterType.Aegir: source = _VoiceAegir; break; case CharacterType.Oberon: source = _VoiceOberon; break; } List<AudioClip> clips = SoundEffectsDict[type]; int rand = Random.Range(0, clips.Count); source.PlayOneShot(clips[rand]); }
/// <summary> /// Play the requested sound effect. /// </summary> /// <param name="soundEffectType">Sound effect to play.</param> public void Play(SoundEffectType soundEffectType) { var effects = this.soundEffects[soundEffectType]; this.Play(effects[Random.Range(0, effects.Count)]); }