void Update() { // Change sound presets if (Presets != lastPresets) { lastPresets = Presets; rainLoop = null; ApplyPresets(); StartWaiting(); } // Start rain loop if not running if ((Presets == AmbientSoundPresets.Rain || Presets == AmbientSoundPresets.Storm) && rainLoop == null) { rainLoop = dfAudioSource.GetAudioClip((int)SoundClips.AmbientRaining, false); dfAudioSource.AudioSource.clip = rainLoop; dfAudioSource.AudioSource.loop = true; dfAudioSource.AudioSource.Play(); } // Tick counter waitCounter += Time.deltaTime; if (waitCounter > waitTime) { PlayEffects(); StartWaiting(); } }
private void ApplyPresets() { switch (Presets) { case AmbientSoundPresets.Dungeon: // Set dungeon one-shots ambientSounds = new SoundClips[] { SoundClips.AmbientDripShort, SoundClips.AmbientDripLong, SoundClips.AmbientWindMoan, SoundClips.AmbientWindMoanDeep, SoundClips.AmbientDoorOpen, SoundClips.AmbientGrind, SoundClips.AmbientStrumming, SoundClips.AmbientWindBlow1, SoundClips.AmbientWindBlow1a, SoundClips.AmbientWindBlow1b, SoundClips.AmbientMonsterRoar, SoundClips.AmbientGoldPieces, SoundClips.AmbientBirdCall, SoundClips.AmbientDoorClose, }; AmbientInteriorPresets(); break; case AmbientSoundPresets.Storm: // Set storm one-shots ambientSounds = new SoundClips[] { SoundClips.StormLightningShort, SoundClips.StormLightningThunder, SoundClips.StormThunderRoll, }; AmbientExteriorPresets(); break; case AmbientSoundPresets.SunnyDay: ambientSounds = new SoundClips[] { SoundClips.BirdCall1, SoundClips.BirdCall2, }; AmbientExteriorPresets(); break; case AmbientSoundPresets.ClearNight: case AmbientSoundPresets.Rain: case AmbientSoundPresets.None: ambientSounds = null; break; } lastPresets = Presets; }
void Update() { // Change sound presets if (Presets != lastPresets) { // Clear settings lastPresets = Presets; rainLoop = null; cricketsLoop = null; // Stop playing any loops if (dfAudioSource.AudioSource.isPlaying) { dfAudioSource.AudioSource.Stop(); dfAudioSource.AudioSource.clip = null; dfAudioSource.AudioSource.loop = false; } ApplyPresets(); StartWaiting(); } // Start rain loop if not running if ((Presets == AmbientSoundPresets.Rain || Presets == AmbientSoundPresets.Storm) && rainLoop == null) { rainLoop = dfAudioSource.GetAudioClip((int)SoundClips.AmbientRaining); dfAudioSource.AudioSource.clip = rainLoop; dfAudioSource.AudioSource.loop = true; dfAudioSource.AudioSource.spatialBlend = 0; dfAudioSource.AudioSource.Play(); } // Start crickets loop if not running if ((Presets == AmbientSoundPresets.ClearNight) && cricketsLoop == null) { cricketsLoop = dfAudioSource.GetAudioClip((int)SoundClips.AmbientCrickets); dfAudioSource.AudioSource.clip = cricketsLoop; dfAudioSource.AudioSource.loop = true; dfAudioSource.AudioSource.spatialBlend = 0; dfAudioSource.AudioSource.Play(); } // Tick counter waitCounter += Time.deltaTime; if (waitCounter > waitTime) { PlayEffects(); StartWaiting(); } }
private void ApplyPresets() { if (Presets == AmbientSoundPresets.Dungeon) { // Set dungeon one-shots ambientSounds = new SoundClips[] { SoundClips.AmbientDripShort, SoundClips.AmbientDripLong, SoundClips.AmbientWindMoan, SoundClips.AmbientWindMoanDeep, SoundClips.AmbientDoorOpen, SoundClips.AmbientGrind, SoundClips.AmbientStrumming, SoundClips.AmbientWindBlow1, SoundClips.AmbientWindBlow1a, SoundClips.AmbientWindBlow1b, SoundClips.AmbientMonsterRoar, SoundClips.AmbientGoldPieces, SoundClips.AmbientBirdCall, SoundClips.AmbientDoorClose, }; AmbientInteriorPresets(); } else if (Presets == AmbientSoundPresets.Storm) { // Set storm one-shots ambientSounds = new SoundClips[] { SoundClips.StormLightningShort, SoundClips.StormLightningThunder, SoundClips.StormThunderRoll, }; AmbientExteriorPresets(); } else if (Presets == AmbientSoundPresets.SunnyDay) { ambientSounds = new SoundClips[] { SoundClips.BirdCall1, SoundClips.BirdCall2, }; AmbientExteriorPresets(); } else { ambientSounds = null; } lastPresets = Presets; }
private void ApplyPresets() { if (Presets == AmbientSoundPresets.Dungeon) { // Set dungeon one-shots ambientSounds = new SoundClips[] { SoundClips.AmbientDripShort, SoundClips.AmbientDripLong, SoundClips.AmbientWindMoan, SoundClips.AmbientWindMoanDeep, SoundClips.AmbientDoorOpen, SoundClips.AmbientGrind, SoundClips.AmbientStrumming, SoundClips.AmbientWindBlow1, SoundClips.AmbientWindBlow2, SoundClips.AmbientMetalJangleLow, SoundClips.AmbientBirdCall, SoundClips.AmbientSqueaks, SoundClips.AmbientClank, SoundClips.AmbientDistantMoan, }; } else if (Presets == AmbientSoundPresets.Storm) { // Set storm one-shots ambientSounds = new SoundClips[] { SoundClips.StormLightningShort, SoundClips.StormLightningThunder, SoundClips.StormThunderRoll, }; } else if (Presets == AmbientSoundPresets.SunnyDay) { ambientSounds = new SoundClips[] { SoundClips.BirdCall1, SoundClips.BirdCall2, }; } else { ambientSounds = null; } lastPresets = Presets; dfAudioSource.SetSound(-1, AudioPresets.OnDemand, 0); }
void Update() { // Change sound presets if (Presets != lastPresets) { // Clear settings lastPresets = Presets; rainLoop = null; cricketsLoop = null; // Stop playing any loops if (loopAudioSource.isPlaying) { loopAudioSource.Stop(); loopAudioSource.clip = null; loopAudioSource.loop = false; } ApplyPresets(); StartWaiting(); } // Start rain loop if not running if ((Presets == AmbientSoundPresets.Rain || Presets == AmbientSoundPresets.Storm) && rainLoop == null) { rainLoop = PlayLoop(SoundClips.AmbientRaining, 1f); } // Start crickets loop if not running if ((Presets == AmbientSoundPresets.ClearNight) && cricketsLoop == null) { cricketsLoop = PlayLoop(SoundClips.AmbientCrickets, 1f); } // Tick counters waitCounter += Time.deltaTime; waterWaitCounter += Time.deltaTime; if (waitCounter > waitTime) { PlayEffects(); StartWaiting(); } // Play water sound effects. Timing based on classic. if (waterWaitCounter > GameManager.classicUpdateInterval) { if (playerEnterExit && playerEnterExit.blockWaterLevel != 10000) { // Chance to play gentle water sound at water surface if (DFRandom.rand() < 50) { Vector3 waterSoundPosition = playerBehaviour.transform.position; waterSoundPosition.y = playerEnterExit.blockWaterLevel * -1 * MeshReader.GlobalScale; waterSoundPosition.x += Random.Range(-3f, 3f); waterSoundPosition.z += Random.Range(-3f, 3f); SpatializedPlayOneShot(SoundClips.WaterGentle, waterSoundPosition, 1f); } // Chance to play water bubbles sound if player is underwater if (playerEnterExit.IsPlayerSubmerged && DFRandom.rand() < 100) { AmbientPlayOneShot(SoundClips.AmbientWaterBubbles, 1f); } } waterWaitCounter = 0; } }
void Update() { // Change sound presets if (Presets != lastPresets) { // Clear settings lastPresets = Presets; rainLoop = null; cricketsLoop = null; // Stop playing any loops if (dfAudioSource.AudioSource.isPlaying) { dfAudioSource.AudioSource.Stop(); dfAudioSource.AudioSource.clip = null; dfAudioSource.AudioSource.loop = false; } ApplyPresets(); StartWaiting(); } // Start rain loop if not running if ((Presets == AmbientSoundPresets.Rain || Presets == AmbientSoundPresets.Storm) && rainLoop == null) { rainLoop = dfAudioSource.GetAudioClip((int)SoundClips.AmbientRaining); dfAudioSource.AudioSource.clip = rainLoop; dfAudioSource.AudioSource.loop = true; dfAudioSource.AudioSource.spatialBlend = 0; dfAudioSource.AudioSource.Play(); } // Start crickets loop if not running if ((Presets == AmbientSoundPresets.ClearNight) && cricketsLoop == null) { cricketsLoop = dfAudioSource.GetAudioClip((int)SoundClips.AmbientCrickets); dfAudioSource.AudioSource.clip = cricketsLoop; dfAudioSource.AudioSource.loop = true; dfAudioSource.AudioSource.spatialBlend = 0; dfAudioSource.AudioSource.Play(); } // Tick counters waitCounter += Time.deltaTime; waterWaitCounter += Time.deltaTime; if (waitCounter > waitTime) { PlayEffects(); StartWaiting(); } // Play water sound effects. Timing and position based on classic behavior. // TODO: Make sound follow player's X and Z movement but play from Y coordinate of dungeon water, for a more dynamically 3d sound. // Currently the sound is a volume adjustment based on vertical distance from the water. if (waterWaitCounter > waterSoundWaitTime) { if (playerEnterExit == null) { playerEnterExit = GameManager.Instance.PlayerEnterExit; } if (playerEnterExit) { if (playerEnterExit.blockWaterLevel != 10000) { Entity.DaggerfallEntityBehaviour player = GameManager.Instance.PlayerEntityBehaviour; // Chance to play gentle water sound based on vertical distance between player and water surface if (DFRandom.rand() < 50) { float waterHeightInDFUnityUnits = (playerEnterExit.blockWaterLevel * -1 * MeshReader.GlobalScale); float volumeScale = Mathf.Clamp(1 - (Mathf.Abs(player.transform.position.y - waterHeightInDFUnityUnits) / 9), 0, 1); dfAudioSource.PlayOneShot((int)SoundClips.WaterGentle, 0, volumeScale); } // Chance to play underwater bubbling noise if player is underwater if (playerEnterExit.IsPlayerSubmerged) { if (DFRandom.rand() < 100) { dfAudioSource.PlayOneShot((int)SoundClips.AmbientWaterBubbles, 0); } } } } waterWaitCounter = 0; } }
private void ApplyPresets() { if (Presets == AmbientSoundPresets.Dungeon) { // Set dungeon one-shots ambientSounds = new SoundClips[] { SoundClips.AmbientDripShort, SoundClips.AmbientDripLong, SoundClips.AmbientWindMoan, SoundClips.AmbientWindMoanDeep, SoundClips.AmbientDoorOpen, SoundClips.AmbientGrind, SoundClips.AmbientStrumming, SoundClips.AmbientWindBlow1, SoundClips.AmbientWindBlow2, SoundClips.AmbientMetalJangleLow, SoundClips.AmbientBirdCall, SoundClips.AmbientSqueaks, SoundClips.AmbientClank, SoundClips.AmbientDistantMoan, }; } else if (Presets == AmbientSoundPresets.Storm) { // Set storm one-shots ambientSounds = new SoundClips[] { SoundClips.StormLightningShort, SoundClips.StormLightningThunder, SoundClips.StormThunderRoll, }; } else { ambientSounds = null; } lastPresets = Presets; dfAudioSource.SetSound(0, AudioPresets.OnDemand, 0); }
void Update() { // Change sound presets if (Presets != lastPresets) { lastPresets = Presets; rainLoop = null; ApplyPresets(); StartWaiting(); } // Start rain loop if not running if ((Presets == AmbientSoundPresets.Rain || Presets == AmbientSoundPresets.Storm) && rainLoop == null) { rainLoop = dfAudioSource.GetAudioClip((int)SoundClips.AmbientRaining); dfAudioSource.AudioSource.clip = rainLoop; dfAudioSource.AudioSource.loop = true; dfAudioSource.AudioSource.spatialBlend = 0; dfAudioSource.AudioSource.Play(); } // Tick counter waitCounter += Time.deltaTime; if (waitCounter > waitTime) { PlayEffects(); StartWaiting(); } }
void Update() { // Change sound presets if (Presets != lastPresets) { // Clear settings lastPresets = Presets; rainLoop = null; cricketsLoop = null; // Stop playing any loops if (dfAudioSource.AudioSource.isPlaying) { dfAudioSource.AudioSource.Stop(); dfAudioSource.AudioSource.clip = null; dfAudioSource.AudioSource.loop = false; } ApplyPresets(); StartWaiting(); } // Update sound volume dfAudioSource.AudioSource.volume = DaggerfallUnity.Settings.SoundVolume; // Start rain loop if not running if ((Presets == AmbientSoundPresets.Rain || Presets == AmbientSoundPresets.Storm) && rainLoop == null) { rainLoop = dfAudioSource.GetAudioClip((int)SoundClips.AmbientRaining); dfAudioSource.AudioSource.clip = rainLoop; dfAudioSource.AudioSource.loop = true; dfAudioSource.AudioSource.spatialBlend = 0; dfAudioSource.AudioSource.Play(); } // Start crickets loop if not running if ((Presets == AmbientSoundPresets.ClearNight) && cricketsLoop == null) { cricketsLoop = dfAudioSource.GetAudioClip((int)SoundClips.AmbientCrickets); dfAudioSource.AudioSource.clip = cricketsLoop; dfAudioSource.AudioSource.loop = true; dfAudioSource.AudioSource.spatialBlend = 0; dfAudioSource.AudioSource.Play(); } // Tick counters waitCounter += Time.deltaTime; waterWaitCounter += Time.deltaTime; if (waitCounter > waitTime) { PlayEffects(); StartWaiting(); } // Play water sound effects. Timing based on classic. if (waterWaitCounter > Entity.PlayerEntity.ClassicUpdateInterval) { if (playerEnterExit && playerEnterExit.blockWaterLevel != 10000) { // Chance to play gentle water sound at water surface if (DFRandom.rand() < 50) { Vector3 waterSoundPosition = playerBehaviour.transform.position; waterSoundPosition.y = playerEnterExit.blockWaterLevel * -1 * MeshReader.GlobalScale; waterSoundPosition.x += Random.Range(-3, 3); waterSoundPosition.y += Random.Range(-3, 3); dfAudioSource.transform.position = waterSoundPosition; dfAudioSource.PlayOneShot((int)SoundClips.WaterGentle, 1, 3f); } // Chance to play water bubbles sound if player is underwater if (playerEnterExit.IsPlayerSubmerged && DFRandom.rand() < 100) { dfAudioSource.PlayOneShot((int)SoundClips.AmbientWaterBubbles, 0); } } waterWaitCounter = 0; } }