예제 #1
0
 /// <summary>
 /// Iterates over all IntensityDrivenBehaviours held by this object and updates the intensity of each
 /// </summary>
 /// <param name="intensity">The new intensity to apply</param>
 public virtual void ApplyIntensity(IntensityData intensityData)
 {
     foreach (IntensityDrivenBehaviour intensityBehaviour in drivenComponents)
     {
         intensityBehaviour.IntensityData = intensityData;
     }
 }
        /// <summary>
        /// Calculates an intensity from the parents intensity, weighted by curves,
        /// then applies that intensity value to all IntensityComponentCurves
        /// </summary>
        /// <param name="intensity">An ignored intensity value, as it is calculated from the parents. Can be anything</param>
        public override void ApplyIntensity(IntensityData intensityData)
        {
            IntensityData totalIntensity = new IntensityData(0.0f, intensityData.temperature, intensityData.humidity, intensityData.wind, intensityData.weatherType);

            for (int i = 0; i < intensityParentWeightings.Length; i++)
            {
                totalIntensity.intensity += intensityParentWeightings[i].weightingCurve.Evaluate(intensityData.intensity);
            }

            totalIntensity.intensity /= (float)intensityParentWeightings.Length;

            //Then apply calculated data
            base.ApplyIntensity(totalIntensity);
        }
예제 #3
0
        private ReliantWeatherProperty[] reliantWeatherProperties; //name must stay as seen for WeatherEventEditor

        /// <summary>
        /// Iterates over all held WeatherPropertys and updates them with the new intensity value
        /// Then notifies all reliant weather properties to update
        /// </summary>
        /// <param name="intensityData">The new intensity values</param>
        /// <param name="intensityCurves">A set of intensity curves to calculate a new iontensity value for each
        /// WeatherProperty. Must match the total number of Non-Reliant and Reliant WeatherProperties</param>
        public virtual void ApplyIntensity(IntensityData intensityData, AnimationCurve[] intensityCurves = null)
        {
            if (intensityCurves == null)
            {
                //apply changes to non reliant
                foreach (WeatherProperty weatherProperty in weatherProperties)
                {
                    weatherProperty.ApplyIntensity(intensityData);
                }

                //then notify reliant to update
                foreach (ReliantWeatherProperty reliantWeatherProperty in reliantWeatherProperties)
                {
                    //The passed intensity value doesn't matter here as RealiantWeatherPropertys calculate their own values
                    //from the parents they rely on... hence the name, but we'll pass through the other data in case that's needed
                    reliantWeatherProperty.ApplyIntensity(intensityData);
                }
            }
            else
            {
                if (intensityCurves.Length != weatherProperties.Length + reliantWeatherProperties.Length)
                {
                    Debug.LogError("Curve length mis-match (" + intensityCurves.Length + " vs " + (weatherProperties.Length + reliantWeatherProperties.Length).ToString() + "), open in the editor to refresh the curves");
                }

                for (int i = 0; i < weatherProperties.Length; i++)
                {
                    IntensityData evaluatedIntensity = new IntensityData(intensityCurves[i].Evaluate(intensityData.intensity), intensityData.temperature, intensityData.humidity, intensityData.wind, intensityData.weatherType);
                    weatherProperties[i].ApplyIntensity(evaluatedIntensity);
                }

                for (int i = 0; i < reliantWeatherProperties.Length; i++)
                {
                    int           index = i + weatherProperties.Length;
                    IntensityData evaluatedIntensity = new IntensityData(intensityCurves[index].Evaluate(intensityData.intensity), intensityData.temperature, intensityData.humidity, intensityData.wind, intensityData.weatherType);
                    reliantWeatherProperties[i].ApplyIntensity(evaluatedIntensity);
                }
            }
        }