private IEnumerator playRandomSounds(Soundscape soundscape)
        {
            while (true)
            {
                float nextInterval = RandUtil.Float(soundscape.MinSoundInterval, soundscape.MaxSoundInterval);
                yield return(new WaitForSeconds(nextInterval));

                createRandomSound(soundscape);
            }
        }
        public void PlaySoundscape(Soundscape soundscape)
        {
            if (CurrentSoundscape == soundscape)
            {
                return;
            }

            if (CurrentSoundscape != null)
            {
                destroyCurrentSoundscape();
            }

            beginSoundscape(soundscape);
        }
        private void beginSoundscape(Soundscape soundscape)
        {
            CurrentSoundscape = soundscape;

            foreach (var baseSound in soundscape.BaseSounds)
            {
                var source = createBaseSoundPlayer(baseSound);
                _baseSoundPlayers.Add(source);
                StartCoroutine(fadeInClip(source));
            }

            if (soundscape.Sounds.Count > 0)
            {
                _playRandomSoundsCoroutine = StartCoroutine(playRandomSounds(soundscape));
            }
        }
        private void createRandomSound(Soundscape soundscape)
        {
            var randomSound = RandUtil.RandomListElement(soundscape.Sounds);
            var source      = createSourceObject();

            source.clip                  = randomSound.Sound;
            source.spatialBlend          = 1;
            source.loop                  = false;
            source.outputAudioMixerGroup = _mixerGroup;
            source.rolloffMode           = AudioRolloffMode.Linear;

            var angle    = RandUtil.Float(randomSound.MinAngle, randomSound.MaxAngle);
            var distance = RandUtil.Float(randomSound.MinDistance, randomSound.MaxDistance);

            Transform baseTransform = Centre == null ? transform : Centre.transform;

            Vector3 soundPos = baseTransform.position +
                               (Quaternion.AngleAxis(angle, Vector3.up) * baseTransform.forward * distance);

            source.transform.position = soundPos;
            StartCoroutine(playSoundThenDestroy(source));
        }