private void OnTriggerExit(Collider other) { if (!WeatherMakerScript.IsLocalPlayer(other.transform)) { return; } StopSounds(); soundZoneStack.Remove(this); // the next item on the stack can play if (soundZoneStack.Count != 0) { int index = soundZoneStack.Count - 1; WeatherMakerSoundZoneScript script = soundZoneStack[index]; if (script == null) { soundZoneStack.RemoveAt(index); } else { script.StartSounds(); } } }
/// <summary> /// Sound manager weather profile change handler /// </summary> /// <param name="oldProfile">Old profile</param> /// <param name="newProfile">New profile</param> /// <param name="transitionDelay">Transition delay</param> /// <param name="transitionDuration">Transition duration</param> public void WeatherProfileChanged(WeatherMakerProfileScript oldProfile, WeatherMakerProfileScript newProfile, float transitionDelay, float transitionDuration) { // override sound zones if (WeatherProfileSoundFadeOutMultiplier > 0.0f) { foreach (Camera camera in Camera.allCameras) { if (WeatherMakerScript.IsLocalPlayer(camera.transform)) { WeatherMakerSoundZoneScript soundZone = camera.GetComponentInChildren <WeatherMakerSoundZoneScript>(); if (soundZone != null && soundZone.enabled) { float stopSeconds = transitionDuration * WeatherProfileSoundFadeOutMultiplier; soundZone.StopSounds(stopSeconds, true); // add new sounds if (newProfile.SoundProfile != null) { foreach (WeatherMakerSoundGroupScript soundScript in newProfile.SoundProfile.Sounds) { soundZone.AddSound(soundScript, true); } } } } } } }
private void UpdateWeatherProfile() { if (_WeatherProfile == null || _WeatherProfile.Disabled) { return; } float transitionDuration = _WeatherProfile.TransitionDuration.Random(); CloudChangeDuration = transitionDuration; Clouds = _WeatherProfile.CloudType; if (CloudScript != null) { Vector2 newCloudVelocity = UnityEngine.Random.insideUnitCircle * _WeatherProfile.CloudSpeed.Random(); TweenFactory.Tween("WeatherMakerScriptProfileChangeCloudVelocity", CloudScript.CloudNoiseVelocity, newCloudVelocity, transitionDuration, TweenScaleFunctions.Linear, (progress) => { CloudScript.CloudNoiseVelocity = progress.CurrentValue; }); } Precipitation = _WeatherProfile.Precipitation; PrecipitationIntensity = _WeatherProfile.PrecipitationIntensity; PrecipitationChangeDuration = transitionDuration * 0.5f; if (Clouds == WeatherMakerCloudType.None) { PrecipitationChangeDelay = 0.0f; } else { PrecipitationChangeDelay = transitionDuration * 0.5f; } if (FogScript != null) { FogScript.FogMode = WeatherMakerFogMode.Linear; FogScript.TransitionFogDensity(FogScript.FogDensity, _WeatherProfile.FogDensity, CloudChangeDuration); FogScript.FogHeight = _WeatherProfile.FogHeight; } if (WindScript != null) { WindScript.AnimateWindIntensity(_WeatherProfile.WindIntensity, transitionDuration); WindScript.WindMaximumChangeRotation = _WeatherProfile.WindMaximumChangeRotation; WindScript.WindMainMultiplier = _WeatherProfile.WindMainMultiplier; } if (LightningScript != null) { FloatTween t = TweenFactory.Tween("WeatherMakerScriptProfileChangeLightning", 0.0f, 0.0f, 0.01f, TweenScaleFunctions.Linear, null, (completion) => { LightningScript.LightningIntenseProbability = _WeatherProfile.LightningIntenseProbability; LightningScript.LightningIntervalTimeRange = _WeatherProfile.LightningIntervalTimeRange; LightningScript.LightningForcedVisibilityProbability = _WeatherProfile.LightningForcedVisibilityProbability; LightningScript.GroundLightningChance = _WeatherProfile.LightningGroundChance; LightningScript.CloudLightningChance = _WeatherProfile.LightningCloudChance; LightningScript.EnableLightning = _WeatherProfile.LightningEnabled; }); t.Delay = PrecipitationChangeDelay; } GameObject player = GameObject.FindGameObjectWithTag("Player"); if (player != null) { WeatherMakerSoundZoneScript soundZone = player.GetComponent <WeatherMakerSoundZoneScript>(); if (soundZone != null) { soundZone.Sounds.Clear(); soundZone.Sounds.AddRange(_WeatherProfile.Sounds); } } }