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

                createRandomSound(soundscape);
            }
        }
Esempio n. 2
0
        public void BeginDream(Dream dream)
        {
            _forcedSpawnID = null;
            _canTransition = true;

            // start a timer to end the dream
            float secondsInDream = RandUtil.Float(MIN_SECONDS_IN_DREAM, MAX_SECONDS_IN_DREAM);

            _endDreamTimer = Coroutines.Instance.StartCoroutine(EndDreamAfterSeconds(secondsInDream));

            ToriiFader.Instance.FadeIn(Color.black, 3, () => Coroutines.Instance.StartCoroutine(LoadDream(dream)));
            CurrentSequence = new DreamSequence();
            CurrentSequence.Visited.Add(dream);
        }
 public IEnumerator RollForGreyman()
 {
     _hasSpawnedGreyman = false;
     while (true)
     {
         if (RandUtil.OneIn(CHANCE_FOR_GREYMAN) && !_hasSpawnedGreyman)
         {
             Spawn();
             _hasSpawnedGreyman = true;
         }
         yield return(new WaitForSeconds(RandUtil.Float(MIN_WAIT_BETWEEN_SPAWN_CHANCES_SECONDS,
                                                        MAX_WAIT_BETWEEN_SPAWN_CHANCES_SECONDS)));
     }
     // ReSharper disable once IteratorNeverReturns
 }
Esempio n. 4
0
        private IEnumerator RollForGreyman()
        {
            while (true)
            {
                if (DreamDirector.CanSpawnGreyman)
                {
                    int chance = RandUtil.Int(GameSettings.CHANCE_FOR_GREYMAN);

                    Debug.Log(chance);
                    if (chance == 0)
                    {
                        SpawnGreyman();
                    }
                }

                yield return(new WaitForSeconds(RandUtil.Float(_minWaitTime, _maxWaitTime)));
            }
        }
        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));
        }