/// <summary>
        /// Updates emmission rates and the gravity modifier based on the given intensity data
        /// </summary>
        /// <param name="intensityData">Intensity data</param>
        protected override void ConditionalUpdateWithIntensity(IntensityData intensityData)
        {
            float value = precipitationRateCurve.Evaluate(intensityData.intensity);

            emmisionModule.rateOverTime = value * emissionRateMultiplier;
            mainModule.gravityModifier  = intensityData.intensity * gravityMultiplier;
        }
        protected override void UpdateWithIntensity(IntensityData intensityData)
        {
            RenderSettings.fogDensity = intensityData.intensity * fogDensityScale;

            RenderSettings.fogStartDistance = intensityData.intensity * fogStartScale;
            RenderSettings.fogEndDistance   = RenderSettings.fogStartDistance + fogLength;
        }
示例#3
0
        private void AddHeatChartFromFile(Panel heatpanel, IntensityData idata)
        {
            LiveCharts.WinForms.CartesianChart heatchart;
            heatchart                   = new LiveCharts.WinForms.CartesianChart();
            heatchart.Size              = new Size(heatSizeX, heatSizeY);
            heatchart.Anchor            = (AnchorStyles.Left | AnchorStyles.Right);
            heatchart.Left              = 0;
            heatchart.Top               = 50;
            heatchart.DisableAnimations = true;
            heatchart.Hoverable         = false;
            heatchart.DataTooltip       = null;

            ChartValues <HeatPoint> values = new ChartValues <HeatPoint>();
            List <HeatPoint>        buffer = new List <HeatPoint>();

            for (int i = 0; i < idata.intensityData.Count(); i++)
            {
                Backend.Model.AggregatedData agregateddata = idata.intensityData[i];
                for (int j = 0; j < agregateddata.aggregatedData.Count(); j++)
                {
                    buffer.Add(new HeatPoint(j, i, agregateddata.aggregatedData[j]));
                }
            }
            values.AddRange(buffer);
            HeatSeries hs = new HeatSeries {
                Values = values,
                GradientStopCollection = gradient
            };

            allPanelsIntensityData.Add(new Tuple <Panel, IntensityData, HeatSeries>(heatpanel, idata, hs));
            heatchart.Series.Add(hs);
            heatpanel.Controls.Add(heatchart);
        }
        private IntensityData constructIntensityData()
        {
            AggregatedData aggregated = new AggregatedData();

            aggregated.aggregatedData = new int[9];

            aggregated.numberOfMeasurements = 5;
            aggregated.aggregatedData[0]    = 5;
            aggregated.aggregatedData[1]    = 6;
            aggregated.aggregatedData[2]    = 5;
            aggregated.aggregatedData[3]    = 5;
            aggregated.aggregatedData[4]    = 10;
            aggregated.aggregatedData[5]    = 11;
            aggregated.aggregatedData[6]    = 15;
            aggregated.aggregatedData[7]    = 6;
            aggregated.aggregatedData[8]    = 5;


            AggregatedData aggregated1 = new AggregatedData();

            aggregated1.aggregatedData = new int[9];

            aggregated1.numberOfMeasurements = 2;
            aggregated1.aggregatedData[0]    = 2;
            aggregated1.aggregatedData[1]    = 2;
            aggregated1.aggregatedData[2]    = 5;
            aggregated1.aggregatedData[3]    = 5;
            aggregated1.aggregatedData[4]    = 5;
            aggregated1.aggregatedData[5]    = 2;
            aggregated1.aggregatedData[6]    = 2;
            aggregated1.aggregatedData[7]    = 2;
            aggregated1.aggregatedData[8]    = 2;


            AggregatedData aggregated2 = new AggregatedData();

            aggregated2.aggregatedData = new int[9];

            aggregated2.numberOfMeasurements = 4;
            aggregated2.aggregatedData[0]    = 4;
            aggregated2.aggregatedData[1]    = 4;
            aggregated2.aggregatedData[2]    = 4;
            aggregated2.aggregatedData[3]    = 4;
            aggregated2.aggregatedData[4]    = 10;
            aggregated2.aggregatedData[5]    = 10;
            aggregated2.aggregatedData[6]    = 10;
            aggregated2.aggregatedData[7]    = 4;
            aggregated2.aggregatedData[8]    = 4;

            IntensityData currentIntensityData = new IntensityData();

            currentIntensityData.intensityData.Add(aggregated);
            currentIntensityData.intensityData.Add(aggregated1);
            currentIntensityData.intensityData.Add(aggregated2);

            return(currentIntensityData);
        }
 /// <summary>
 /// Sets the volume to the intensity and plays the audio source
 /// </summary>
 /// <param name="intensityData">The related intensity value to this activation</param>
 public override void Activate(IntensityData intensityData)
 {
     //as intensity increases, chance of occurence also increases
     if (!controlledAudioSource.isPlaying) //only play if not already playing sound
     {
         controlledAudioSource.volume = intensityData.intensity;
         controlledAudioSource.Play();
     }
 }
 /// <summary>
 /// Should the behaviour update?
 /// </summary>
 /// <param name="intensityData">The intensity data that will be updated with</param>
 /// <returns>True if validWeatherTypes contains the WeatherType set in the intensityData object</returns>
 protected override bool ShouldUpdate(IntensityData intensityData)
 {
     try
     {
         return(validWeatherTypes.Contains(intensityData.weatherType));
     }catch (System.Exception ex)
     {
         Debug.LogException(ex);
         return(false);
     }
 }
        /// <summary>
        /// Utilises the intensity element of the IntensityData to caluclate a chance for the event to occur, if a threshold is met, the event is activated
        /// </summary>
        /// <param name="intensityData">The intensity data</param>
        protected override void ConditionalUpdateWithIntensity(IntensityData intensityData)
        {
            //as intensity increases, chance of occurence also increases
            float x            = transform.position.x * intensityData.wind.x + Time.timeSinceLevelLoad * 100f;
            float y            = transform.position.z * intensityData.wind.y + Time.timeSinceLevelLoad * 100f;
            float randomNumber = WeatherSystem.Internal.Generators.GetPerlinNoise(x, y, 500, 500, 1, 0);

            if (randomNumber < instanceChance)
            {
                instanceEvent.Activate(intensityData);
            }
        }
 /// <summary>
 /// Updates the component if ShouldUpdate returns true, otherwise deactivates
 /// </summary>
 /// <param name="intensityData">The intensity data with which to update</param>
 protected override void UpdateWithIntensity(IntensityData intensityData)
 {
     if (ShouldUpdate(intensityData))
     {
         OnActivate(); //will only apply if not already active
         ConditionalUpdateWithIntensity(intensityData);
     }
     else
     {
         OnDeactivate();
     }
 }
示例#9
0
        public string saveIntensityData(IntensityData intensityData)
        {
            int numberofElements = intensityData.intensityData.Count;

            if (numberofElements == 0)
            {
                throw new Exception("Could not save IntensityData, does not contains any data ");
            }
            string fileName = Settings.projectName + "_" + new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds() + ".csv";

            try {
                this.createFolderIfNotExists(AppDomain.CurrentDomain.BaseDirectory + INTENSITY_PATH);
                using (StreamWriter sw = File.CreateText(AppDomain.CurrentDomain.BaseDirectory + INTENSITY_PATH + fileName)) {
                    AggregatedData firstAggregatedData = intensityData.intensityData.First();
                    sw.WriteLine("#HEADER");
                    sw.WriteLine("numberOfAggregatedData  :" + numberofElements);
                    sw.WriteLine("lengthOfOneAggregatedData  :" + firstAggregatedData.aggregatedData.Length);
                    sw.WriteLine("numberOfMeasurements :" + firstAggregatedData.numberOfMeasurements);
                    sw.WriteLine("sampling :" + firstAggregatedData.sampling);
                    sw.WriteLine("gate :" + firstAggregatedData.gate);

                    // create header for csv
                    string header = "t(ms);";
                    for (int i = 1; i <= numberofElements; i++)
                    {
                        header += "Y" + i + ";";
                    }
                    header = header.Remove(header.Length - 1); // remove last comma
                    sw.WriteLine(header);

                    // append data into csv
                    double sampling = 0;
                    string line     = "";
                    for (int i = 0; i < firstAggregatedData.aggregatedData.Length; i++)
                    {
                        line = String.Format("{0:0.000}", sampling);
                        for (int j = 0; j < numberofElements; j++)
                        {
                            line += ";" + intensityData.intensityData[j].aggregatedData[i];
                        }
                        sw.WriteLine(line);
                        sampling += ((double)firstAggregatedData.sampling / 1000);
                    }

                    sw.Close();
                }
            } catch (Exception e) {
                throw new Exception("Could not save IntensityData, exception : " + e.Message);
            }
            return(fileName);
        }
示例#10
0
        public override void Activate(IntensityData data)
        {
            if (flashCoroutine != null)
            {
                StopCoroutine(flashCoroutine);
            }

            int flashCount = (int)Mathf.Max(1, maxFlashes * data.intensity); //min 1 flash, up to max no of flashes

            float[] flashTimes = new float[flashCount];

            for (int i = 0; i < flashCount; i++)
            {
                flashTimes[i] = Random.Range(0f, maxtimePerFlash);
            }

            flashCoroutine = StartCoroutine(Flash(flashTimes));
        }
示例#11
0
        protected override void UpdateWithIntensity(IntensityData intensityData)
        {
            //We could do this ourselves, but the weather manager already keeps track of the cumulative wind at the position we need, so we'll use that one
            Vector2 trackedWind = weatherManager.GetCumulativeWind();

            lastKnownWind = new Vector3(trackedWind.x, 0, trackedWind.y);

            Quaternion startRotation = windZone.transform.rotation;

            windZone.transform.LookAt(windZone.transform.position + lastKnownWind);
            float step = maxDegreesPerSeconds * Time.deltaTime;

            windZone.transform.rotation = Quaternion.RotateTowards(startRotation, windZone.transform.rotation, step);

            windZone.windMain       = intensityData.intensity * 2f * fixedMultiplier;
            windZone.windTurbulence = intensityData.intensity * fixedMultiplier;

            windZone.windPulseMagnitude = windZone.windMain * 0.5f;
            windZone.windPulseFrequency = windZone.windMain * 0.01f;
        }
示例#12
0
        protected override void UpdateWithIntensity(IntensityData intensityData)
        {
            curve.AddKey(new Keyframe(Time.timeSinceLevelLoad, intensityData.intensity));

            //light.SkyboxExtinctionCoef = (intensityData.intensity/2.0f) + 0.5f; //between 0.5f -> 1.0f
            float target = (intensityData.intensity / 2.0f) + 0.5f;

            light.SkyboxExtinctionCoef = Mathf.MoveTowards(light.SkyboxExtinctionCoef, target, maxMovementSkyboxExtinction);

            target = Scale(0.02f, 0.14f, intensityData.intensity);
            light.ScatteringCoef = Mathf.MoveTowards(light.ScatteringCoef, target, maxMovemenScatteringCoef);

            //light.ExtinctionCoef = Scale(0.003f, 0.05f, intensityData.intensity); //this looks good for storms, not so much for rain

            target = Scale(0.003f, 0.01f, intensityData.intensity);
            light.ExtinctionCoef = Mathf.MoveTowards(light.ExtinctionCoef, target, maxMovementExtinctionCoef);

            target = Scale(0.6f, 5.0f, IntensityData.intensity);
            light.NoiseIntensity = Mathf.MoveTowards(light.NoiseIntensity, target, maxMovementNoiseIntensity);
        }
        public void saveAndLoadIntensityData()
        {
            IntensityData currentIntensityData = constructIntensityData();

            String        output = FileService.Instance.saveIntensityData(currentIntensityData);
            IntensityData loadedIntensityData = FileService.Instance.loadIntensityData(AppDomain.CurrentDomain.BaseDirectory + FileService.INTENSITY_PATH + output);

            Assert.AreEqual(loadedIntensityData.intensityData.Count, currentIntensityData.intensityData.Count);
            Assert.AreEqual(loadedIntensityData.intensityData[0].aggregatedData.Length, currentIntensityData.intensityData[0].aggregatedData.Length);
            Assert.AreEqual(loadedIntensityData.intensityData[0].gate, currentIntensityData.intensityData[0].gate);
            Assert.AreEqual(loadedIntensityData.intensityData[0].sampling, currentIntensityData.intensityData[0].sampling);
            Assert.AreEqual(loadedIntensityData.intensityData[0].numberOfMeasurements, currentIntensityData.intensityData[0].numberOfMeasurements);

            for (int i = 0; i < currentIntensityData.intensityData.Count; i++)
            {
                for (int j = 0; j < currentIntensityData.intensityData[i].aggregatedData.Length; j++)
                {
                    Assert.AreEqual(loadedIntensityData.intensityData[i].aggregatedData[j], currentIntensityData.intensityData[i].aggregatedData[j]);
                }
            }
        }
        protected override void ConditionalUpdateWithIntensity(IntensityData intensityData)
        {
            updateCount++;
            trackedIntensity += intensityData.intensity;
            float timeSinceActivated = Time.timeSinceLevelLoad - timeActivated;

            //snow value = average intensity per update by time * multiplier
            float buildUpValue = (trackedIntensity / (float)updateCount) * timeSinceActivated * snowCumulationMultiplier;

            snowController.BottomThreshold = 1.0f - buildUpValue;

            if (snowController.BottomThreshold == 0.0f) //Build up at max, so we start increasing top threshold
            {
                snowController.TopThreshold = (trackedIntensity / (float)updateCount) * snowCumulationMultiplier;
            }
            else
            {
                if (snowController.TopThreshold != 1.0f) //if top threshold isn't at min, need to decrease it when bottom threshold isn't at max
                {
                    snowController.TopThreshold -= snowController.TopThreshold * 0.1f;
                }
            }
        }
示例#15
0
        public void CreateHeatFromCurrent()
        {
            if (livePanel is null)  // <-- only ONE live heat graph is allowed!
            {
                Panel         heatCurrentPanel = CreateHeatPanel();
                IntensityData idata            = new IntensityData();

                liveheatchart                   = new LiveCharts.WinForms.CartesianChart();
                liveheatchart.Size              = new Size(heatSizeX, heatSizeY);
                liveheatchart.Anchor            = (AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right);
                liveheatchart.Left              = 0;
                liveheatchart.Top               = 50;
                liveheatchart.DisableAnimations = true;
                liveheatchart.Hoverable         = false;
                liveheatchart.DataTooltip       = null;

                heatCurrentPanel.Controls.Add(liveheatchart);

                AddButtons(heatCurrentPanel, true);
                graphpanel.Controls.Add(heatCurrentPanel);
                livePanel          = new Tuple <Panel, IntensityData, HeatSeries>(heatCurrentPanel, idata, null);
                this.heatIsStarted = true;
            }
        }
 //updated by changes to IntensityData
 protected virtual void UpdateWithIntensity(IntensityData intensityData)
 {
     Debug.LogWarning("This behaviour has no Intensity update code - " + this.name);
 }
 protected override void UpdateWithIntensity(IntensityData intensityData)
 {
     renderer.material.SetFloat(materialValueName, intensityData.intensity);
 }
示例#18
0
        public IntensityData loadIntensityData(string projectPath)
        {
            IntensityData intensityData = new IntensityData();

            try {
                using (var streamReader = tryToOpenFile(projectPath)) {
                    string          line                   = "";
                    int             countline              = 0;
                    int             sampling               = 0;
                    int             gate                   = 0;
                    int             numberOfMeasurements   = 0;
                    int             lengthOfOneMeasuremet  = 0;
                    int             numberOfAggregatedData = 0;
                    List <string[]> saveMeasurements       = new List <string[]>();

                    while ((line = streamReader.ReadLine()) != null)
                    {
                        if (countline == 1)
                        {
                            numberOfAggregatedData = Int32.Parse(line.Split(':')[1]);
                        }
                        else if (countline == 2)
                        {
                            lengthOfOneMeasuremet = Int32.Parse(line.Split(':')[1]);
                        }
                        else if (countline == 3)
                        {
                            numberOfMeasurements = Int32.Parse(line.Split(':')[1]);
                        }
                        else if (countline == 4)
                        {
                            sampling = Int32.Parse(line.Split(':')[1]);
                        }
                        else if (countline == 5)
                        {
                            gate = Int32.Parse(line.Split(':')[1]);
                        }
                        else if (countline == 0 || countline == 6)
                        {
                            countline++;
                            continue;
                        }
                        else
                        {
                            saveMeasurements.Add(line.Split(';'));
                        }
                        countline++;
                    }

                    // create instance of aggregated data into intensity data
                    for (int i = 0; i < numberOfAggregatedData; i++)
                    {
                        AggregatedData aggregated = new AggregatedData();
                        aggregated.sampling             = sampling;
                        aggregated.gate                 = gate;
                        aggregated.numberOfMeasurements = numberOfMeasurements;
                        aggregated.aggregatedData       = new int[lengthOfOneMeasuremet];

                        intensityData.intensityData.Add(aggregated);
                    }

                    // save data from csv into list of aggregated data
                    int positionCounter = 0;
                    foreach (string[] measurement in saveMeasurements)
                    {
                        for (int i = 0; i < numberOfAggregatedData; i++)
                        {
                            intensityData.intensityData[i].aggregatedData[positionCounter] = Int32.Parse(measurement[i + 1]);
                        }
                        positionCounter++;
                    }
                }
            } catch (Exception e) {
                throw new FileLoadException("Could not parse file content into IntensityData, got error : " + e.Message);
            }
            return(intensityData);
        }
 protected override void UpdateWithIntensity(IntensityData intensityData)
 {
     light.intensity = 1f - (0.01f + intensityData.intensity * 0.99f);
     light.color     = Color.Lerp(idealColor, Color.black, intensityData.intensity);
 }
示例#20
0
 ///<exclude/>
 public bool Equals(IntensityData other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return other._Tm.Equals(_Tm) && other._Intensities.SequenceEqual(_Intensities) && other._Geometry.Equals(_Geometry) && other._Config.Equals(_Config);
 }
示例#21
0
 public virtual void Activate(IntensityData data)
 {
 }
 protected override void UpdateWithIntensity(IntensityData intensityData)
 {
     controlledAudioSource.volume = intensityData.intensity;
 }
 /// <summary>
 /// Logic for applying intensity data. This method is called when updating intensity and ShouldUpdate is true
 /// </summary>
 /// <param name="intensityData">The intensity data</param>
 protected virtual void ConditionalUpdateWithIntensity(IntensityData intensityData)
 {
     Debug.Log("Conditional update ran for " + this.name);
     base.UpdateWithIntensity(intensityData);
 }
示例#24
0
 protected override void UpdateWithIntensity(IntensityData intensityData)
 {
     //Do nothing with fed values, as those are at the player's location
 }
 /// <summary>
 /// Checks to see if this component should update
 /// </summary>
 /// <param name="intensityData">The current intensity data</param>
 /// <returns>
 protected virtual bool ShouldUpdate(IntensityData intensityData)
 {
     return(true);
 }