Example #1
0
        public void PlaySoundWithDistance(int index, float volume, float distanceFactor = 0.0f)
        {
            if (!_canReproduceAudio)
            {
                return;
            }

            if (volume < -1 || volume > 1f)
            {
                return;
            }

            if (ProfileManager.Current == null || !ProfileManager.Current.EnableSound || !Client.Game.IsActive && !ProfileManager.Current.ReproduceSoundsInBackground)
            {
                volume = 0;
            }

            UOSound sound = (UOSound)SoundsLoader.Instance.GetSound(index);

            if (sound != null)
            {
                sound.Play(true, AudioEffects.None, volume, distanceFactor);

                _current_sounds.AddLast(sound);
            }
        }
Example #2
0
        public void PlaySoundWithDistance(int index, int x, int y)
        {
            if (!_canReproduceAudio || !World.InGame)
            {
                return;
            }

            int distX    = Math.Abs(x - World.Player.X);
            int distY    = Math.Abs(y - World.Player.Y);
            int distance = Math.Max(distX, distY);

            Profile currentProfile = ProfileManager.CurrentProfile;
            float   volume         = currentProfile.SoundVolume / Constants.SOUND_DELTA;
            float   distanceFactor = 0.0f;

            if (distance >= 1)
            {
                float volumeByDist = volume / (World.ClientViewRange + 1);
                distanceFactor = volumeByDist * distance;
            }

            if (distance > World.ClientViewRange)
            {
                volume = 0;
            }

            if (volume < -1 || volume > 1f)
            {
                return;
            }

            if (currentProfile == null || !currentProfile.EnableSound ||
                !Client.Game.IsActive && !currentProfile.ReproduceSoundsInBackground)
            {
                volume = 0;
            }

            UOSound sound = (UOSound)SoundsLoader.Instance.GetSound(index);

            if (sound != null && sound.Play(volume, distanceFactor))
            {
                sound.X = x;
                sound.Y = y;
                sound.CalculateByDistance = true;

                _currentSounds.AddLast(sound);
            }
        }
Example #3
0
        public void PlaySound(int index)
        {
            Profile currentProfile = ProfileManager.CurrentProfile;

            if (!_canReproduceAudio || currentProfile == null)
            {
                return;
            }

            float volume = currentProfile.SoundVolume / Constants.SOUND_DELTA;

            if (Client.Game.IsActive)
            {
                if (!currentProfile.ReproduceSoundsInBackground)
                {
                    volume = currentProfile.SoundVolume / Constants.SOUND_DELTA;
                }
            }
            else if (!currentProfile.ReproduceSoundsInBackground)
            {
                volume = 0;
            }

            if (volume < -1 || volume > 1f)
            {
                return;
            }

            if (!currentProfile.EnableSound ||
                !Client.Game.IsActive && !currentProfile.ReproduceSoundsInBackground)
            {
                volume = 0;
            }

            UOSound sound = (UOSound)SoundsLoader.Instance.GetSound(index);

            if (sound != null && sound.Play(volume))
            {
                sound.X = -1;
                sound.Y = -1;
                sound.CalculateByDistance = false;

                _currentSounds.AddLast(sound);
            }
        }
Example #4
0
        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);
            }
        }