Beispiel #1
0
        public void PlaySound(CharacterSound.SoundType soundType)
        {
            if (sounds == null || sounds.Count == 0)
            {
                return;
            }
            if (soundChannel != null && soundChannel.IsPlaying)
            {
                return;
            }

            var matchingSounds = sounds.Where(s =>
                                              s.Type == soundType &&
                                              (s.Gender == Gender.None || (info != null && info.Gender == s.Gender)));

            if (!matchingSounds.Any())
            {
                return;
            }

            var matchingSoundsList = matchingSounds.ToList();
            var selectedSound      = matchingSoundsList[Rand.Int(matchingSoundsList.Count)];

            soundChannel = SoundPlayer.PlaySound(selectedSound.Sound, selectedSound.Volume, selectedSound.Range, AnimController.WorldPosition, CurrentHull);
            soundTimer   = soundInterval;
        }
Beispiel #2
0
        public void PlaySound(CharacterSound.SoundType soundType)
        {
            if (sounds == null || sounds.Count == 0)
            {
                return;
            }

            var matchingSounds = sounds.FindAll(s => s.Type == soundType);

            if (matchingSounds.Count == 0)
            {
                return;
            }

            var selectedSound = matchingSounds[Rand.Int(matchingSounds.Count)];

            selectedSound.Sound.Play(1.0f, selectedSound.Range, AnimController.WorldPosition);
        }