コード例 #1
0
        public static WeatherMakerProfileScript OverrideProfile
        (
            WeatherMakerProfileScript profile,
            WeatherMakerCloudProfileScript cloudProfile,
            WeatherMakerSkyProfileScript skyProfile,
            WeatherMakerAuroraProfileScript auroraProfile,
            WeatherMakerPrecipitationProfileScript precipitationProfile,
            WeatherMakerFullScreenFogProfileScript fogProfile,
            WeatherMakerWindProfileScript windProfile,
            WeatherMakerLightningProfileScript lightningProfile,
            WeatherMakerSoundProfileScript soundProfile,
            RangeOfFloats transitionDuration,
            RangeOfFloats holdDuration
        )
        {
            if (profile == null)
            {
                Debug.LogError("Null profile in Weather Maker profile OverrideProfile, this is not allowed");
                return(null);
            }

            // check for overrides, if so clone the profile
            else if (cloudProfile != null || skyProfile != null || auroraProfile != null || precipitationProfile != null || fogProfile != null ||
                     windProfile != null || lightningProfile != null || soundProfile != null || transitionDuration.Maximum > 0.0f || holdDuration.Maximum > 0.0f)
            {
                if (profile.name.IndexOf("(clone)", System.StringComparison.OrdinalIgnoreCase) < 0)
                {
                    profile = ScriptableObject.Instantiate(profile);
                }
                AssignOverride(ref profile.CloudProfile, cloudProfile);
                AssignOverride(ref profile.SkyProfile, skyProfile);
                AssignOverride(ref profile.AuroraProfile, auroraProfile);
                AssignOverride(ref profile.PrecipitationProfile, precipitationProfile);
                AssignOverride(ref profile.FogProfile, fogProfile);
                AssignOverride(ref profile.WindProfile, windProfile);
                AssignOverride(ref profile.LightningProfile, lightningProfile);
                AssignOverride(ref profile.SoundProfile, soundProfile);
                if (transitionDuration.Maximum > 0.0f)
                {
                    profile.TransitionDuration = transitionDuration;
                }
                if (holdDuration.Maximum > 0.0f)
                {
                    profile.HoldDuration = holdDuration;
                }
            }

            return(profile);
        }
コード例 #2
0
        /// <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();
                }
            }
        }