コード例 #1
0
        /// <summary>
        /// Plays this AudioElement.
        /// </summary>
        public void Play(bool loop = false)
        {
            playing      = true;
            playbackTime = 0f;
            if (loop && randomPitch && changePitchEachLoop)
            {
                pitch = pitchRange.GetRandomValue();
            }
            else
            {
                pitch = randomPitch ? pitchRange.GetRandomValue() : pitch;
            }

            audioSource.pitch = pitch;

            longestClipLength = 0f;
            foreach (AudioChannel channel in channels)
            {
                float clipLength;
                PlayChannel(channel, out clipLength);
                if (clipLength > longestClipLength)
                {
                    longestClipLength = channel.ClipLength;
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Main facial expression coroutine.
        /// </summary>
        IEnumerator FaceCoroutine()
        {
            while (true)
            {
                switch (emotion)
                {
                case Emotion.Idle:
                    yield return(new WaitForSeconds(blinkFrequency.GetRandomValue()));

                    yield return(Blink());

                    break;

                case Emotion.Happy:
                    yield return(null);

                    break;

                case Emotion.Angry:
                    yield return(null);

                    break;
                }
            }
        }
コード例 #3
0
 /// <summary>
 /// Returns a volume value to use for this channel.
 /// </summary>
 public float GetVolume()
 {
     if (useRandomVolume)
     {
         return(randomVolumeRange.GetRandomValue());
     }
     else
     {
         return(uniformVolume);
     }
 }
コード例 #4
0
 public IEnumerator <float> IERunSpawnSequence(System.Func <int> onSpawn)
 {
     Reset();
     while (true)
     {
         spawnedHashCodes.Add(onSpawn());
         remainingSpawns--;
         if (remainingSpawns <= 0)
         {
             break;
         }
         yield return(Timing.WaitForSeconds(SpawningTime.GetRandomValue()));
     }
 }
コード例 #5
0
    private GameObject GetGeyser()
    {
        GameObject projectile = ObjectPool.Instance.GetObject(PoolObjectType.GeyserFissure);

        if (projectile)
        {
            projectile.transform.position = transform.position + transform.forward * geyserStartDistanceOffset;
            projectile.transform.forward  = transform.forward;
            projectile.transform.rotation = Quaternion.Euler(0f, projectile.transform.rotation.eulerAngles.y, 0f);


            projectile.GetComponent <GeyserFissure>().Initialize(fissureSpeed, damage, fissureLiveTime);

            fishEmitter.SetBaseEmissionSpeed(fishLaunchSpeed.GetRandomValue());
            fishEmitter.Play();
        }

        animator.SetTrigger("Shoot");
        return(projectile);
    }
コード例 #6
0
        private void SpawnIn(GameWorld world, Vector2 slideDirection)
        {
            Vector2 wabbleDirection = slideDirection.Perpendicular;

            float  length    = ((BlubSize.Maximum * 2.0f) + BlubGap.Maximum) * enemyCount;
            Point2 worldSize = world.Scene.HalfSize;

            Vector2 position = (wabbleDirection * worldSize) * 0.95f + slideDirection * new Vector2(
                rand.RandomRange(BlubSize.Maximum, worldSize.X - length),
                rand.RandomRange(BlubSize.Maximum, worldSize.Y - length)
                );

            for (int i = 0; i < enemyCount; ++i)
            {
                float radius = BlubSize.GetRandomValue(this.rand);
                this.SpawnBlub(position, radius, world);

                float positionOffset = (2 * radius) + BlubGap.GetRandomValue(this.rand);
                position += slideDirection * positionOffset;
            }
        }