public void PlaySound(int index, AudioEffects effect = AudioEffects.None, bool spamCheck = false) { if (Engine.Profile == null || Engine.Profile.Current == null || !Engine.Profile.Current.EnableSound) { return; } float volume = (Engine.Profile.Current.SoundVolume / SOUND_DELTA); if (Engine.Instance.IsActive) { if (!Engine.Profile.Current.ReproduceSoundsInBackground) { volume = Engine.Profile.Current.SoundVolume / SOUND_DELTA; } } else if (!Engine.Profile.Current.ReproduceSoundsInBackground) { volume = 0; } if (volume < -1 || volume > 1f) { return; } FileManager.Sounds.GetSound(index)?.Play(true, effect, volume, spamCheck); }
public void PlaySound(int soundIndex, AudioEffects effect = AudioEffects.None, float volume = 1.0f, bool spamCheck = false) { if (volume < 0.01f) { return; } if (UltimaGameSettings.Audio.SoundOn) { ASound sound; if (_sounds.TryGetValue(soundIndex, out sound)) { sound.Play(true, effect, volume, spamCheck); } else { string name; byte[] data; if (SoundData.TryGetSoundData(soundIndex, out data, out name)) { sound = new UOSound(name, data); _sounds.Add(soundIndex, sound); sound.Play(true, effect, volume, spamCheck); } } } }
// Plays music for the 'level' level public void PlayLevelMusic(string level) { // Get what music to play for this level string levelMusic = GetLevelMusic(level); // Do a bunch of checks that currently playing music and the music you want to play // exist. And that they are not the same (to prevent song restart on restart of the room) if (musicDict.ContainsKey(levelMusic) && musicDict.ContainsKey(currentLevelMusicName) && (!musicDict[currentLevelMusicName].isPlaying || currentLevelMusicName != levelMusic)) { // Stop previously playing music if (currentLevelMusicName != levelMusic) { musicDict[currentLevelMusicName].Stop(); currentLevelMusicName = levelMusic; } // Play new music StopAllCoroutines(); StartCoroutine(AudioEffects.Fade( musicDict[currentLevelMusicName], 0.0f, _musicVolume, 0.5f) ); } }
/// <summary> /// Plays the effect. /// </summary> /// <param name="asEffect">Set to false for music, true for sound effects.</param> public void Play(bool asEffect, AudioEffects effect = AudioEffects.None, float volume = 1.0f) { double now = UltimaGame.TotalMS; CullExpiredEffects(now); m_ThisInstance = GetNewInstance(asEffect); if (m_ThisInstance == null) { this.Dispose(); return; } switch (effect) { case AudioEffects.PitchVariation: float pitch = (float)Utility.RandomValue(-5, 5) * .025f; m_ThisInstance.Pitch = pitch; break; } BeforePlay(); byte[] buffer = GetBuffer(); if (buffer != null && buffer.Length > 0) { m_ThisInstance.BufferNeeded += new EventHandler<EventArgs>(OnBufferNeeded); m_ThisInstance.SubmitBuffer(buffer); m_ThisInstance.Volume = volume; m_ThisInstance.Play(); List<Tuple<DynamicSoundEffectInstance, double>> list = (asEffect) ? m_EffectInstances : m_MusicInstances; double ms = m_ThisInstance.GetSampleDuration(buffer.Length).TotalMilliseconds; list.Add(new Tuple<DynamicSoundEffectInstance, double>(m_ThisInstance, now + ms)); } }
static void RegisterAudioClip(AudioEffects Effect, AudioClip Clip) { if (!AudioClips.ContainsKey(Effect)) { AudioClips.Add(Effect, new AudioClipSet()); } AudioClips[Effect].Add(Clip); }
public void playAudio(AudioEffects audioEffect) { var audioClip = audios.Find(audio => Equals(audio.audioEffect, audioEffect)).audioClip; if (audioClip != null) { audioSource.PlayOneShot(audioClip); } }
public void PlayClip(AudioEffects effect) { if (GameObject.Find(effect.ToString()) != null || PlayerPrefs.GetInt("AudioOn") == 0) return; GameObject clip = new GameObject(effect.ToString()); AudioSource audioS = clip.AddComponent<AudioSource>(); audioS.PlayOneShot(audioClips[(int)effect]); Destroy(clip, audioClips[(int)effect].length); }
void PlaySoundEffect(int strength, string type) { AudioEffects audioEffects = Camera.main.gameObject.GetComponent <AudioEffects>(); if (audioEffects != null) { audioEffects.PlaySoundEffect(strength, type); } }
public void Reset() { GameManager.isPlaying = false; instructions.SetActive(true); textBox.SetActive(false); StartCoroutine(AudioEffects.FadeOut(bgm, 2f)); silvio.Reset(); pm.Reset(); dm.Reset(); }
public static void PlaySfx(AudioEffects Effect) { if (!AudioClips.ContainsKey(Effect)) { Debug.LogWarning("Sfx not found " + Effect); return; } PlaySfx(AudioClips[Effect].GetRandom()); }
public void playWinMusic() { AudioSource audio = ((GameObject)sounds["winMusic"]).GetComponent <AudioSource>(); if (audio != current_background && audio != null) { StartCoroutine(AudioEffects.fadeOut(current_background, 5.0f)); StartCoroutine(AudioEffects.fadeIn(audio, 5.0f)); current_background = audio; } }
private void Start() { if (_audioEffects == null) { _audioEffects = this; _audioSource = GetComponent <AudioSource>(); } else if (_audioEffects != this) { Destroy(this); } }
public void StartGame() { if (pm.PlayerListIsEmpty()) { return; } instructions.SetActive(false); isPlaying = true; StartCoroutine(AudioEffects.FadeIn(bgm, 0.5f, 0.3f)); silvio.StartInitialDialog(); }
// Fadeout currently playing level music public void FadeOutLevelMusic() { if (musicDict.ContainsKey(currentLevelMusicName)) { StopAllCoroutines(); StartCoroutine(AudioEffects.Fade( musicDict[currentLevelMusicName], musicDict[currentLevelMusicName].volume, 0.0f, 0.5f) ); } }
private void Awake() { AudioPlayer = GetComponent <AudioEffects>(); m_Rigidbody2D = GetComponent <Rigidbody2D>(); if (OnLandEvent == null) { OnLandEvent = new UnityEvent(); } if (OnCrouchEvent == null) { OnCrouchEvent = new BoolEvent(); } }
public void PlaySound(int index, AudioEffects effect = AudioEffects.None, bool spamCheck = false) { if (Engine.Profile == null || Engine.Profile.Current == null || !Engine.Profile.Current.EnableSound) { return; } float volume = (Engine.Profile.Current.SoundVolume / SOUND_DELTA); if (volume < -1 || volume > 1f) { return; } FileManager.Sounds.GetSound(index)?.Play(true, effect, volume, spamCheck); }
/// <summary> /// Plays the effect. /// </summary> /// <param name="asEffect">Set to false for music, true for sound effects.</param> public void Play(bool asEffect, AudioEffects effect = AudioEffects.None, float volume = 1.0f, bool spamCheck = false) { double now = UltimaGame.TotalMS; CullExpiredEffects(now); if (spamCheck && (LastPlayed + MinimumDelay > DateTime.Now)) { return; } m_ThisInstance = GetNewInstance(asEffect); if (m_ThisInstance == null) { Dispose(); return; } switch (effect) { case AudioEffects.PitchVariation: float pitch = Utility.RandomValue(-5, 5) * .025f; m_ThisInstance.Pitch = pitch; break; } BeforePlay(); LastPlayed = DateTime.Now; byte[] buffer = GetBuffer(); if (buffer != null && buffer.Length > 0) { m_ThisInstance.BufferNeeded += OnBufferNeeded; m_ThisInstance.SubmitBuffer(buffer); m_ThisInstance.Volume = volume; m_ThisInstance.Play(); List <Tuple <DynamicSoundEffectInstance, double> > list = (asEffect) ? m_EffectInstances : m_MusicInstances; double ms = m_ThisInstance.GetSampleDuration(buffer.Length).TotalMilliseconds; list.Add(new Tuple <DynamicSoundEffectInstance, double>(m_ThisInstance, now + ms)); } }
public void activatePowerUp(string type) { // play a sound effect AudioEffects.play("powerup"); // Only add a certain powerup once if (isPowerUpOn(type)) { return; } if (type == "KillIrishCoffee") { removePowerUp("IrishCoffee"); } else { powerUps.Add(type); } }
private void manageEffects(AudioEffects eff) { bool found = false; for (int i = 0; i < Configer.Effects.Count; i++) { if (Configer.Effects[i] == eff) { found = true; break; } } if (found) { Configer.Effects.Remove(eff); } else { Configer.Effects.Add(eff); } }
public void PlaySound(int index, AudioEffects effect = AudioEffects.None) { if (!_canReproduceAudio) { return; } if (ProfileManager.Current == null || !ProfileManager.Current.EnableSound) { return; } float volume = ProfileManager.Current.SoundVolume / Constants.SOUND_DELTA; if (CUOEnviroment.Client.IsActive) { if (!ProfileManager.Current.ReproduceSoundsInBackground) { volume = ProfileManager.Current.SoundVolume / Constants.SOUND_DELTA; } } else if (!ProfileManager.Current.ReproduceSoundsInBackground) { volume = 0; } if (volume < -1 || volume > 1f) { return; } UOSound sound = (UOSound)UOFileManager.Sounds.GetSound(index); if (sound != null) { sound.Play(true, effect, volume, 0.0f); _currentSounds.Add(sound); } }
public void PlaySound(int soundIndex, AudioEffects effect = AudioEffects.None, float volume = 1.0f) { if (Settings.Audio.SoundOn) { ASound sound; if (m_Sounds.TryGetValue(soundIndex, out sound)) { sound.Play(true, effect, volume); } else { string name; byte[] data; if (SoundData.TryGetSoundData(soundIndex, out data, out name)) { sound = new UOSound(name, data); m_Sounds.Add(soundIndex, sound); sound.Play(true, effect, volume); } } } }
/// <summary> /// Plays the effect. /// </summary> /// <param name="asEffect">Set to false for music, true for sound effects.</param> public void Play(bool asEffect, AudioEffects effect = AudioEffects.None, float volume = 1.0f, bool spamCheck = false) { //double now = (float)Service.Get<UltimaGame>().TotalMS; //CullExpiredEffects(now); //if (spamCheck && (LastPlayed + MinimumDelay > DateTime.Now)) // return; //BeforePlay(); //_thisInstance = GetNewInstance(asEffect); //if (_thisInstance == null) //{ // Dispose(); // return; //} //switch (effect) //{ // case AudioEffects.PitchVariation: // float pitch = Utility.RandomValue(-5, 5) * .025f; // _thisInstance.Pitch = pitch; // break; //} //LastPlayed = DateTime.Now; //byte[] buffer = GetBuffer(); //if (buffer != null && buffer.Length > 0) //{ // _thisInstance.BufferNeeded += OnBufferNeeded; // _thisInstance.SubmitBuffer(buffer); // _thisInstance.Volume = volume; // _thisInstance.Play(); // List<Tuple<DynamicSoundEffectInstance, double>> list = (asEffect) ? _effectInstances : _musicInstances; // double ms = _thisInstance.GetSampleDuration(buffer.Length).TotalMilliseconds; // list.Add(new Tuple<DynamicSoundEffectInstance, double>(_thisInstance, now + ms)); //} }
public void PlaySound(int index, AudioEffects effect = AudioEffects.None) { if (!_canReproduceAudio) { return; } float volume = ProfileManager.Current.SoundVolume / Constants.SOUND_DELTA; if (Client.Game.IsActive) { if (!ProfileManager.Current.ReproduceSoundsInBackground) { volume = ProfileManager.Current.SoundVolume / Constants.SOUND_DELTA; } } else if (!ProfileManager.Current.ReproduceSoundsInBackground) { volume = 0; } PlaySoundWithDistance(index, volume); }
// Use this for initialization void Start() { audioEffects = Camera.main.gameObject.GetComponent <AudioEffects>(); }
public void PlaySound(int soundIndex, AudioEffects effect = AudioEffects.None, float volume = 1.0f, bool spamCheck = false) { }
/** * @params * - deltaX = 0..1 * - deltaY = 0..1 * * Required that deltaX^2 + deltaY^2 <= 1 */ public void move(float deltaX, float deltaY) { { // Some magic code... float tempX = Mathf.Sqrt(Mathf.Abs(deltaX)); float tempY = Mathf.Sqrt(Mathf.Abs(deltaY)); if (deltaX < 0) { deltaX = tempX * (-1); } else { deltaX = tempX; } if (deltaY < 0) { deltaY = tempY * (-1); } else { deltaY = tempY; } } if (powerUpStateHandler.isPowerUpOn("IrishCoffee")) { // Don't allow player controls because the player might end up in wrong places return; } deltaMove = new Vector3(0, 0, 0); if (isOnGround() || doubleJumpActive()) { // Player is on the ground. Normal controls deltaMove.x = deltaX * multiplierX * maxSpeedX; deltaMove.y = deltaY * multiplierY * maxSpeedY; // If the player wants to jump to complete new direction, // then make it easier /*if ( Mathf.Abs(deltaY) > 0.001 && wantsToChangeDirection() ) { * player.velocity = new Vector3(0, player.velocity.y, 0); * }*/ if (deltaMove.y > 0) { AudioEffects.play("jump"); } else { AudioEffects.play("move"); } } else if (isTryingToReduceSpeed(deltaX)) { deltaMove.x = deltaX * airMovementFactor * multiplierX * maxSpeedX; } checkMovementBoundaries(); // To normalize with time player.AddForce(deltaMove); }