public void PlaySound(SoundName soundName) { switch (soundName) { case SoundName.AsteroidExplosion: _soundPlayer.PlayOneShot(asteroidExplosion); break; case SoundName.MetallicAsteroidHit: _soundPlayer.PlayOneShot(metallicAsteroidHit); break; case SoundName.StickBendingPole: _soundPlayer.PlayOneShot(stickBendingPole); break; case SoundName.ReleaseBendingPole: _soundPlayer.PlayOneShot(releaseBendingPole); break; default: Debug.LogWarning("THERE'S NO SOUND LIKE THIS"); break; } }
public Sound(SoundName inName, string AssetName) { Name = inName; Asset = AssetName; maxSound = 0; currSound = 0; }
private IEnumerator DropSound(SoundName sound) { AudioManager.instance.PlaySound(sound); yield return(null); soundCoroutine = null; }
public void Init() { ClientAssetRepository clientAssetRepo = GameFacade.Instance.RetrieveProxy <ClientAssetRepository>(); XmlDocument mXmlSoundDocument = XmlUtility.LoadXmlDocument(SOUND_LOOKUP_TABLE_XML_PATH); // TODO: Remove this loading hack. XmlNodeList soundNodes = mXmlSoundDocument.SelectNodes("Sounds/Sound"); mSoundsLeftToLoad = soundNodes.Count; foreach (XmlNode soundNode in soundNodes) { string name = soundNode.SelectSingleNode("Name").InnerText; SoundName soundName = (SoundName)Enum.Parse(typeof(SoundName), name); string path = soundNode.SelectSingleNode("Path").InnerText; //Console.WriteLine("Loading sound: " + name + ", " + path); clientAssetRepo.LoadAssetFromPath <SoundAsset>(path, delegate(SoundAsset asset) { RetrieveSoundAssetFromRepoOnLoad(soundName, asset); }); } mMainCamera = GameFacade.Instance.RetrieveMediator <CameraManagerMediator>().MainCamera; }
public void PlaySound(SoundName soundName) { foreach (IBlock block in blocks) { block.PlaySound(soundName); } }
public AudioSource PlaySoundCue(SoundName sound, Vector3 position, float pitch = 1) { SoundPrefab soundPrefab; // Find the sound cue if (!GetSoundFromSoundList(sound, soundList.cues, out soundPrefab)) { return(null); } // Instantiate the cue GameObject go = Instantiate(soundPrefab.clip, position, Quaternion.identity); OneShotThenDestroy oneShot = go.GetComponent <OneShotThenDestroy>(); if (oneShot != null) { oneShot.soundManager = this; } // Register it AudioSource source = go.GetComponent <AudioSource>(); cues.Add(new Cues(sound, source)); return(source); }
public void PlayAudioOneShot(SoundName audioName) { if (gameInstaller != null) { gameInstaller.fxSource.PlayOneShot(ReturnAudio(audioName)); } }
public void PlaySound(SoundName name, Vector3 position) // TODO try with 3d audio position { if (this.pistolShotAudio == null || this.rifleShotAudio == null || this.gunReloadAudio == null) { GD.Print("Audio not set!"); QueueFree(); return; } if (name == SoundName.PISTOL_SHOT) { this.audioPlayer.Stream = this.pistolShotAudio; } else if (name == SoundName.RIFLE_SHOT) { this.audioPlayer.Stream = this.rifleShotAudio; } else if (name == SoundName.RELOAD) { this.audioPlayer.Stream = this.gunReloadAudio; } else { GD.Print("UNKNOWN STREAM"); QueueFree(); return; } this.audioPlayer.Play(); }
public Sound(SoundName name, AudioClip clip, float volume = 1.0f, float pitch = 1.0f) { Name = name; Clip = clip; Volume = volume; Pitch = pitch; }
void Awake() { if( sounds == null ) sounds = new List<SoundName>(); _audio = audio; if (_audio == null) { _audio = gameObject.AddComponent<AudioSource>(); _audio.playOnAwake = false; } #if UNITY_EDITOR foreach (var component in gameObject.GetComponents<Component>()) { object[] attributes = component.GetType().GetCustomAttributes(true); foreach (var attr in attributes) { if (attr is SoundClipAttribute == false) continue; string name = ((SoundClipAttribute) attr).name; SoundName sound = sounds.Find(s => s.name == name); if (sound == null) { sound = new SoundName(); sound.name = name; sounds.Add(sound); } } } #endif }
public static void PlaySound(SoundName SoundName, bool Looping = true) { switch (SoundName) { case SoundName.Saber: SoundPlayer.Stream = Properties.Resources.Saber; break; case SoundName.GameBackground: SoundPlayer.Stream = Properties.Resources.GameBackground; break; case SoundName.MenuBackground: SoundPlayer.Stream = Properties.Resources.MenuBackground; break; case SoundName.CrusadersWin: SoundPlayer.Stream = Properties.Resources.CrusadersWin; break; case SoundName.SaracensWin: SoundPlayer.Stream = Properties.Resources.SaracensWin; break; default: return; } if (SoundEnabled) // play only if sound is enabled { if (Looping) // play in a loop SoundPlayer.PlayLooping(); else SoundPlayer.Play(); } }
public static Sound Add(SoundName soundName) { SoundManager soundMan = SoundManager.GetInstance(); Sound pSound = (Sound)soundMan.BaseAdd(); pSound.Set(soundName); return(pSound); }
async ValueTask play(SoundName soundName) { throwIfNotLoaded(); SoundEffect audio = _loader.GetSoundEffect(soundName); await audio.Play(); }
public static SoundBuffer GetSound(SoundName soundName) { if (sounds.Count == 0) { LoadSound(); } return(sounds[soundName]); }
public void AddSound(SoundName name, AudioClip audioClip) { if (mSoundDictionary.ContainsKey(name)) { throw new Exception("mSoundDictionary already contains SoundName: " + name + "."); } mSoundDictionary.Add(name, audioClip); }
public void InspectorAdapt(SoundName sn, bool isiid, float iidcoe, bool isitd, bool issim) { soundName = sn; isIid = isiid; iidCoefficient = iidcoe; isItd = isitd; isSimulation = issim; }
public void PlaySound(SoundName name) { if (_loadedEffects.TryGetValue(name, out SoundEffect effect)) { var volume = (float)_volume / 100; effect.Play(volume, 0f, 0f); } }
public static Sound getSound(SoundName soundName) { if (sounds.Count == 0) { LoadSounds(); } return sounds[soundName]; }
public void InspectorAdapt(SoundName sn,bool isiid,float iidcoe,bool isitd,bool issim) { soundName = sn; isIid = isiid; iidCoefficient = iidcoe; isItd = isitd; isSimulation = issim; }
public void playSound(SoundName soundName, float volume) { if (volume > 1) { volume = 1f; } sounds[(int)soundName].volume = volume; sounds[(int)soundName].Play(); }
public void StopEffect(SoundName effect) { Transform audio = transform.Find("(Audio) " + effect.ToString()); if (audio != null) { BlockTools.Destroy(audio.gameObject); } }
/// <summary> /// Módulo encargado de ejecutar el sonido y devolver su duración /// </summary> /// <param name="soundName">Sonido seleccionado</param> /// <returns></returns> public float PlaySound(SoundName soundName) { AudioClip aux; switch (soundName) { case SoundName.Heartbeat: aux = hearbeatSound; break; case SoundName.Scare: aux = scareSound; break; case SoundName.Violin: aux = violinSound; break; case SoundName.ButtonMouseEnter: aux = buttonMouseEnterSound; break; case SoundName.ButtonMouseClick: aux = buttonMouseClickSound; break; case SoundName.JumpPlayer: aux = jumpPlayerSound; break; case SoundName.HurtPlayer: aux = hurtPlayerSound; break; case SoundName.DeadPlayer: aux = deadPlayerSound; break; case SoundName.AttackPlayer: aux = attackPlayerSound; break; case SoundName.DeadScorpio: aux = deadScorpioSound; break; case SoundName.DeadVulture: aux = deadVultureSound; break; default: aux = null; break; } _soundEffects.PlayOneShot(aux); return(aux.length); }
public static Sound Find(SoundName soundName) { SoundManager soundMan = SoundManager.GetInstance(); Sound pSound = (Sound)soundMan.BaseFind(new Sound { name = soundName }); return(pSound); }
public void PlayGoalBeat(SoundName name) { if (playMode != PlayMode.Goal) { return; } var sourceItem = soundBank.First(x => x.Name == name); sourceItem.Source.Play(); }
public void PlayClip(SoundName soundName) { AudioClip audioClip = FindClip(soundName); if (audioClip != null) { audioSource.clip = audioClip; audioSource.Play(); } }
// Looks for first specified sound-effect by enum name public void PlaySound(SoundName soundName) { SoundEffect soundCombo = soundEffects.FirstOrDefault(x => x.soundName == soundName); if (soundCombo == null) { return; } soundCombo.audioSource.Play(); }
public void Play(SoundName name) { if (playMode != PlayMode.Gameplay) { return; } var sourceItem = soundBank.First(x => x.Name == name); sourceItem.Source.Play(); onDeckPlays.Add(name); }
private AudioClip GetSound(SoundName soundName) { foreach (var sound in sounds) { if (sound.soundName == soundName) { return(sound.clip); } } return(null); }
int GetIndex(SoundName name) { foreach (Sound item in sounds) { if (name == item.name) { return(sounds.IndexOf(item)); } } return(sounds.Count); }
/// <summary> /// Play a sound effect /// </summary> /// <param name="son"></param> public void playSound(SoundName son) { try // Catch exceptions in case the computer can't play songs (example: Travis) { if (!sfxmute) { sounds[(int)son].Play(); } } catch { } }
public void StopLooping(SoundName sn) { string p_YourLoopingSound = sn.ToString(); foreach (AudioSource audio in audioSources) { if (audio.clip.name == p_YourLoopingSound) { audio.Stop(); } } }
public void RemoveCue(SoundName name) { foreach (Cues cue in cues) { if (cue.name == name) { cues.Remove(cue); Destroy(cue.cue.gameObject); return; } } }
public void PlaySoundOneShot(SoundName soundName, AudioSource source) { int index = GetIndex(soundName); if (index == sounds.Count) { Debug.LogWarning("There is no sound with this name " + soundName + " on SoundsManger, please verify your typing."); return; } source.pitch = sounds[index].pitchs[Random.Range(0, sounds[index].pitchs.Count)]; source.PlayOneShot(sounds[index].clips[Random.Range(0, sounds[index].clips.Count)], sounds[index].volume); }
public void PlaySound(SoundName enumClip) { for (int i = 0; i < SoundsClipArray.Length; i++) { if (enumClip.ToString() == SoundsClipArray[i].name) { AudioSource soundSource = gameObject.AddComponent<AudioSource>(); soundSource.PlayOneShot (SoundsClipArray[i]); Destroy (soundSource, SoundsClipArray[i].length); } } }
private void RetrieveSoundAssetFromRepo(SoundName soundName, Asset asset) { //Console.WriteLine("Loaded sound: " + soundName.ToString()); SoundAsset soundAsset = (SoundAsset)asset; soundAsset.AudioClip.name = soundName.ToString(); if (soundAsset == null) { throw new Exception("asset returned from repo could not be cast as SoundAsset."); } AddSound(soundName, soundAsset.AudioClip); }
public AudioClip Get(SoundName soundName) { Sound target = null; foreach (Sound sound in sounds) { if (sound.soundName == soundName) { target = sound; break; } } if (target == null) { Debug.Log("Couldnt find the sound file!"); } return target.audioClip; }
public void PlaySound(SoundName soundName) { _view.PlaySound(soundName); }
//if soundName does not already exist, add it to dictionary //else do not add it! public void LoadSound(SoundName soundName, string soundPath) { Sound sound = new Sound(soundPath); if (!sounds.ContainsKey(soundName)) { sounds.Add(soundName, sound); } }
//public void PlaySound(SoundName soundName) //{ // if (sounds.ContainsKey(soundName)) // { // int index = GetAvailableSoundIndex(); // if (index != -1) // { // soundInstances[index] = sounds[soundName].Effect.CreateInstance(); // if (soundInstances[index].State != SoundState.Playing) // { // soundInstances[index].Play(); // } // } // } //} //Play soundName only if it exists in dictionary public void PlaySound(SoundName soundName) { if (sounds.ContainsKey(soundName)) { sounds[soundName].Play(); } }
public void PlaySound(SoundName soundName, bool bLoop) { if (sounds.ContainsKey(soundName)) { sounds[soundName].Loop = bLoop; sounds[soundName].Play(); } }
public void PlaySound(SoundName soundName, Vector3 position, bool bLoop) { if (sounds.ContainsKey(soundName)) { sounds[soundName].Position = position; sounds[soundName].Loop = bLoop; sounds[soundName].Apply3D(); sounds[soundName].Play(); } }
public void PlaySound(SoundName soundName) { }
public void PlaySound(SoundName soundName, bool bLoop, float fPitch, float fPan) { if (sounds.ContainsKey(soundName)) { sounds[soundName].Loop = bLoop; sounds[soundName].Pitch = fPitch; sounds[soundName].Pan = fPan; sounds[soundName].Play(); } }
public void PlaySound(SoundName soundName) { if (GetComponent<AudioSource>() == null) { Debug.Log("No audiosource is attached!"); return; } AudioClip clip = SoundRepository.Instance.Get(soundName); GetComponent<AudioSource>().clip = clip; GetComponent<AudioSource>().PlayDelayed(0.05f); }