Exemple #1
0
        public void WeatherProfileChanged(WeatherMakerProfileScript oldProfile, WeatherMakerProfileScript newProfile, float transitionDelay, float transitionDuration)
        {
            Precipitation               = newProfile.PrecipitationProfile.PrecipitationType;
            PrecipitationChangeDelay    = transitionDelay;
            PrecipitationChangeDuration = transitionDuration;
            PrecipitationIntensity      = newProfile.PrecipitationProfile.IntensityRange.Random();
            nextIntensityChangeSeconds  = (newProfile.PrecipitationProfile.IntensityRangeDuration.Maximum <= 0.0f ? 0.0f : newProfile.PrecipitationProfile.IntensityRangeDuration.Random());
            nextIntensityChangeRange    = newProfile.PrecipitationProfile.IntensityRange;
            nextIntensityDurationRange  = newProfile.PrecipitationProfile.IntensityRangeDuration;
            Color      oldPrecipitationTintColor          = precipitationTintColor;
            Color      oldPrecipitationMistTintColor      = precipitationMistTintColor;
            Color      oldPecipitationSecondaryTintColor  = precipitationSecondaryTintColor;
            Color      newPrecipitationTintColor          = newProfile.PrecipitationProfile.PrecipitationTintColor;
            Color      newPrecipitationMistTintColor      = newProfile.PrecipitationProfile.PrecipitationMistTintColor;
            Color      newPrecipitationSecondaryTintColor = newProfile.PrecipitationProfile.PrecipitationSecondaryTintColor;
            FloatTween tween = TweenFactory.Tween("WeatherMakerPrecipitation_" + GetInstanceID(), 0.0f, 1.0f, transitionDuration, TweenScaleFunctions.Linear, (ITween <float> c) =>
            {
                float progress                  = c.CurrentValue;
                precipitationTintColor          = Color.Lerp(oldPrecipitationTintColor, newPrecipitationTintColor, progress);
                precipitationMistTintColor      = Color.Lerp(oldPrecipitationMistTintColor, newPrecipitationMistTintColor, progress);
                precipitationSecondaryTintColor = Color.Lerp(oldPecipitationSecondaryTintColor, newPrecipitationSecondaryTintColor, progress);
            });

            tween.Delay = transitionDelay;
        }
 private void OnTriggerEnter(Collider other)
 {
     if (gameObject.activeInHierarchy && enabled && WeatherMakerScript.IsLocalPlayer(other.transform) && ++triggers == 1)
     {
         // if this is the first trigger entered, run it
         TweenFactory.Tween("WeatherMakerDampeningZoneScript", 0.0f, 1.0f, TransitionDuration, TweenScaleFunctions.Linear, (t) =>
         {
             if (WeatherMakerAudioManagerScript.Instance != null)
             {
                 float currentValue;
                 if (!WeatherMakerAudioManagerScript.Instance.VolumeModifierDictionary.TryGetValue("WeatherMakerDampeningZoneScript", out currentValue))
                 {
                     currentValue = 1.0f;
                 }
                 WeatherMakerAudioManagerScript.Instance.VolumeModifierDictionary["WeatherMakerDampeningZoneScript"] = Mathf.Lerp(currentValue, SoundDampening, t.CurrentValue);
             }
             if (WeatherMakerScript.Instance != null)
             {
                 float currentValue;
                 if (!WeatherMakerScript.Instance.IntensityModifierDictionary.TryGetValue("WeatherMakerDampeningZoneScript", out currentValue))
                 {
                     currentValue = 1.0f;
                 }
                 WeatherMakerScript.Instance.IntensityModifierDictionary["WeatherMakerDampeningZoneScript"] = Mathf.Lerp(currentValue, IntensityDampening, t.CurrentValue);
             }
             if (WeatherMakerThunderAndLightningScript.Instance != null)
             {
                 WeatherMakerThunderAndLightningScript.Instance.LightningBoltScript.LightParameters.LightIntensityMultiplier =
                     Mathf.Lerp(WeatherMakerThunderAndLightningScript.Instance.LightningBoltScript.LightParameters.LightIntensityMultiplier, LightDampening, t.CurrentValue);
             }
         });
     }
 }
Exemple #3
0
        /// <summary>
        /// Show cloud animated
        /// </summary>
        /// <param name="duration">How long until clouds fully transition to the parameters</param>
        /// <param name="cover">Cloud cover, 0 to 1</param>
        /// <param name="density">Cloud density, 0 to 1</param>
        /// <param name="whispiness">Cloud whispiness, 0 to 3</param>
        /// <param name="sharpness">Cloud sharpness, controls fade, 0 to 1</param>
        /// <param name="lightAbsorption">Cloud light absoprtion, 0 to 1, higher values absorb less</param>
        /// <param name="color">Cloud color, if null defaults to CloudColor</param>
        public void ShowCloudsAnimated(float duration, float cover, float density = -1.0f, float whispiness = -1.0f, float sharpness = -1.0f, float lightAbsorption = -1.0f, Color?color = null)
        {
            float startCover           = CloudCover;
            float startDensity         = CloudDensity;
            float startWhispiness      = CloudWhispiness;
            float startSharpness       = CloudSharpness;
            float startLightAbsorption = CloudLightAbsorption;
            Color startColor           = CloudColor;

            color           = color ?? CloudColor;
            density         = (density < 0.0f ? CloudDensity : density);
            whispiness      = (whispiness < 0.0f ? CloudWhispiness : whispiness);
            sharpness       = (sharpness < 0.0f ? CloudSharpness : sharpness);
            lightAbsorption = (lightAbsorption < 0.0f ? CloudLightAbsorption : lightAbsorption);
            TweenFactory.Tween("WeatherMakerClouds", 0.0f, 1.0f, duration, TweenScaleFunctions.Linear, (ITween <float> c) =>
            {
                CloudCover           = Mathf.Lerp(startCover, cover, c.CurrentValue);
                CloudDensity         = Mathf.Lerp(startDensity, density, c.CurrentValue);
                CloudWhispiness      = Mathf.Lerp(startWhispiness, whispiness, c.CurrentValue);
                CloudColor           = Color.Lerp(startColor, color.Value, c.CurrentValue);
                CloudSharpness       = Mathf.Lerp(startSharpness, sharpness, c.CurrentValue);
                CloudLightAbsorption = Mathf.Lerp(startLightAbsorption, lightAbsorption, c.CurrentValue);
            }
                               );
        }
Exemple #4
0
 /// <summary>
 /// Set a new fog density over a period of time - if set to 0, game object will be disabled at end of transition
 /// </summary>
 /// <param name="fromDensity">Start of new fog density</param>
 /// <param name="toDensity">End of new fog density</param>
 /// <param name="transitionDuration">How long to transition to the new fog density in seconds</param>
 public void TransitionFogDensity(float fromDensity, float toDensity, float transitionDuration)
 {
     FogDensity = fromDensity;
     TweenFactory.Tween("WeatherMakerFog_" + gameObject.name, fromDensity, toDensity, transitionDuration, TweenScaleFunctions.Linear, (v) =>
     {
         FogDensity = v.CurrentValue;
     }, null);
 }
Exemple #5
0
        /// <summary>
        /// Start and add a Vector4 tween
        /// </summary>
        /// <param name="obj">Game object</param>
        /// <param name="key">Key</param>
        /// <param name="start">Start value</param>
        /// <param name="end">End value</param>
        /// <param name="duration">Duration in seconds</param>
        /// <param name="scaleFunc">Scale function</param>
        /// <param name="progress">Progress handler</param>
        /// <param name="completion">Completion handler</param>
        /// <returns>Vector4Tween</returns>
        public static Vector4Tween Tween(this GameObject obj, object key, Vector4 start, Vector4 end, float duration, Func <float, float> scaleFunc, Action <ITween <Vector4> > progress, Action <ITween <Vector4> > completion)
        {
            Vector4Tween t = TweenFactory.Tween(key, start, end, duration, scaleFunc, progress, completion);

            t.GameObject = obj;
            t.Renderer   = obj.GetComponent <Renderer>();
            return(t);
        }
Exemple #6
0
        /// <summary>
        /// Start and add a Color tween
        /// </summary>
        /// <param name="obj">Game object</param>
        /// <param name="start">Start value</param>
        /// <param name="end">End value</param>
        /// <param name="duration">Duration in seconds</param>
        /// <param name="scaleFunc">Scale function</param>
        /// <param name="progress">Progress handler</param>
        /// <param name="completion">Completion handler</param>
        /// <returns>ColorTween</returns>
        public static ColorTween Tween(this GameObject obj, object key, Color start, Color end, float duration, Func <float, float> scaleFunc, System.Action <ITween <Color> > progress, System.Action <ITween <Color> > completion)
        {
            ColorTween t = TweenFactory.Tween(key, start, end, duration, scaleFunc, progress, completion);

            t.GameObject = obj;
            t.Renderer   = obj.GetComponent <Renderer>();
            return(t);
        }
        /// <summary>
        /// Start and add a Quaternion tween
        /// </summary>
        /// <param name="obj">Game object</param>
        /// <param name="key">Key</param>
        /// <param name="start">Start value</param>
        /// <param name="end">End value</param>
        /// <param name="duration">Duration in seconds</param>
        /// <param name="scaleFunc">Scale function</param>
        /// <param name="progress">Progress handler</param>
        /// <param name="completion">Completion handler</param>
        /// <returns>QuaternionTween</returns>
        public static QuaternionTween Tween(this GameObject obj, object key, Quaternion start, Quaternion end, float duration, Func <float, float> scaleFunc, System.Action <ITween <Quaternion> > progress, System.Action <ITween <Quaternion> > completion = null)
        {
            QuaternionTween t = TweenFactory.Tween(key, start, end, duration, scaleFunc, progress, completion);

            t.GameObject = obj;
            t.Renderer   = obj.GetComponent <Renderer>();
            return(t);
        }
Exemple #8
0
 private void OnTriggerEnter(Collider other)
 {
     // if this is the first trigger entered, run it
     if (other.gameObject.tag == RequiredTag && ++triggers == 1)
     {
         TweenFactory.Tween("WeatherMakerSoundDamperZoneScript", CurrentSoundDampening(), Dampening, TransitionDuration, TweenScaleFunctions.Linear, (t) =>
         {
             WeatherMakerScript.Instance.VolumeModifierDictionary["WeatherMakerSoundDamperZoneScript"] = t.CurrentValue;
         });
     }
 }
Exemple #9
0
        public void HideCloudsAnimated(float duration)
        {
            float cover   = CloudCover;
            float density = CloudDensity;

            TweenFactory.Tween("WeatherMakerClouds", 1.0f, 0.0f, duration, TweenScaleFunctions.Linear, (ITween <float> c) =>
            {
                CloudCover   = c.CurrentValue * cover;
                CloudDensity = c.CurrentValue * density;
            });
        }
Exemple #10
0
 /// <summary>
 /// Set a new fog density over a period of time - if set to 0, game object will be disabled at end of transition
 /// </summary>
 /// <param name="fromDensity">Start of new fog density</param>
 /// <param name="toDensity">End of new fog density</param>
 /// <param name="transitionDuration">How long to transition to the new fog density in seconds</param>
 public void TransitionFogDensity(float fromDensity, float toDensity, float transitionDuration)
 {
     gameObject.SetActive(true);
     FogDensity = fromDensity;
     UpdateMaterial();
     TweenFactory.Tween("WeatherMakerFog_" + gameObject.name, fromDensity, toDensity, transitionDuration, TweenScaleFunctions.Linear, (v) =>
     {
         FogDensity = v.CurrentValue;
     }, (v) =>
     {
         gameObject.SetActive(v.CurrentValue != 0.0f);
     });
 }
        private void OnDestroy()
        {
            TweenFactory.Clear();
            WeatherMakerObjectExtensions.Clear();

            // remove lightning bolt lights from the light manager
            if (Application.isPlaying && WeatherMakerLightManagerScript.Instance != null && WeatherMakerThunderAndLightningScript.Instance != null)
            {
                WeatherMakerThunderAndLightningScript.Instance.LightningBoltScript.LightAddedCallback   -= LightningLightAdded;
                WeatherMakerThunderAndLightningScript.Instance.LightningBoltScript.LightRemovedCallback -= LightningLightRemoved;
            }

            WeatherMakerScript.ReleaseInstance(ref instance);
        }
Exemple #12
0
        /// <summary>
        /// Weather profile changed for thunder and lightning
        /// </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)
        {
            FloatTween tween = TweenFactory.Tween("WeatherMakerScriptProfileChangeLightning", 0.0f, 1.0f, 0.01f, TweenScaleFunctions.Linear, null, (completion) =>
            {
                ThunderAndLightningScript.LightningIntenseProbability          = newProfile.LightningProfile.LightningIntenseProbability;
                ThunderAndLightningScript.LightningIntervalTimeRange           = newProfile.LightningProfile.LightningIntervalTimeRange;
                ThunderAndLightningScript.LightningForcedVisibilityProbability = newProfile.LightningProfile.LightningForcedVisibilityProbability;
                ThunderAndLightningScript.GroundLightningChance = newProfile.LightningProfile.LightningGroundChance;
                ThunderAndLightningScript.CloudLightningChance  = newProfile.LightningProfile.LightningCloudChance;
                ThunderAndLightningScript.EnableLightning       = (newProfile.LightningProfile.LightningIntervalTimeRange.Minimum > 0.0f);
            });

            tween.Delay = transitionDelay;
        }
        /// <summary>
        /// Set a new fog density over a period of time - if set to 0, game object will be disabled at end of transition
        /// </summary>
        /// <param name="fromDensity">Start of new fog density</param>
        /// <param name="toDensity">End of new fog density</param>
        /// <param name="transitionDuration">How long to transition to the new fog density in seconds</param>
        public void TransitionFogDensity(float fromDensity, float toDensity, float transitionDuration)
        {
            if (!isActiveAndEnabled)
            {
                Debug.LogError("Fog script must be enabled to show fog");
                return;
            }

            FogProfile.FogDensity = fromDensity;
            TweenFactory.Tween("WeatherMakerFog_" + gameObject.name, fromDensity, toDensity, transitionDuration, TweenScaleFunctions.Linear, (v) =>
            {
                FogProfile.FogDensity = v.CurrentValue;
            }, null);
        }
Exemple #14
0
 private void TweenScript(WeatherMakerFallingParticleScript script, float end)
 {
     if (Mathf.Abs(script.Intensity - end) < PrecipitationChangeThreshold)
     {
         script.Intensity = end;
     }
     else
     {
         TweenFactory.Tween("WeatherMakerPrecipitationChange_" + script.gameObject.GetInstanceID(), script.Intensity, end, PrecipitationChangeDuration, TweenScaleFunctions.Linear, (t) =>
         {
             // Debug.LogFormat("Tween key: {0}, value: {1}, prog: {2}", t.Key, t.CurrentValue, t.CurrentProgress);
             script.Intensity = t.CurrentValue;
         }, null);
     }
 }
Exemple #15
0
        private void TweenScript(WeatherMakerFallingParticleScript script, float end)
        {
            if (PrecipitationChangeDuration < 0.1f)
            {
                script.Intensity = end;
                return;
            }

            float      duration = (Mathf.Abs(script.Intensity - end) < PrecipitationChangeThreshold ? 0.0f : PrecipitationChangeDuration);
            FloatTween tween    = TweenFactory.Tween("WeatherMakerPrecipitationChange_" + script.gameObject.GetInstanceID(), script.Intensity, end, duration, TweenScaleFunctions.Linear, (t) =>
            {
                // Debug.LogFormat("Tween key: {0}, value: {1}, prog: {2}", t.Key, t.CurrentValue, t.CurrentProgress);
                script.Intensity = t.CurrentValue;
            });

            tween.Delay = PrecipitationChangeDelay;
        }
        /// <summary>
        /// Animate from one aurora profile to another
        /// </summary>
        /// <param name="oldProfile">Old profile</param>
        /// <param name="duration">Duration</param>
        /// <param name="key">Animation key</param>
        /// <param name="completion">Completion callback</param>
        public void AnimateFrom(WeatherMakerAuroraProfileScript oldProfile, float duration, string key, System.Action completion)
        {
            if (oldProfile != null)
            {
                TweenFactory.Tween(key, 0.0f, 1.0f, duration, TweenScaleFunctions.QuadraticEaseInOut, (ITween <float> v) =>
                {
                    AnimationSampleCount     = Mathf.RoundToInt(Mathf.Lerp((float)oldProfile.AnimationSampleCount, (float)SampleCount, v.CurrentProgress));
                    AnimationSubSampleCount  = Mathf.RoundToInt(Mathf.Lerp((float)oldProfile.AnimationSubSampleCount, (float)SubSampleCount, v.CurrentProgress));
                    AnimationAnimationSpeed  = Vector3.Lerp(oldProfile.AnimationAnimationSpeed, AnimationSpeed, v.CurrentProgress);
                    AnimationColor           = oldProfile.AnimationColor.Lerp(Color, v.CurrentProgress);
                    AnimationDither          = Mathf.Lerp(oldProfile.AnimationDither, Dither, v.CurrentProgress);
                    AnimationIntensity       = Mathf.Lerp(oldProfile.AnimationIntensity, Intensity, v.CurrentProgress);
                    AnimationPower           = Mathf.Lerp(oldProfile.AnimationPower, Power, v.CurrentProgress);
                    AnimationHeightFadePower = Mathf.Lerp(oldProfile.AnimationHeightFadePower, HeightFadePower, v.CurrentProgress);
                    AnimationMarchScale      = Vector3.Lerp(oldProfile.AnimationMarchScale, MarchScale, v.CurrentProgress);
                    AnimationScale           = Vector3.Lerp(oldProfile.AnimationScale, Scale, v.CurrentProgress);
                    AnimationHeight          = new RangeOfFloats(Mathf.Lerp(oldProfile.AnimationHeight.Minimum, Height.Minimum, v.CurrentProgress), Mathf.Lerp(oldProfile.Height.Maximum, Height.Maximum, v.CurrentProgress));
                    AnimationPlanetRadius    = Mathf.Lerp(oldProfile.AnimationPlanetRadius, PlanetRadius, v.CurrentProgress);
                    AnimationDistanceFade    = Mathf.Lerp(oldProfile.AnimationDistanceFade, DistanceFade, v.CurrentProgress);
                    AnimationAmbientColor    = UnityEngine.Color.Lerp(oldProfile.AnimationAmbientColor, AmbientLight * Intensity, v.CurrentProgress);
                    AnimationOctave          = Vector2.Lerp(oldProfile.AnimationOctave, Octave, v.CurrentProgress);

                    if (WeatherMakerScript.Instance != null)
                    {
                        AnimationSampleCount    = Mathf.Min(WeatherMakerScript.Instance.PerformanceProfile.AuroraSampleCount, AnimationSampleCount);
                        AnimationSubSampleCount = Mathf.Min(WeatherMakerScript.Instance.PerformanceProfile.AuroraSubSampleCount, AnimationSubSampleCount);
                    }
                }, (ITween <float> v) =>
                {
                    if (completion != null)
                    {
                        completion.Invoke();
                    }
                });
            }
            else
            {
                UpdateAnimationProperties();
                if (completion != null)
                {
                    completion.Invoke();
                }
            }
        }
Exemple #17
0
        private void OnDestroy()
        {
            TweenFactory.Clear();
            WeatherMakerObjectExtensions.Clear();

#if UNITY_EDITOR
            Instance = GameObject.FindObjectOfType <WeatherMakerScript>();
#endif

            Camera.onPreCull   -= CameraPreCullWrapper;
            Camera.onPreRender -= CameraPreRenderWrapper;

            if (WeatherMakerLightManagerScript.Instance != null)
            {
                // wire up lightning bolt lights to the light manager
                LightningBoltScript.LightAddedCallback   -= LightAdded;
                LightningBoltScript.LightRemovedCallback -= LightRemoved;
            }
        }
Exemple #18
0
        /// <summary>
        /// Enable / disable lens flare
        /// </summary>
        /// <param name="enable">Enable or disable</param>
        public void SetFlareEnabled(bool enable)
        {
            if (WeatherScript.Sun == null)
            {
                return;
            }
            LensFlare flare = WeatherScript.Sun.Transform.GetComponent <LensFlare>();

            if (flare == null)
            {
                return;
            }
            Color startColor = flare.color;
            Color endColor   = (enable ? Color.white : Color.black);

            TweenFactory.Tween("WeatherMakerLensFlare", startColor, endColor, 3.0f, TweenScaleFunctions.Linear, (ITween <Color> c) =>
            {
                flare.color = c.CurrentValue;
            }, null);
        }
 private void OnTriggerExit(Collider other)
 {
     // if this is the last trigger exited, run it
     if (gameObject.activeInHierarchy && enabled && WeatherMakerScript.IsLocalPlayer(other.transform) && --triggers == 0)
     {
         TweenFactory.Tween("WeatherMakerDampeningZoneScript", 0.0f, 1.0f, TransitionDuration, TweenScaleFunctions.Linear, (t) =>
         {
             if (WeatherMakerAudioManagerScript.Instance != null)
             {
                 float currentValue;
                 if (WeatherMakerAudioManagerScript.Instance.VolumeModifierDictionary.TryGetValue("WeatherMakerDampeningZoneScript", out currentValue))
                 {
                     WeatherMakerAudioManagerScript.Instance.VolumeModifierDictionary["WeatherMakerDampeningZoneScript"] = Mathf.Lerp(currentValue, 1.0f, t.CurrentValue);
                 }
             }
             if (WeatherMakerScript.Instance != null)
             {
                 float currentValue;
                 if (WeatherMakerScript.Instance.IntensityModifierDictionary.TryGetValue("WeatherMakerDampeningZoneScript", out currentValue))
                 {
                     WeatherMakerScript.Instance.IntensityModifierDictionary["WeatherMakerDampeningZoneScript"] = Mathf.Lerp(currentValue, 1.0f, t.CurrentValue);
                 }
             }
             if (WeatherMakerThunderAndLightningScript.Instance != null)
             {
                 WeatherMakerThunderAndLightningScript.Instance.LightningBoltScript.LightParameters.LightIntensity =
                     Mathf.Lerp(WeatherMakerThunderAndLightningScript.Instance.LightningBoltScript.LightParameters.LightIntensity, 1.0f, t.CurrentValue);
             }
         }, (t) =>
         {
             if (WeatherMakerAudioManagerScript.Instance != null)
             {
                 WeatherMakerAudioManagerScript.Instance.VolumeModifierDictionary.Remove("WeatherMakerSoundDamperZoneScript");
             }
             if (WeatherMakerScript.Instance != null)
             {
                 WeatherMakerScript.Instance.IntensityModifierDictionary.Remove("WeatherMakerIntensityDamperZoneScript");
             }
         });
     }
 }
Exemple #20
0
        /// <summary>
        /// Show cloud animated
        /// </summary>
        /// <param name="duration">How long until clouds fully transition to the parameters</param>
        /// <param name="cover">Cloud cover, 0 to 1</param>
        /// <param name="density">Cloud density, 0 to 1</param>
        /// <param name="whispiness">Cloud whispiness, 0 to 3</param>
        /// <param name="color">Cloud color, if null defaults to white</param>
        public void ShowCloudsAnimated(float duration, float cover, float density = 0.0f, float whispiness = 0.3f, float sharpness = 0.015f, Color?color = null)
        {
            SetFlareEnabled(cover < 0.25f);
            if (!color.HasValue)
            {
                color = CloudColor;
            }
            float startCover      = CloudCover;
            float startDensity    = CloudDensity;
            float startWhispiness = CloudWhispiness;
            float startSharpness  = CloudSharpness;
            Color startColor      = CloudColor;

            TweenFactory.Tween("WeatherMakerClouds", 0.0f, 1.0f, duration, TweenScaleFunctions.Linear, (ITween <float> c) =>
            {
                CloudCover      = Mathf.Lerp(startCover, cover, c.CurrentValue);
                CloudDensity    = Mathf.Lerp(startDensity, density, c.CurrentValue);
                CloudWhispiness = Mathf.Lerp(startWhispiness, whispiness, c.CurrentValue);
                CloudColor      = Color.Lerp(startColor, color.Value, c.CurrentValue);
                CloudSharpness  = Mathf.Lerp(startSharpness, sharpness, c.CurrentValue);
            }, null);
        }
 /// <summary>
 /// Stops the tween.
 /// </summary>
 /// <param name="stopBehavior">The behavior to use to handle the stop.</param>
 public void Stop(TweenStopBehavior stopBehavior)
 {
     if (state != TweenState.Stopped)
     {
         state = TweenState.Stopped;
         if (stopBehavior == TweenStopBehavior.Complete)
         {
             currentTime = duration;
             UpdateValue();
             if (completionCallback != null)
             {
                 completionCallback.Invoke(this);
                 completionCallback = null;
             }
             if (continueWith != null)
             {
                 continueWith.Start();
                 TweenFactory.AddTween(continueWith);
                 continueWith = null;
             }
         }
     }
 }
Exemple #22
0
        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);
                }
            }
        }
        private void PositionAnimatedTexture(Transform anchor)
        {
            if (AnimatedTextureRenderer == null)
            {
                return;
            }
            else if (AnimatedTextureRendererIntensityThreshold >= 1.0f || Intensity == 0.0f)
            {
                AnimatedTextureRenderer.enabled = false;
            }
            else
            {
                RaycastHit  hit;
                Vector3     pos      = anchor.position;
                const float duration = 2.0f;

                // check if something above camera, if so disable animated texture
                if (Physics.Raycast(pos, Vector3.up, out hit, 200.0f, AnimatedTextureCollisionMaskAbove, QueryTriggerInteraction.Ignore) &&
                    hit.point.y > pos.y)
                {
                    if (AnimatedTextureRenderer.enabled && AnimatedTextureRenderer.sharedMaterial.GetFloat(WMS._AlphaMultiplierAnimation2) >= 1.0f)
                    {
                        // fade out
                        float start = AnimatedTextureRenderer.sharedMaterial.GetFloat(WMS._AlphaMultiplierAnimation2);
                        TweenFactory.Tween("WeatherMakerPrecipitationAnimatedTextureChange_" + GetInstanceID(), start, 0.0f, duration, TweenScaleFunctions.Linear, (t) =>
                        {
                            // Debug.LogFormat("Tween key: {0}, value: {1}, prog: {2}", t.Key, t.CurrentValue, t.CurrentProgress);
                            AnimatedTextureRenderer.sharedMaterial.SetFloat(WMS._AlphaMultiplierAnimation2, t.CurrentValue);
                        },
                                           (t) =>
                        {
                            AnimatedTextureRenderer.enabled = false;
                        });
                    }
                }
                else
                {
                    if (Physics.Raycast(pos, Vector3.down, out hit, 200.0f, AnimatedTextureCollisionMaskBelow, QueryTriggerInteraction.Ignore))
                    {
                        Vector3 newPos = hit.point;
                        float   y      = newPos.y;
                        newPos  += (anchor.transform.forward * AnimatedTextureRendererPositionOffset.z);
                        newPos.y = y + AnimatedTextureRendererPositionOffset.y;
                        AnimatedTextureRenderer.transform.position = newPos;
                    }
                    float lerp  = (Intensity * ExternalIntensityMultiplier) / Mathf.Max(0.01f, AnimatedTextureRendererIntensityThreshold);
                    float alpha = Mathf.Lerp(0.0f, 1.0f, lerp);
                    AnimatedTextureRenderer.sharedMaterial.SetFloat(WMS._AlphaMultiplierAnimation, alpha);
                    if (!AnimatedTextureRenderer.enabled)
                    {
                        AnimatedTextureRenderer.enabled = true;
                        float start = AnimatedTextureRenderer.sharedMaterial.GetFloat(WMS._AlphaMultiplierAnimation2);

                        // fade in
                        TweenFactory.Tween("WeatherMakerPrecipitationAnimatedTextureChange_" + GetInstanceID(), start, 1.0f, duration, TweenScaleFunctions.Linear, (t) =>
                        {
                            // Debug.LogFormat("Tween key: {0}, value: {1}, prog: {2}", t.Key, t.CurrentValue, t.CurrentProgress);
                            AnimatedTextureRenderer.sharedMaterial.SetFloat(WMS._AlphaMultiplierAnimation2, t.CurrentValue);
                        });
                    }
                }
            }
        }
Exemple #24
0
        /// <summary>
        /// Create a new fog profile and begin animating to the new profile settings
        /// </summary>
        /// <param name="toProfile">New fog profile to transition to</param>
        /// <param name="transitionDelay">Transition delay in seconds</param>
        /// <param name="transitionDuration">Transition duration in seconds</param>
        /// <param name="newDensity">Density for the new profile or null to use profile density</param>
        /// <param name="tweenKey">Tween key</param>
        /// <returns>The newly created fog profile that is being transitioned to (a copy of toProfile)</returns>
        public virtual T ShowFogAnimated(T toProfile, float transitionDelay, float transitionDuration, float?newDensity = null, string tweenKey = null)
        {
            if (FogProfile == null)
            {
                Debug.LogError("Fog profile needs to be set before ShowFogAnimated can be called");
                return(null);
            }

            T toProfileInstance = ScriptableObject.Instantiate(toProfile);

            if (newDensity != null)
            {
                toProfileInstance.FogDensity = newDensity.Value;
            }
            FogProfile.CopyStateTo(toProfileInstance);
            tweenKey = (tweenKey ?? string.Empty);

            // animate density, color and noise properties, just leave the rest at final values

            // cleanup old profile if it was temporary
            T oldProfile = FogProfile;

            FogProfile = toProfileInstance;

            // make copies of final value for animatable properties
            float   newFogDensity               = toProfileInstance.FogDensity;
            float   newFogFactorMultiplier      = toProfileInstance.FogFactorMultiplier;
            Color   newFogColor                 = toProfileInstance.FogColor;
            Color   newFogEmissionColor         = toProfileInstance.FogEmissionColor;
            float   newFogLightAbsorption       = toProfileInstance.FogLightAbsorption;
            float   newMaxFogFactor             = toProfileInstance.MaxFogFactor;
            int     newFogNoiseSampleCount      = toProfileInstance.FogNoiseSampleCount;
            float   newFogNoiseAdder            = toProfileInstance.FogNoiseAdder;
            float   newFogNoiseMultiplier       = toProfileInstance.FogNoiseMultiplier;
            float   newFogNoiseScale            = toProfileInstance.FogNoiseScale;
            Vector3 newFogNoiseVelocity         = toProfileInstance.FogNoiseVelocity;
            Vector4 newFogNoiseVelocityRotation = toProfileInstance.FogNoiseVelocityRotation;
            float   newFogShadowBrightness      = toProfileInstance.FogShadowBrightness;
            float   newFogShadowDecay           = toProfileInstance.FogShadowDecay;
            float   newFogShadowDither          = toProfileInstance.FogShadowDither;
            float   newFogShadowMaxRayLength    = toProfileInstance.FogShadowMaxRayLength;
            float   newFogShadowMultiplier      = toProfileInstance.FogShadowMultiplier;
            float   newFogShadowPower           = toProfileInstance.FogShadowPower;
            int     newFogShadowSampleCount     = toProfileInstance.FogShadowSampleCount;
            float   newDitherLevel              = toProfileInstance.DitherLevel;

            float oldFogDensity          = oldProfile.FogDensity;
            float oldFogFactorMultiplier = oldProfile.FogFactorMultiplier;
            T     transitionFromProfile  = (oldFogDensity == 0.0f ? toProfileInstance : oldProfile);
            bool  newProfileHasNoise     = toProfileInstance.HasNoise;
            bool  oldProfileHasNoise     = oldProfile.HasNoise;
            bool  bothProfileHaveNoise   = newProfileHasNoise && oldProfileHasNoise;
            bool  transitionShadow       = (oldProfile.FogShadowSampleCount > 0 && toProfileInstance.FogShadowSampleCount > 0);

            // transition to a new profile without noise, copy old profile noise settings
            if (oldProfileHasNoise && !newProfileHasNoise)
            {
                toProfileInstance.FogNoiseVelocity         = transitionFromProfile.FogNoiseVelocity;
                toProfileInstance.FogNoiseVelocityRotation = transitionFromProfile.FogNoiseVelocityRotation;
                toProfileInstance.FogNoiseAdder            = transitionFromProfile.FogNoiseAdder;
                toProfileInstance.FogNoiseMultiplier       = transitionFromProfile.FogNoiseMultiplier;
                toProfileInstance.FogNoiseSampleCount      = transitionFromProfile.FogNoiseSampleCount;
                toProfileInstance.FogNoiseScale            = transitionFromProfile.FogNoiseScale;
            }

            FloatTween tween = TweenFactory.Tween("WeatherMakerFogScript_" + GetInstanceID() + tweenKey, 0.0f, 1.0f, transitionDuration, TweenScaleFunctions.Linear, (ITween <float> c) =>
            {
                float progress = c.CurrentValue;
                toProfileInstance.FogDensity          = Mathf.Lerp(oldFogDensity, newFogDensity, progress);
                toProfileInstance.FogFactorMultiplier = Mathf.Lerp(oldFogFactorMultiplier, newFogFactorMultiplier, progress);
                toProfileInstance.FogColor            = Color.Lerp(transitionFromProfile.FogColor, newFogColor, progress);
                toProfileInstance.FogEmissionColor    = Color.Lerp(transitionFromProfile.FogEmissionColor, newFogEmissionColor, progress);
                toProfileInstance.FogLightAbsorption  = Mathf.Lerp(transitionFromProfile.FogLightAbsorption, newFogLightAbsorption, progress);
                toProfileInstance.MaxFogFactor        = Mathf.Lerp(transitionFromProfile.MaxFogFactor, newMaxFogFactor, progress);
                toProfileInstance.DitherLevel         = Mathf.Lerp(transitionFromProfile.DitherLevel, newDitherLevel, progress);

                // if both profiles have fog noise, animate noise
                if (bothProfileHaveNoise)
                {
                    toProfileInstance.FogNoiseVelocity         = Vector3.Lerp(transitionFromProfile.FogNoiseVelocity, newFogNoiseVelocity, progress);
                    toProfileInstance.FogNoiseVelocityRotation = Vector4.Lerp(transitionFromProfile.FogNoiseVelocityRotation, newFogNoiseVelocityRotation, progress);
                    toProfileInstance.FogNoiseAdder            = Mathf.Lerp(transitionFromProfile.FogNoiseAdder, newFogNoiseAdder, progress);
                    toProfileInstance.FogNoiseMultiplier       = Mathf.Lerp(transitionFromProfile.FogNoiseMultiplier, newFogNoiseMultiplier, progress);
                    toProfileInstance.FogNoiseSampleCount      = (int)Mathf.Lerp(transitionFromProfile.FogNoiseSampleCount, newFogNoiseSampleCount, progress);
                    toProfileInstance.FogNoiseScale            = Mathf.Lerp(transitionFromProfile.FogNoiseScale, newFogNoiseScale, progress);
                }
                // if only new profile has noise, animate to noise from no noise
                else if (newProfileHasNoise)
                {
                    toProfileInstance.fogNoisePercent = progress;
                }
                // if only old profile has noise, animate from noise to no noise
                else if (oldProfileHasNoise)
                {
                    toProfileInstance.fogNoisePercent = 1.0f - progress;
                }

                if (transitionShadow)
                {
                    toProfileInstance.FogShadowBrightness   = Mathf.Lerp(transitionFromProfile.FogShadowBrightness, newFogShadowBrightness, progress);
                    toProfileInstance.FogShadowDecay        = Mathf.Lerp(transitionFromProfile.FogShadowDecay, newFogShadowDecay, progress);
                    toProfileInstance.FogShadowDither       = Mathf.Lerp(transitionFromProfile.FogShadowDither, newFogShadowDither, progress);
                    toProfileInstance.FogShadowMaxRayLength = Mathf.Lerp(transitionFromProfile.FogShadowMaxRayLength, newFogShadowMaxRayLength, progress);
                    toProfileInstance.FogShadowMultiplier   = Mathf.Lerp(transitionFromProfile.FogShadowMultiplier, newFogShadowMultiplier, progress);
                    toProfileInstance.FogShadowPower        = Mathf.Lerp(transitionFromProfile.FogShadowPower, newFogShadowPower, progress);
                    toProfileInstance.FogShadowSampleCount  = (int)Mathf.Lerp(transitionFromProfile.FogShadowSampleCount, newFogShadowSampleCount, progress);
                }
                // note do not animate the dither magic property!
            }, (ITween <float> c) =>
            {
                // if the old profile was a clone, clean it up
                if (oldProfile.name.IndexOf("clone", System.StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    GameObject.Destroy(oldProfile);
                }

                // if new profile has no noise and old profile had noise, disable noise by setting noise multiplier to 0 (save performance).
                if (oldProfileHasNoise && !newProfileHasNoise)
                {
                    toProfileInstance.FogNoiseMultiplier = 0.0f;
                }
            });

            tween.Delay = transitionDelay;
            return(toProfileInstance);
        }
 /// <summary>
 /// Set a new null zone strength, animated
 /// </summary>
 /// <param name="newStrength">New strength, clamped to 0 - 1</param>
 /// <param name="duration">Duration</param>
 public void SetStrengthAnimated(float newStrength, float duration)
 {
     TweenFactory.Tween("WeatherMakerZullZoneScript_" + GetInstanceID(), NullZoneStrength, Mathf.Clamp(newStrength, 0.0f, 1.0f),
                        duration, TweenScaleFunctions.Linear, (t) => NullZoneStrength = t.CurrentProgress);
 }
Exemple #26
0
        private void AnimateWindChange(WeatherMakerWindProfileScript newProfile, float transitionDelay, float transitionDuration)
        {
            // update to new wind
            WeatherMakerWindProfileScript oldProfile = WindProfile;

            newProfile  = newProfile ?? WindProfile;
            WindProfile = newProfile;

            // pick the next time to change
            windNextChangeTime = WindProfile.WindChangeInterval.Random();

            // previous values...
            float      oldWindIntensity  = WindIntensity;
            float      oldTurbulence     = WindZone.windTurbulence;
            float      oldPulseMagnitude = WindZone.windPulseMagnitude;
            float      oldPulseFrequency = WindZone.windPulseFrequency;
            Quaternion oldWindDirection  = WindZone.transform.rotation;

            // animate to new values...
            float newWindIntensity = WindIntensity;

            if (WindProfile.AutoWindIntensity)
            {
                newWindIntensity = (WindProfile.WindSpeedRange.Maximum <= 0.0f ? 0.0f : WindProfile.WindSpeedRange.Random() / WindProfile.WindSpeedRange.Maximum);
            }
            float      newTurbulence     = WindProfile.WindTurbulenceRange.Random();
            float      newPulseMagnitude = WindProfile.WindPulseMagnitudeRange.Random();
            float      newPulseFrequency = WindProfile.WindPulseFrequencyRange.Random();
            Quaternion newWindDirection  = oldWindDirection;

            // if random wind, pick a new direction from wind
            if (RandomWindDirection)
            {
                // 2D is set immediately
                switch (WeatherMakerScript.ResolveCameraMode())
                {
                case CameraMode.OrthographicXY:
                case CameraMode.OrthographicXZ:
                    int val = UnityEngine.Random.Range(0, 2);
                    newWindDirection = Quaternion.Euler(0.0f, -90.0f + (180.0f * val), 0.0f);
                    break;

                default:
                    // 3D is lerped over time
                    float xAxis = (WindProfile.AllowBlowUp ? UnityEngine.Random.Range(-30.0f, 30.0f) : 0.0f);
                    newWindDirection = Quaternion.Euler(xAxis, UnityEngine.Random.Range(0.0f, 360.0f), 0.0f);
                    break;
                }
            }

            FloatTween tween = TweenFactory.Tween("WeatherMakerWindScript_" + GetInstanceID(), 0.0f, 1.0f, transitionDuration, TweenScaleFunctions.Linear, (t) =>
            {
                WindIntensity               = Mathf.Lerp(oldWindIntensity, newWindIntensity, t.CurrentValue);
                WindZone.windTurbulence     = Mathf.Lerp(oldTurbulence, newTurbulence, t.CurrentValue);
                WindZone.windPulseFrequency = Mathf.Lerp(oldPulseMagnitude, newPulseMagnitude, t.CurrentValue);
                WindZone.windPulseMagnitude = Mathf.Lerp(oldPulseFrequency, newPulseFrequency, t.CurrentValue);
                WindZone.transform.rotation = Quaternion.Lerp(oldWindDirection, newWindDirection, t.CurrentValue);
            }, (t) =>
            {
                // if the old profile was a clone, clean it up
                if (oldProfile.name.IndexOf("(clone)", System.StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    GameObject.Destroy(oldProfile);
                }
            });

            tween.Delay = transitionDelay;
        }
        /// <summary>
        /// Show clouds animated. Animates cover, density, sharpness, light absorption and color. To ensure smooth animations, all noise textures on all layers in both profiles should match.
        /// </summary>
        /// <param name="duration">Transition duration in seconds</param>
        /// <param name="newProfile">Cloud profile, or pass null to hide clouds</param>
        public void ShowCloudsAnimated(float duration, WeatherMakerCloudProfileScript newProfile)
        {
            if (!isActiveAndEnabled || currentRenderCloudProfile == null)
            {
                Debug.LogError("Full screen cloud script must be enabled to show clouds");
                return;
            }

            WeatherMakerCloudProfileScript oldProfile = currentRenderCloudProfile;

            // dynamic start and end properties
            float   endCover1, endCover2, endCover3, endCover4;
            float   endDensity1, endDensity2, endDensity3, endDensity4;
            float   startSharpness1, startSharpness2, startSharpness3, startSharpness4;
            float   endSharpness1, endSharpness2, endSharpness3, endSharpness4;
            float   startLightAbsorption1, startLightAbsorption2, startLightAbsorption3, startLightAbsorption4;
            float   endLightAbsorption1, endLightAbsorption2, endLightAbsorption3, endLightAbsorption4;
            Vector4 startScale1, startScale2, startScale3, startScale4;
            Vector4 endScale1, endScale2, endScale3, endScale4;
            Vector4 startMultiplier1, startMultiplier2, startMultiplier3, startMultiplier4;
            Vector4 endMultiplier1, endMultiplier2, endMultiplier3, endMultiplier4;
            float   startMaskScale1, startMaskScale2, startMaskScale3, startMaskScale4;
            float   endMaskScale1, endMaskScale2, endMaskScale3, endMaskScale4;
            float   startHeight1, startHeight2, startHeight3, startHeight4;
            float   endHeight1, endHeight2, endHeight3, endHeight4;

            // set to empty profile if null passed in
            if (newProfile == null)
            {
                newProfile = emptyProfile;
            }
            newProfile.EnsureNonNullLayers();

            // apply end cover and density
            endCover1   = newProfile.CloudLayer1.CloudCover;
            endCover2   = newProfile.CloudLayer2.CloudCover;
            endCover3   = newProfile.CloudLayer3.CloudCover;
            endCover4   = newProfile.CloudLayer4.CloudCover;
            endDensity1 = newProfile.CloudLayer1.CloudDensity;
            endDensity2 = newProfile.CloudLayer2.CloudDensity;
            endDensity3 = newProfile.CloudLayer3.CloudDensity;
            endDensity4 = newProfile.CloudLayer4.CloudDensity;

            float   startCover1             = oldProfile.CloudLayer1.CloudCover;
            float   startCover2             = oldProfile.CloudLayer2.CloudCover;
            float   startCover3             = oldProfile.CloudLayer3.CloudCover;
            float   startCover4             = oldProfile.CloudLayer4.CloudCover;
            float   startDensity1           = oldProfile.CloudLayer1.CloudDensity;
            float   startDensity2           = oldProfile.CloudLayer2.CloudDensity;
            float   startDensity3           = oldProfile.CloudLayer3.CloudDensity;
            float   startDensity4           = oldProfile.CloudLayer4.CloudDensity;
            Color   startColor1             = oldProfile.CloudLayer1.CloudColor;
            Color   startColor2             = oldProfile.CloudLayer2.CloudColor;
            Color   startColor3             = oldProfile.CloudLayer3.CloudColor;
            Color   startColor4             = oldProfile.CloudLayer4.CloudColor;
            Color   startEmissionColor1     = oldProfile.CloudLayer1.CloudEmissionColor;
            Color   startEmissionColor2     = oldProfile.CloudLayer2.CloudEmissionColor;
            Color   startEmissionColor3     = oldProfile.CloudLayer3.CloudEmissionColor;
            Color   startEmissionColor4     = oldProfile.CloudLayer4.CloudEmissionColor;
            float   startAmbientMultiplier1 = oldProfile.CloudLayer1.CloudAmbientMultiplier;
            float   startAmbientMultiplier2 = oldProfile.CloudLayer2.CloudAmbientMultiplier;
            float   startAmbientMultiplier3 = oldProfile.CloudLayer3.CloudAmbientMultiplier;
            float   startAmbientMultiplier4 = oldProfile.CloudLayer4.CloudAmbientMultiplier;
            Vector4 startVelocity1          = oldProfile.CloudLayer1.CloudNoiseVelocity;
            Vector4 startVelocity2          = oldProfile.CloudLayer2.CloudNoiseVelocity;
            Vector4 startVelocity3          = oldProfile.CloudLayer3.CloudNoiseVelocity;
            Vector4 startVelocity4          = oldProfile.CloudLayer4.CloudNoiseVelocity;
            Vector4 startMaskVelocity1      = oldProfile.CloudLayer1.CloudNoiseMaskVelocity;
            Vector4 startMaskVelocity2      = oldProfile.CloudLayer2.CloudNoiseMaskVelocity;
            Vector4 startMaskVelocity3      = oldProfile.CloudLayer3.CloudNoiseMaskVelocity;
            Vector4 startMaskVelocity4      = oldProfile.CloudLayer4.CloudNoiseMaskVelocity;
            Vector4 startRotation           = new Vector4(oldProfile.CloudLayer1.CloudNoiseRotation.LastValue, oldProfile.CloudLayer2.CloudNoiseRotation.LastValue, oldProfile.CloudLayer3.CloudNoiseRotation.LastValue, oldProfile.CloudLayer4.CloudNoiseRotation.LastValue);
            Vector4 startMaskRotation       = new Vector4(oldProfile.CloudLayer1.CloudNoiseMaskRotation.LastValue, oldProfile.CloudLayer2.CloudNoiseMaskRotation.LastValue, oldProfile.CloudLayer3.CloudNoiseMaskRotation.LastValue, oldProfile.CloudLayer4.CloudNoiseMaskRotation.LastValue);
            float   startDirectionalLightIntensityMultiplier      = oldProfile.DirectionalLightIntensityMultiplier;
            float   startDirectionalLightShadowStrengthMultiplier = oldProfile.DirectionalLightShadowStrengthMultiplier;

            Color   endColor1             = newProfile.CloudLayer1.CloudColor;
            Color   endColor2             = newProfile.CloudLayer2.CloudColor;
            Color   endColor3             = newProfile.CloudLayer3.CloudColor;
            Color   endColor4             = newProfile.CloudLayer4.CloudColor;
            Color   endEmissionColor1     = newProfile.CloudLayer1.CloudEmissionColor;
            Color   endEmissionColor2     = newProfile.CloudLayer2.CloudEmissionColor;
            Color   endEmissionColor3     = newProfile.CloudLayer3.CloudEmissionColor;
            Color   endEmissionColor4     = newProfile.CloudLayer4.CloudEmissionColor;
            float   endAmbientMultiplier1 = newProfile.CloudLayer1.CloudAmbientMultiplier;
            float   endAmbientMultiplier2 = newProfile.CloudLayer2.CloudAmbientMultiplier;
            float   endAmbientMultiplier3 = newProfile.CloudLayer3.CloudAmbientMultiplier;
            float   endAmbientMultiplier4 = newProfile.CloudLayer4.CloudAmbientMultiplier;
            Vector3 endVelocity1          = newProfile.CloudLayer1.CloudNoiseVelocity;
            Vector3 endVelocity2          = newProfile.CloudLayer2.CloudNoiseVelocity;
            Vector3 endVelocity3          = newProfile.CloudLayer3.CloudNoiseVelocity;
            Vector3 endVelocity4          = newProfile.CloudLayer4.CloudNoiseVelocity;
            Vector3 endMaskVelocity1      = newProfile.CloudLayer1.CloudNoiseMaskVelocity;
            Vector3 endMaskVelocity2      = newProfile.CloudLayer2.CloudNoiseMaskVelocity;
            Vector3 endMaskVelocity3      = newProfile.CloudLayer3.CloudNoiseMaskVelocity;
            Vector3 endMaskVelocity4      = newProfile.CloudLayer4.CloudNoiseMaskVelocity;
            Vector4 endRotation           = new Vector4(newProfile.CloudLayer1.CloudNoiseRotation.Random(), newProfile.CloudLayer2.CloudNoiseRotation.Random(), newProfile.CloudLayer3.CloudNoiseRotation.Random(), newProfile.CloudLayer4.CloudNoiseRotation.Random());
            Vector4 endMaskRotation       = new Vector4(newProfile.CloudLayer1.CloudNoiseMaskRotation.Random(), newProfile.CloudLayer2.CloudNoiseMaskRotation.Random(), newProfile.CloudLayer3.CloudNoiseMaskRotation.Random(), newProfile.CloudLayer4.CloudNoiseMaskRotation.Random());
            float   endDirectionalLightIntensityMultiplier      = newProfile.DirectionalLightIntensityMultiplier;
            float   endDirectionalLightShadowStrengthMultiplier = newProfile.DirectionalLightShadowStrengthMultiplier;

            if (startCover1 == 0.0f && startCover2 == 0.0f && startCover3 == 0.0f && startCover4 == 0.0f)
            {
                // transition from no clouds to clouds, start at new profile values
                startSharpness1       = endSharpness1 = newProfile.CloudLayer1.CloudSharpness;
                startSharpness2       = endSharpness2 = newProfile.CloudLayer2.CloudSharpness;
                startSharpness3       = endSharpness3 = newProfile.CloudLayer3.CloudSharpness;
                startSharpness4       = endSharpness4 = newProfile.CloudLayer4.CloudSharpness;
                startLightAbsorption1 = endLightAbsorption1 = newProfile.CloudLayer1.CloudLightAbsorption;
                startLightAbsorption2 = endLightAbsorption2 = newProfile.CloudLayer2.CloudLightAbsorption;
                startLightAbsorption3 = endLightAbsorption3 = newProfile.CloudLayer3.CloudLightAbsorption;
                startLightAbsorption4 = endLightAbsorption4 = newProfile.CloudLayer4.CloudLightAbsorption;
                startScale1           = endScale1 = newProfile.CloudLayer1.CloudNoiseScale;
                startScale2           = endScale2 = newProfile.CloudLayer2.CloudNoiseScale;
                startScale3           = endScale3 = newProfile.CloudLayer3.CloudNoiseScale;
                startScale4           = endScale4 = newProfile.CloudLayer4.CloudNoiseScale;
                startMultiplier1      = endMultiplier1 = newProfile.CloudLayer1.CloudNoiseMultiplier;
                startMultiplier2      = endMultiplier2 = newProfile.CloudLayer2.CloudNoiseMultiplier;
                startMultiplier3      = endMultiplier3 = newProfile.CloudLayer3.CloudNoiseMultiplier;
                startMultiplier4      = endMultiplier4 = newProfile.CloudLayer4.CloudNoiseMultiplier;
                startMaskScale1       = endMaskScale1 = newProfile.CloudLayer1.CloudNoiseMaskScale;
                startMaskScale2       = endMaskScale2 = newProfile.CloudLayer2.CloudNoiseMaskScale;
                startMaskScale3       = endMaskScale3 = newProfile.CloudLayer3.CloudNoiseMaskScale;
                startMaskScale4       = endMaskScale4 = newProfile.CloudLayer4.CloudNoiseMaskScale;
                startHeight1          = endHeight1 = newProfile.CloudLayer1.CloudHeight;
                startHeight2          = endHeight2 = newProfile.CloudLayer2.CloudHeight;
                startHeight3          = endHeight3 = newProfile.CloudLayer3.CloudHeight;
                startHeight4          = endHeight4 = newProfile.CloudLayer4.CloudHeight;
                _CloudProfile         = newProfile;
            }
            else if (endCover1 == 0.0f && endCover2 == 0.0f && endCover3 == 0.0f && endCover4 == 0.0f)
            {
                // transition from clouds to no clouds, start at old profile values
                startSharpness1       = endSharpness1 = oldProfile.CloudLayer1.CloudSharpness;
                startSharpness2       = endSharpness2 = oldProfile.CloudLayer2.CloudSharpness;
                startSharpness3       = endSharpness3 = oldProfile.CloudLayer3.CloudSharpness;
                startSharpness4       = endSharpness4 = oldProfile.CloudLayer4.CloudSharpness;
                startLightAbsorption1 = endLightAbsorption1 = oldProfile.CloudLayer1.CloudLightAbsorption;
                startLightAbsorption2 = endLightAbsorption2 = oldProfile.CloudLayer2.CloudLightAbsorption;
                startLightAbsorption3 = endLightAbsorption3 = oldProfile.CloudLayer3.CloudLightAbsorption;
                startLightAbsorption4 = endLightAbsorption4 = oldProfile.CloudLayer4.CloudLightAbsorption;
                startScale1           = endScale1 = oldProfile.CloudLayer1.CloudNoiseScale;
                startScale2           = endScale2 = oldProfile.CloudLayer2.CloudNoiseScale;
                startScale3           = endScale3 = oldProfile.CloudLayer3.CloudNoiseScale;
                startScale4           = endScale4 = oldProfile.CloudLayer4.CloudNoiseScale;
                startMultiplier1      = endMultiplier1 = oldProfile.CloudLayer1.CloudNoiseMultiplier;
                startMultiplier2      = endMultiplier2 = oldProfile.CloudLayer2.CloudNoiseMultiplier;
                startMultiplier3      = endMultiplier3 = oldProfile.CloudLayer3.CloudNoiseMultiplier;
                startMultiplier4      = endMultiplier4 = oldProfile.CloudLayer4.CloudNoiseMultiplier;
                startMaskScale1       = endMaskScale1 = oldProfile.CloudLayer1.CloudNoiseMaskScale;
                startMaskScale2       = endMaskScale2 = oldProfile.CloudLayer2.CloudNoiseMaskScale;
                startMaskScale3       = endMaskScale3 = oldProfile.CloudLayer3.CloudNoiseMaskScale;
                startMaskScale4       = endMaskScale4 = oldProfile.CloudLayer4.CloudNoiseMaskScale;
                startHeight1          = endHeight1 = oldProfile.CloudLayer1.CloudHeight;
                startHeight2          = endHeight2 = oldProfile.CloudLayer2.CloudHeight;
                startHeight3          = endHeight3 = oldProfile.CloudLayer3.CloudHeight;
                startHeight4          = endHeight4 = oldProfile.CloudLayer4.CloudHeight;

                // transition with old profile, the new profile is empty and can't be used for transition
                _CloudProfile = oldProfile;
            }
            else
            {
                // regular transition from one clouds to another, transition normally
                startScale1           = oldProfile.CloudLayer1.CloudNoiseScale;
                startScale2           = oldProfile.CloudLayer2.CloudNoiseScale;
                startScale3           = oldProfile.CloudLayer3.CloudNoiseScale;
                startScale4           = oldProfile.CloudLayer4.CloudNoiseScale;
                endScale1             = newProfile.CloudLayer1.CloudNoiseScale;
                endScale2             = newProfile.CloudLayer2.CloudNoiseScale;
                endScale3             = newProfile.CloudLayer3.CloudNoiseScale;
                endScale4             = newProfile.CloudLayer4.CloudNoiseScale;
                startMultiplier1      = oldProfile.CloudLayer1.CloudNoiseMultiplier;
                startMultiplier2      = oldProfile.CloudLayer2.CloudNoiseMultiplier;
                startMultiplier3      = oldProfile.CloudLayer3.CloudNoiseMultiplier;
                startMultiplier4      = oldProfile.CloudLayer4.CloudNoiseMultiplier;
                endMultiplier1        = newProfile.CloudLayer1.CloudNoiseMultiplier;
                endMultiplier2        = newProfile.CloudLayer2.CloudNoiseMultiplier;
                endMultiplier3        = newProfile.CloudLayer3.CloudNoiseMultiplier;
                endMultiplier4        = newProfile.CloudLayer4.CloudNoiseMultiplier;
                startMaskScale1       = oldProfile.CloudLayer1.CloudNoiseMaskScale;
                startMaskScale2       = oldProfile.CloudLayer2.CloudNoiseMaskScale;
                startMaskScale3       = oldProfile.CloudLayer3.CloudNoiseMaskScale;
                startMaskScale4       = oldProfile.CloudLayer4.CloudNoiseMaskScale;
                endMaskScale1         = newProfile.CloudLayer1.CloudNoiseMaskScale;
                endMaskScale2         = newProfile.CloudLayer2.CloudNoiseMaskScale;
                endMaskScale3         = newProfile.CloudLayer3.CloudNoiseMaskScale;
                endMaskScale4         = newProfile.CloudLayer4.CloudNoiseMaskScale;
                startSharpness1       = oldProfile.CloudLayer1.CloudSharpness;
                startSharpness2       = oldProfile.CloudLayer2.CloudSharpness;
                startSharpness3       = oldProfile.CloudLayer3.CloudSharpness;
                startSharpness4       = oldProfile.CloudLayer4.CloudSharpness;
                endSharpness1         = newProfile.CloudLayer1.CloudSharpness;
                endSharpness2         = newProfile.CloudLayer2.CloudSharpness;
                endSharpness3         = newProfile.CloudLayer3.CloudSharpness;
                endSharpness4         = newProfile.CloudLayer4.CloudSharpness;
                startLightAbsorption1 = oldProfile.CloudLayer1.CloudLightAbsorption;
                startLightAbsorption2 = oldProfile.CloudLayer2.CloudLightAbsorption;
                startLightAbsorption3 = oldProfile.CloudLayer3.CloudLightAbsorption;
                startLightAbsorption4 = oldProfile.CloudLayer4.CloudLightAbsorption;
                endLightAbsorption1   = newProfile.CloudLayer1.CloudLightAbsorption;
                endLightAbsorption2   = newProfile.CloudLayer2.CloudLightAbsorption;
                endLightAbsorption3   = newProfile.CloudLayer3.CloudLightAbsorption;
                endLightAbsorption4   = newProfile.CloudLayer4.CloudLightAbsorption;
                startHeight1          = oldProfile.CloudLayer1.CloudHeight;
                startHeight2          = oldProfile.CloudLayer2.CloudHeight;
                startHeight3          = oldProfile.CloudLayer3.CloudHeight;
                startHeight4          = oldProfile.CloudLayer4.CloudHeight;
                endHeight1            = newProfile.CloudLayer1.CloudHeight;
                endHeight2            = newProfile.CloudLayer2.CloudHeight;
                endHeight3            = newProfile.CloudLayer3.CloudHeight;
                endHeight4            = newProfile.CloudLayer4.CloudHeight;

                // use new profile for transition
                _CloudProfile = newProfile;
            }

            DeleteAndTransitionRenderProfile(_CloudProfile);

            // create temp object for animation, we don't want to modify variables in the actual assets during animation
            _CloudProfile = lastProfile = currentRenderCloudProfile = _CloudProfile.Clone();
            currentRenderCloudProfileIsTemporary = true;

            // animate animatable properties
            TweenFactory.Tween("WeatherMakerClouds", 0.0f, 1.0f, duration, TweenScaleFunctions.Linear, (ITween <float> c) =>
            {
                float progress = c.CurrentValue;
                currentRenderCloudProfile.CloudLayer1.CloudNoiseScale                  = Vector4.Lerp(startScale1, endScale1, progress);
                currentRenderCloudProfile.CloudLayer2.CloudNoiseScale                  = Vector4.Lerp(startScale2, endScale2, progress);
                currentRenderCloudProfile.CloudLayer3.CloudNoiseScale                  = Vector4.Lerp(startScale3, endScale3, progress);
                currentRenderCloudProfile.CloudLayer4.CloudNoiseScale                  = Vector4.Lerp(startScale4, endScale4, progress);
                currentRenderCloudProfile.CloudLayer1.CloudNoiseMultiplier             = Vector4.Lerp(startMultiplier1, endMultiplier1, progress);
                currentRenderCloudProfile.CloudLayer2.CloudNoiseMultiplier             = Vector4.Lerp(startMultiplier2, endMultiplier2, progress);
                currentRenderCloudProfile.CloudLayer3.CloudNoiseMultiplier             = Vector4.Lerp(startMultiplier3, endMultiplier3, progress);
                currentRenderCloudProfile.CloudLayer4.CloudNoiseMultiplier             = Vector4.Lerp(startMultiplier4, endMultiplier4, progress);
                currentRenderCloudProfile.CloudLayer1.CloudNoiseRotation.LastValue     = Mathf.Lerp(startRotation.x, endRotation.x, progress);
                currentRenderCloudProfile.CloudLayer2.CloudNoiseRotation.LastValue     = Mathf.Lerp(startRotation.y, endRotation.y, progress);
                currentRenderCloudProfile.CloudLayer3.CloudNoiseRotation.LastValue     = Mathf.Lerp(startRotation.z, endRotation.z, progress);
                currentRenderCloudProfile.CloudLayer4.CloudNoiseRotation.LastValue     = Mathf.Lerp(startRotation.w, endRotation.w, progress);
                currentRenderCloudProfile.CloudLayer1.CloudNoiseVelocity               = Vector3.Lerp(startVelocity1, endVelocity1, progress);
                currentRenderCloudProfile.CloudLayer2.CloudNoiseVelocity               = Vector3.Lerp(startVelocity2, endVelocity2, progress);
                currentRenderCloudProfile.CloudLayer3.CloudNoiseVelocity               = Vector3.Lerp(startVelocity3, endVelocity3, progress);
                currentRenderCloudProfile.CloudLayer4.CloudNoiseVelocity               = Vector3.Lerp(startVelocity4, endVelocity4, progress);
                currentRenderCloudProfile.CloudLayer1.CloudNoiseMaskScale              = Mathf.Lerp(startMaskScale1, endMaskScale1, progress);
                currentRenderCloudProfile.CloudLayer2.CloudNoiseMaskScale              = Mathf.Lerp(startMaskScale2, endMaskScale2, progress);
                currentRenderCloudProfile.CloudLayer3.CloudNoiseMaskScale              = Mathf.Lerp(startMaskScale3, endMaskScale3, progress);
                currentRenderCloudProfile.CloudLayer4.CloudNoiseMaskScale              = Mathf.Lerp(startMaskScale4, endMaskScale4, progress);
                currentRenderCloudProfile.CloudLayer1.CloudNoiseMaskRotation.LastValue = Mathf.Lerp(startMaskRotation.x, endMaskRotation.x, progress);
                currentRenderCloudProfile.CloudLayer2.CloudNoiseMaskRotation.LastValue = Mathf.Lerp(startMaskRotation.y, endMaskRotation.y, progress);
                currentRenderCloudProfile.CloudLayer3.CloudNoiseMaskRotation.LastValue = Mathf.Lerp(startMaskRotation.z, endMaskRotation.z, progress);
                currentRenderCloudProfile.CloudLayer4.CloudNoiseMaskRotation.LastValue = Mathf.Lerp(startMaskRotation.w, endMaskRotation.w, progress);
                currentRenderCloudProfile.CloudLayer1.CloudNoiseMaskVelocity           = Vector3.Lerp(startMaskVelocity1, endMaskVelocity1, progress);
                currentRenderCloudProfile.CloudLayer2.CloudNoiseMaskVelocity           = Vector3.Lerp(startMaskVelocity2, endMaskVelocity2, progress);
                currentRenderCloudProfile.CloudLayer3.CloudNoiseMaskVelocity           = Vector3.Lerp(startMaskVelocity3, endMaskVelocity3, progress);
                currentRenderCloudProfile.CloudLayer4.CloudNoiseMaskVelocity           = Vector3.Lerp(startMaskVelocity4, endMaskVelocity4, progress);
                currentRenderCloudProfile.CloudLayer1.CloudCover                   = Mathf.Lerp(startCover1, endCover1, progress);
                currentRenderCloudProfile.CloudLayer2.CloudCover                   = Mathf.Lerp(startCover2, endCover2, progress);
                currentRenderCloudProfile.CloudLayer3.CloudCover                   = Mathf.Lerp(startCover3, endCover3, progress);
                currentRenderCloudProfile.CloudLayer4.CloudCover                   = Mathf.Lerp(startCover4, endCover4, progress);
                currentRenderCloudProfile.CloudLayer1.CloudDensity                 = Mathf.Lerp(startDensity1, endDensity1, progress);
                currentRenderCloudProfile.CloudLayer2.CloudDensity                 = Mathf.Lerp(startDensity2, endDensity2, progress);
                currentRenderCloudProfile.CloudLayer3.CloudDensity                 = Mathf.Lerp(startDensity3, endDensity3, progress);
                currentRenderCloudProfile.CloudLayer4.CloudDensity                 = Mathf.Lerp(startDensity4, endDensity4, progress);
                currentRenderCloudProfile.CloudLayer1.CloudSharpness               = Mathf.Lerp(startSharpness1, endSharpness1, progress);
                currentRenderCloudProfile.CloudLayer2.CloudSharpness               = Mathf.Lerp(startSharpness2, endSharpness2, progress);
                currentRenderCloudProfile.CloudLayer3.CloudSharpness               = Mathf.Lerp(startSharpness3, endSharpness3, progress);
                currentRenderCloudProfile.CloudLayer4.CloudSharpness               = Mathf.Lerp(startSharpness4, endSharpness4, progress);
                currentRenderCloudProfile.CloudLayer1.CloudLightAbsorption         = Mathf.Lerp(startLightAbsorption1, endLightAbsorption1, progress);
                currentRenderCloudProfile.CloudLayer2.CloudLightAbsorption         = Mathf.Lerp(startLightAbsorption2, endLightAbsorption2, progress);
                currentRenderCloudProfile.CloudLayer3.CloudLightAbsorption         = Mathf.Lerp(startLightAbsorption3, endLightAbsorption3, progress);
                currentRenderCloudProfile.CloudLayer4.CloudLightAbsorption         = Mathf.Lerp(startLightAbsorption4, endLightAbsorption4, progress);
                currentRenderCloudProfile.CloudLayer1.CloudColor                   = Color.Lerp(startColor1, endColor1, progress);
                currentRenderCloudProfile.CloudLayer2.CloudColor                   = Color.Lerp(startColor2, endColor2, progress);
                currentRenderCloudProfile.CloudLayer3.CloudColor                   = Color.Lerp(startColor3, endColor3, progress);
                currentRenderCloudProfile.CloudLayer4.CloudColor                   = Color.Lerp(startColor4, endColor4, progress);
                currentRenderCloudProfile.CloudLayer1.CloudEmissionColor           = Color.Lerp(startEmissionColor1, endEmissionColor1, progress);
                currentRenderCloudProfile.CloudLayer2.CloudEmissionColor           = Color.Lerp(startEmissionColor2, endEmissionColor2, progress);
                currentRenderCloudProfile.CloudLayer3.CloudEmissionColor           = Color.Lerp(startEmissionColor3, endEmissionColor3, progress);
                currentRenderCloudProfile.CloudLayer4.CloudEmissionColor           = Color.Lerp(startEmissionColor4, endEmissionColor4, progress);
                currentRenderCloudProfile.CloudLayer1.CloudAmbientMultiplier       = Mathf.Lerp(startAmbientMultiplier1, endAmbientMultiplier1, progress);
                currentRenderCloudProfile.CloudLayer2.CloudAmbientMultiplier       = Mathf.Lerp(startAmbientMultiplier2, endAmbientMultiplier2, progress);
                currentRenderCloudProfile.CloudLayer3.CloudAmbientMultiplier       = Mathf.Lerp(startAmbientMultiplier3, endAmbientMultiplier3, progress);
                currentRenderCloudProfile.CloudLayer4.CloudAmbientMultiplier       = Mathf.Lerp(startAmbientMultiplier4, endAmbientMultiplier4, progress);
                currentRenderCloudProfile.CloudLayer1.CloudHeight                  = Mathf.Lerp(startHeight1, endHeight1, progress);
                currentRenderCloudProfile.CloudLayer2.CloudHeight                  = Mathf.Lerp(startHeight2, endHeight2, progress);
                currentRenderCloudProfile.CloudLayer3.CloudHeight                  = Mathf.Lerp(startHeight3, endHeight3, progress);
                currentRenderCloudProfile.CloudLayer4.CloudHeight                  = Mathf.Lerp(startHeight4, endHeight4, progress);
                currentRenderCloudProfile.DirectionalLightIntensityMultiplier      = Mathf.Lerp(startDirectionalLightIntensityMultiplier, endDirectionalLightIntensityMultiplier, progress);
                currentRenderCloudProfile.DirectionalLightShadowStrengthMultiplier = Mathf.Lerp(startDirectionalLightShadowStrengthMultiplier, endDirectionalLightShadowStrengthMultiplier, progress);
            }, (ITween <float> c) =>
            {
                DeleteAndTransitionRenderProfile(newProfile);
                currentRenderCloudProfileIsTemporary = false;
            });
        }
 /// <summary>
 /// Animate wind intensity change
 /// </summary>
 /// <param name="value">New intensity</param>
 /// <param name="duration">Animation duration</param>
 public void AnimateWindIntensity(float value, float duration)
 {
     TweenFactory.Tween("WeatherMakerWindIntensity", WindIntensity, value, duration, TweenScaleFunctions.Linear, (t) => WindIntensity = t.CurrentValue, null);
 }
 private void UpdateWind()
 {
     if (WindIntensity > 0.0f)
     {
         WindZone.windMain = MaximumWindSpeed * WindIntensity * WindMainMultiplier;
         if (WindTurbulenceRange.Maximum > 0.0f || WindPulseMagnitudeRange.Maximum > 0.0f ||
             WindPulseFrequencyRange.Maximum > 0.0f || WindDirection != lastWindDirection)
         {
             lastWindDirection = WindDirection = WindDirection.normalized;
             if (WeatherScript.Camera != null)
             {
                 WindZone.transform.position = WeatherScript.Camera.transform.position;
                 if (!WeatherScript.Camera.orthographic)
                 {
                     WindZone.transform.Translate(0.0f, WindZone.radius, 0.0f);
                 }
             }
             if (nextWindTime < Time.time)
             {
                 if (WindTurbulenceRange.Maximum > 0.0f)
                 {
                     WindZone.windTurbulence = WindTurbulenceRange.Random();
                 }
                 if (WindPulseMagnitudeRange.Maximum > 0.0f)
                 {
                     WindZone.windPulseMagnitude = WindPulseMagnitudeRange.Random();
                 }
                 if (WindPulseFrequencyRange.Maximum > 0.0f)
                 {
                     WindZone.windPulseFrequency = WindPulseFrequencyRange.Random();
                 }
                 if (RandomWindDirection)
                 {
                     if (WeatherScript.Camera != null && WeatherScript.Camera.orthographic)
                     {
                         int val = UnityEngine.Random.Range(0, 2);
                         WindZone.transform.rotation = Quaternion.Euler(0.0f, (val == 0 ? 90.0f : -90.0f), 0.0f);
                     }
                     else
                     {
                         float xAxis = (AllowBlowUp ? UnityEngine.Random.Range(-30.0f, 30.0f) : 0.0f);
                         WindZone.transform.rotation = Quaternion.Euler(xAxis, UnityEngine.Random.Range(0.0f, 360.0f), 0.0f);
                     }
                     WindDirection = WindZone.transform.forward;
                 }
                 else if (WeatherScript.Camera.orthographic)
                 {
                     WindZone.transform.right = new Vector3(WindDirection.x, WindDirection.y, 0.0f);
                 }
                 else
                 {
                     WindZone.transform.forward = WindDirection;
                 }
                 nextWindTime = Time.time + WindChangeInterval.Random();
             }
         }
         AudioSourceWind.Play(WindIntensity * WindSoundMultiplier);
         Vector3 newVelocity = WindDirection * WindZone.windMain;
         if (newVelocity != CurrentWindVelocity)
         {
             if (FogVelocityMultiplier != 0.0f && WeatherScript.FogScript != null)
             {
                 Vector3 fogVelocityOld = WeatherScript.FogScript.FogNoiseVelocity;
                 Vector3 fogVelocity    = new Vector3(newVelocity.x * FogVelocityMultiplier, newVelocity.z * FogVelocityMultiplier, 0.0f);
                 TweenFactory.Tween("WeatherMakerWindScriptFogVelocity", fogVelocityOld, fogVelocity, (nextWindTime - Time.time) * 1.1f, TweenScaleFunctions.Linear, (p) =>
                 {
                     WeatherScript.FogScript.FogNoiseVelocity = p.CurrentValue;
                 }, null);
             }
             CurrentWindVelocity = newVelocity;
             if (WindChanged != null)
             {
                 WindChanged(newVelocity);
             }
         }
     }
     else
     {
         AudioSourceWind.Stop();
         WindZone.windMain   = WindZone.windTurbulence = WindZone.windPulseFrequency = WindZone.windPulseMagnitude = 0.0f;
         CurrentWindVelocity = Vector3.zero;
     }
     AudioSourceWind.Update();
 }