/// <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; } } }
/// <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; } } }
/// <summary> /// Returns a volume value to use for this channel. /// </summary> public float GetVolume() { if (useRandomVolume) { return(randomVolumeRange.GetRandomValue()); } else { return(uniformVolume); } }
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())); } }
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); }
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; } }