Example #1
0
        public override void Update()
        {
#if UNITY_EDITOR
            if (!Application.isPlaying || WeatherMakerScript.Instance == null)
            {
                return;
            }
            else
#endif

            if (AudioSourceLoop == null)
            {
                return;
            }
            else if (AudioSourceLoop.AudioSource.isPlaying)
            {
                // see if we need to stop
                if (!AudioSourceLoop.Stopping && ((timeRemainingToPlay -= Time.deltaTime) < 0.0f && IntervalRange.Minimum > 0.0f) || !CanStartSound())
                {
                    Stop();
                }
            }
            // check if it is the right time of day to play the ambient sound
            else if (CanStartSound())
            {
                if (timeToNextPlay <= 0.0f && IntervalRange.Minimum > 0.0f)
                {
                    CalculateNextPlay();
                }
                // check if it is time to play
                else if ((timeToNextPlay -= Time.deltaTime) < 0.0f)
                {
                    timeToNextPlay      = 0.0f;
                    timeRemainingToPlay = (!Looping || DurationRange.Maximum <= 0.0f ? float.MaxValue : DurationRange.Random());
                    float startFade = Looping ? FadeDuration.Random() : 0.0f;
                    float endFade   = Looping ? FadeDuration.Random() : 0.0f;
                    AudioSourceLoop.SetFade(startFade, endFade);
                    AudioSourceLoop.AudioSource.clip = AudioClips[UnityEngine.Random.Range(0, AudioClips.Length)];
                    AudioSourceLoop.Play(VolumeRange.Random());

#if ENABLE_DEBUG_LOG_WEATHER_MAKER_SOUNDS
                    if (Looping)
                    {
                        Debug.LogFormat("Weather Maker playing sound {0} for {1} seconds", Name, (timeRemainingToPlay == float.MaxValue ? "Infinite" : timeRemainingToPlay.ToString("0.00")));
                    }
                    else
                    {
                        Debug.LogFormat("Weather Maker playing sound {0} for {1:0.00} seconds", Name, AudioClip.length);
                    }
#endif
                }
            }
            else
            {
                timeToNextPlay = 0.0f;
            }
            AudioSourceLoop.VolumeModifier = WeatherMakerScript.Instance.cachedVolumeModifier;
            AudioSourceLoop.Update();
        }
        protected override void PopulateParameters(LightningBoltParameters p)
        {
            base.PopulateParameters(p);

            p.RandomOverride = RandomOverride;
            float duration   = DurationRange.Random(p.Random);
            float trunkWidth = TrunkWidthRange.Random(p.Random);

            p.Generations            = Generations;
            p.LifeTime               = duration;
            p.ChaosFactor            = ChaosFactor;
            p.ChaosFactorForks       = ChaosFactorForks;
            p.TrunkWidth             = trunkWidth;
            p.Intensity              = Intensity;
            p.GlowIntensity          = GlowIntensity;
            p.GlowWidthMultiplier    = GlowWidthMultiplier;
            p.Forkedness             = Forkedness;
            p.ForkLengthMultiplier   = ForkLengthMultiplier;
            p.ForkLengthVariance     = ForkLengthVariance;
            p.FadePercent            = FadePercent;
            p.FadeInMultiplier       = FadeInMultiplier;
            p.FadeOutMultiplier      = FadeOutMultiplier;
            p.FadeFullyLitMultiplier = FadeFullyLitMultiplier;
            p.GrowthMultiplier       = GrowthMultiplier;
            p.EndWidthMultiplier     = EndWidthMultiplier;
            p.ForkEndWidthMultiplier = ForkEndWidthMultiplier;
            p.DelayRange             = DelayRange;
            p.LightParameters        = LightParameters;
        }
Example #3
0
            /// <summary>
            /// Show clouds from a mesh
            /// </summary>
            /// <param name="mesh">Mesh</param>
            /// <param name="lifeTimeRange">Life time range</param>
            /// <param name="fadeTimeRange">Range of fade time for each cloud</param>
            /// <param name="fadeTimeDelayRange">Amount to add to the delay for fading for each subsequent cloud</param>
            public static void ShowClouds(Mesh mesh, RangeOfFloats lifeTimeRange, RangeOfFloats fadeTimeRange, RangeOfFloats fadeTimeDelayRange)
            {
                if (mesh == null)
                {
                    return;
                }

                List <Vector4> lifeTimes = new List <Vector4>(mesh.vertexCount);
                float          fadeDelay = 0.0f;

                for (int i = 0; i < mesh.vertexCount / 4; i++)
                {
                    float   fadeTime      = fadeTimeRange.Random();
                    float   totalLifeTime = lifeTimeRange.Random();
                    float   creationTime  = Time.timeSinceLevelLoad + fadeDelay;
                    Vector4 lifeTime      = new Vector4(creationTime, fadeTime, totalLifeTime);
                    fadeDelay += fadeTimeDelayRange.Random();
                    lifeTimes.Add(lifeTime);
                    lifeTimes.Add(lifeTime);
                    lifeTimes.Add(lifeTime);
                    lifeTimes.Add(lifeTime);
                }

                mesh.SetUVs(1, lifeTimes);
            }
        private void StartNewTransitionGroup(WeatherMakerTransitionGroupWeight w)
        {
            currentTransition = w;

            // turn off things that don't need to be setup on every transition
            WeatherScript.LightningScript.EnableLightning = false;
            foreach (WeatherMakerPropertyTransition t in w.TransitionGroup.Transitions)
            {
                t.UpdateStartValue();
            }

            // store properties in case they are not animated - for this we will lerp these to low or 0 values as we want them essentially off by default unless they are animated
            startPrecipitationIntensity = WeatherScript.PrecipitationIntensity;
            startFogDensity             = WeatherScript.FogScript.FogDensity;
            startWindIntensity          = WeatherScript.WindIntensity;

            currentTransition.CustomUpdater = CustomUpdater;

            // how long the group transition lasts
            transitionTime = TransitionTime.Random();
            holdTime       = HoldTime.Random();
            totalTime      = transitionTime;
            WeatherScript.CloudChangeDuration = (UseBuiltInCloudAnimation ? transitionTime : 0.0f);
            holdingTransition = false;
            Debug.LogFormat("Starting Weather Transition {0}, transition time: {1:0.00}, hold time: {2:0.00}", w.TransitionGroup.Title, transitionTime, holdTime);
        }
        protected override Vector3 CalculateStartPosition(ref Vector3 anchorPosition, Camera visibleInCamera, bool intense)
        {
            Vector3 start = anchorPosition;
            Vector3 randomDir;

            if (visibleInCamera == null)
            {
                randomDir = UnityEngine.Random.onUnitSphere;
            }
            else
            {
                Vector3 randomScreenPoint = new Vector3
                                            (
                    UnityEngine.Random.Range((float)visibleInCamera.pixelWidth * 0.3f, (float)visibleInCamera.pixelWidth * 0.7f),
                    UnityEngine.Random.Range((float)visibleInCamera.pixelHeight * 0.3f, (float)visibleInCamera.pixelHeight * 0.7f),
                    Random.Range(visibleInCamera.nearClipPlane, visibleInCamera.farClipPlane)
                                            );
                randomDir = (visibleInCamera.ScreenToWorldPoint(randomScreenPoint) - visibleInCamera.transform.position).normalized;
            }
            start   += (randomDir * (intense ? IntenseDistance.Random() : NormalDistance.Random()));
            start.x += StartXVariance.Random();
            start.y  = StartYVariance.Random() + StartYBase.Random();
            start.z += StartZVariance.Random();

            // if the start is too close to the anchor point, push it back
            float minDistance = (intense ? IntenseDistance.Minimum : NormalDistance.Minimum);

            if (Vector3.Distance(start, anchorPosition) < minDistance)
            {
                Vector3 startDir = (start - anchorPosition).normalized;
                start = anchorPosition + (startDir * minDistance);
            }

            return(start);
        }
        /// <summary>
        /// Begin a new transition group
        /// </summary>
        /// <param name="index">Index of the group in Transitions</param>
        /// <param name="randomSeed">Random seed</param>
        public void StartNewTransitionGroup(int index, int randomSeed)
        {
            Initialize(randomSeed);
            currentTransition = Transitions[index];
            transitionTime    = TransitionTime.Random(random);
            holdTime          = HoldTime.Random(random);
            totalTime         = transitionTime;

            Debug.LogFormat("Starting Weather Transition {0}, transition time: {1:0.00}, hold time: {2:0.00}", currentTransition.TransitionGroup.Title, transitionTime, holdTime);

            // turn off things that don't need to be setup on every transition
            WeatherMakerScript.Instance.LightningScript.EnableLightning = false;
            foreach (WeatherMakerPropertyTransition t in currentTransition.TransitionGroup.Transitions)
            {
                t.UpdateStartValue();
            }

            // store properties in case they are not animated - for this we will lerp these to low or 0 values as we want them essentially off by default unless they are animated
            startPrecipitationIntensity = WeatherMakerScript.Instance.PrecipitationIntensity;
            startFogDensity             = (WeatherMakerScript.Instance.FogScript.FogProfile == null ? 0.0f : WeatherMakerScript.Instance.FogScript.FogProfile.FogDensity);
            startWindIntensity          = WeatherMakerScript.Instance.WindIntensity;

            currentTransition.CustomUpdater = CustomUpdater;

            // how long the group transition lasts
            WeatherMakerScript.Instance.CloudChangeDuration = (UseBuiltInCloudAnimation ? transitionTime : 0.0f);
            holdingTransition = false;

            WeatherMakerScript.Instance.RaiseWeatherManagerTransitionStarted(WeatherMakerScript.Instance.WeatherManagers.IndexOf(this), index, randomSeed);
        }
Example #7
0
        private void CalculateNextPlay(float delay = 0.0f)
        {
            timeToNextPlay = IntervalRange.Random() + delay;

#if ENABLE_DEBUG_LOG_WEATHER_MAKER_SOUNDS
            Debug.LogFormat("Weather Maker sound {0} will play in {1:0.00} seconds", Name, timeToNextPlay);
#endif
        }
Example #8
0
        private void CheckForPrecipitationChange()
        {
            if (Precipitation != precipitation)
            {
                precipitation = Precipitation;
                switch (precipitation)
                {
                default:
                    ChangePrecipitation(null);
                    break;

                case WeatherMakerPrecipitationType.Rain:
                    ChangePrecipitation(RainScript);
                    break;

                case WeatherMakerPrecipitationType.Snow:
                    ChangePrecipitation(SnowScript);
                    break;

                case WeatherMakerPrecipitationType.Hail:
                    ChangePrecipitation(HailScript);
                    break;

                case WeatherMakerPrecipitationType.Sleet:
                    ChangePrecipitation(SleetScript);
                    break;

                case WeatherMakerPrecipitationType.Custom:
                    ChangePrecipitation(CustomPrecipitationScript);
                    break;
                }
            }

            // pick new intensity if profile says to do so
            if (nextIntensityChangeSeconds > 0.0f && (nextIntensityChangeSeconds -= Time.deltaTime) <= 0.0f)
            {
                if (!transitionInProgress)
                {
                    PrecipitationIntensity = nextIntensityChangeRange.Random();
                }
                nextIntensityChangeSeconds = nextIntensityDurationRange.Random();
            }

            if (PrecipitationScript != null && PrecipitationIntensity != lastPrecipitationIntensity)
            {
                lastPrecipitationIntensity = PrecipitationIntensity;
                TweenPrecipitationScript(PrecipitationScript, PrecipitationIntensity);
                PrecipitationScript.PrecipitationTintColor          = precipitationTintColor;
                PrecipitationScript.PrecipitationMistTintColor      = precipitationMistTintColor;
                PrecipitationScript.PrecipitationSecondaryTintColor = precipitationSecondaryTintColor;
            }
        }
Example #9
0
            /// <summary>
            /// Hide clouds from a mesh
            /// </summary>
            /// <param name="mesh">Mesh</param>
            /// <param name="fadeTimeRange">Range of fade time for each cloud</param>
            /// <param name="fadeTimeDelayRange">Amount to add to the delay for fading for each subsequent cloud</param>
            public static void HideClouds(Mesh mesh, RangeOfFloats fadeTimeRange, RangeOfFloats fadeTimeDelayRange)
            {
                if (mesh == null)
                {
                    return;
                }

                List <Vector4> lifeTimes = new List <Vector4>(mesh.vertexCount);
                float          fadeDelay = 0.0f;

                mesh.GetUVs(1, lifeTimes);

                for (int i = 0; i < lifeTimes.Count;)
                {
                    float   fadeTime = fadeTimeRange.Random();
                    Vector4 lifeTime = lifeTimes[i];
                    lifeTime.y     = fadeTimeRange.Random();
                    lifeTime.z     = (Time.timeSinceLevelLoad - lifeTime.x) + fadeTime + fadeDelay;
                    fadeDelay     += fadeTimeDelayRange.Random();
                    lifeTimes[i++] = lifeTimes[i++] = lifeTimes[i++] = lifeTimes[i++] = lifeTime;
                }

                mesh.SetUVs(1, lifeTimes);
            }
        protected override Vector3 CalculateStartPosition(ref Vector3 anchorPosition, Camera visibleInCamera, bool intense)
        {
            Vector3 start = anchorPosition;
            Vector3 randomDir;

            if (visibleInCamera == null)
            {
                randomDir = UnityEngine.Random.onUnitSphere;
            }
            else
            {
                Vector3 randomScreenPoint = new Vector3
                                            (
                    UnityEngine.Random.Range((float)Screen.width * 0.2f, (float)Screen.width * 0.8f),
                    UnityEngine.Random.Range((float)Screen.height * 0.2f, (float)Screen.height * 0.8f),
                    visibleInCamera.farClipPlane * 0.5f
                                            );
                randomDir = visibleInCamera.ScreenToWorldPoint(randomScreenPoint).normalized;
            }
            randomDir.y = Mathf.Abs(randomDir.y);
            randomDir  *= (intense ? IntenseDistance.Random() : NormalDistance.Random());
            randomDir.y = StartYBase.Random();
            start      += randomDir;
            start.x    += StartXVariance.Random();
            start.y    += StartYVariance.Random();
            start.z    += StartZVariance.Random();

            // if the start is too close to the anchor point, push it back
            float minDistance = (intense ? IntenseDistance.Minimum : NormalDistance.Minimum);

            if (Vector3.Distance(start, anchorPosition) < minDistance)
            {
                Vector3 startDir = (start - anchorPosition).normalized;
                start = anchorPosition + (startDir * minDistance);
            }

            return(start);
        }
        private void UpdateWind()
        {
            if (EnableWind && WindZone != null && WindSpeedRange.y > 1.0f)
            {
                WindZone.gameObject.SetActive(true);
                if (Camera != null)
                {
                    WindZone.transform.position = Camera.transform.position;
                    if (!Camera.orthographic)
                    {
                        WindZone.transform.Translate(0.0f, WindZone.radius, 0.0f);
                    }
                }
                if (nextWindTime < Time.time)
                {
                    WindZone.windMain       = UnityEngine.Random.Range(WindSpeedRange.x, WindSpeedRange.y);
                    WindZone.windTurbulence = UnityEngine.Random.Range(WindSpeedRange.x, WindSpeedRange.y);
                    if (Camera != null && 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);
                    }
                    nextWindTime = Time.time + WindChangeInterval.Random();
                    AudioSourceWind.Play((WindZone.windMain / WindSpeedRange.z));
                }
            }
            else
            {
                AudioSourceWind.Stop();
            }

            AudioSourceWind.Update();
        }
 private void CalculateNextLightningTimestamp(float offset)
 {
     nextLightningTimestamp = (IntervalRange.Minimum == IntervalRange.Maximum ? IntervalRange.Minimum : offset + IntervalRange.Random());
 }
Example #13
0
 public float RandomHoldDuration()
 {
     return(HoldDuration.Maximum <= 0.0f ? 10.0f : HoldDuration.Random());
 }
Example #14
0
 public float RandomTransitionDuration()
 {
     return(TransitionDuration.Maximum <= 0.0f ? 10.0f : TransitionDuration.Random());
 }
        private void UpdateWind()
        {
            // put wind on top of camera
            if (WeatherMakerScript.Instance.Camera != null)
            {
                WindZone.transform.position = WeatherMakerScript.Instance.Camera.transform.position;
                if (!WeatherMakerScript.Instance.CameraIsOrthographic)
                {
                    WindZone.transform.Translate(0.0f, WindZone.radius, 0.0f);
                }
            }

            if (WindIntensity > 0.0f && MaximumWindSpeed > 0.0f && WindMainMultiplier > 0.0f)
            {
                WindZone.windMain = MaximumWindSpeed * WindIntensity * WindMainMultiplier;

                // update wind audio if wind intensity changed
                if (WindZone.windMain != lastWindIntensity)
                {
                    AudioSourceWind.Play(WindIntensity * WindSoundMultiplier);
                }
                lastWindIntensity = WindZone.windMain;

                // check for wind change
                if (windNextChangeTime <= Time.time)
                {
                    // update to new wind
                    windNextChangeTime = Time.time + WindChangeInterval.Random();
                    windChangeTotal    = 0.0f;
                    if (WindChangeInterval.Minimum > 0.0f && WindChangeInterval.Maximum >= WindChangeInterval.Minimum)
                    {
                        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 random wind, pick a new direction from wind
                    if (RandomWindDirection)
                    {
                        // 2D is set immediately
                        if (WeatherMakerScript.Instance.CameraIsOrthographic)
                        {
                            int val = UnityEngine.Random.Range(0, 2);
                            WindZone.transform.rotation = Quaternion.Euler(0.0f, -90.0f + (180.0f * val), 0.0f);
                        }
                        // 3D is lerped over time
                        else
                        {
                            float xAxis = (AllowBlowUp ? UnityEngine.Random.Range(-30.0f, 30.0f) : 0.0f);
                            windChangeRotationStart = WindZone.transform.rotation;
                            windChangeRotationEnd   = Quaternion.Euler(xAxis, UnityEngine.Random.Range(0.0f, 360.0f), 0.0f);
                            windChangeElapsed       = 0.0f;
                            windChangeTotal         = WindChangeRotationDurationPercent.Random() * (windNextChangeTime - Time.time);
                        }
                    }
                    // else use the WindZone transform rotation as is
                }
                // no change, update lerp for wind direction if needed
                else if (windChangeTotal != 0.0f)
                {
                    WindZone.transform.rotation = Quaternion.Lerp(windChangeRotationStart, windChangeRotationEnd, windChangeElapsed / windChangeTotal);
                    windChangeElapsed           = Mathf.Min(windChangeTotal, windChangeElapsed + Time.deltaTime);
                }
                Vector3 newVelocity     = WindZone.transform.forward * WindZone.windMain;
                bool    velocityChanged = newVelocity != CurrentWindVelocity;
                CurrentWindVelocity = newVelocity;
                if (velocityChanged && WindChanged != null)
                {
                    WindChanged(newVelocity);
                }
                if (FogVelocityMultiplier != 0.0f && WeatherMakerScript.Instance.FogScript != null && WeatherMakerScript.Instance.FogScript.FogProfile != null)
                {
                    WeatherMakerScript.Instance.FogScript.FogProfile.FogNoiseVelocity = CurrentWindVelocity * FogVelocityMultiplier;
                }
            }
            else
            {
                AudioSourceWind.Stop();
                WindZone.windMain   = WindZone.windTurbulence = WindZone.windPulseFrequency = WindZone.windPulseMagnitude = 0.0f;
                CurrentWindVelocity = Vector3.zero;
            }
            AudioSourceWind.Update();
        }
 private void Start()
 {
     initialPos    = startPos = transform.position;
     _light        = GetComponent <Light>();
     _meshRenderer = GetComponent <MeshRenderer>();
     if (_meshRenderer == null && transform.parent != null)
     {
         _meshRenderer = transform.parent.GetComponent <MeshRenderer>();
         if (_meshRenderer != null)
         {
             moveTransform = _meshRenderer.transform;
         }
     }
     if (moveTransform == null)
     {
         moveTransform = transform;
     }
     meshRenderer2    = transform.childCount == 0 ? null : transform.GetChild(0).GetComponent <MeshRenderer>();
     _light.color     = new Color(Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f));
     _light.intensity = baseIntensity = (IntensityRange.Maximum <= 0.0f ? (_light.intensity * Random.Range(0.5f, 1.5f)) : IntensityRange.Random());
     if (_light.type == LightType.Spot)
     {
         _light.range     = (LightRange.Maximum <= 0.0f ? Random.Range(100.0f, 200.0f) : LightRange.Random());
         _light.spotAngle = Random.Range(30.0f, 90.0f);
         if (_meshRenderer != null)
         {
             moveTransform.localScale *= (_light.range / 200.0f);
             Vector2 movement = Random.insideUnitCircle * Random.Range(-Range, Range);
             moveTransform.Translate(movement.x, 0.0f, movement.y);
         }
     }
     else if (_light.type == LightType.Point)
     {
         _light.range              = (LightRange.Maximum <= 0.0f ? Random.Range(32.0f, 64.0f) : LightRange.Random());
         moveTransform.localScale *= (_light.range / 100.0f);
     }
     if (_meshRenderer != null)
     {
         _meshRenderer.sharedMaterial = new Material(_meshRenderer.sharedMaterial);
         _meshRenderer.sharedMaterial.SetColor(WMS._EmissionColor, _light.color);
     }
     if (meshRenderer2 != null)
     {
         meshRenderer2.sharedMaterial = new Material(_meshRenderer.sharedMaterial);
         meshRenderer2.sharedMaterial.SetColor(WMS._EmissionColor, Color.gray);
     }
 }
 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();
 }
Example #18
0
 private void CalculateNextLightningTime()
 {
     NextLightningTime = Time.time + LightningIntervalTimeRange.Random();
     LightningInProgress = false;
 }
 private void CalculateNextLightningTime()
 {
     NextLightningTime = Time.time + LightningIntervalTimeRange.Random();
 }