Esempio n. 1
0
        void UpdateSenerioInfo()
        {
            SetZeroes();
            int tempHours;
            int tempMinutes;
            int tempSeconds;

            GameObject line = Instantiate(LinePrefab, ScenarioInformationGrid.transform, false);

            ((RectTransform)ScenarioInformationGrid.transform).SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 1, 30 * ScenarioInformationGrid.transform.childCount);
            ScenarioValues senValues = line.GetComponent <ScenarioValues>();

            int.TryParse(StartHouresInputField.text, out tempHours);
            int.TryParse(StartMinutesInputField.text, out tempMinutes);
            int.TryParse(StartSecondesInputField.text, out tempSeconds);

            senValues.StartTime.text = tempHours.ToString("00") + ":" + tempMinutes.ToString("00") + ":" + tempSeconds.ToString("00");

            int.TryParse(DurationHouresInputField.text, out tempHours);
            int.TryParse(DurationMinutesInputField.text, out tempMinutes);

            senValues.Duration.text = tempHours.ToString("00") + ":" + tempMinutes.ToString("00");

            senValues.Weather.text      = PercipitationManger.weatherState.ToString();
            senValues.Fog.isOn          = PercipitationManger.Fog;
            senValues.Lightning.isOn    = PercipitationManger.Lightning;
            senValues.Intensity.text    = IntansitySlider.value.ToString();
            senValues.CloudCovrege.text = CloudCovregeDropdown.options[CloudCovregeDropdown.value].text;
            senValues.ScenarioID        = -5;
            ScenarioInfo.AddScenario(line);
        }
        private void ColorSelected(GameObject obj, bool isSelected)
        {
            if (obj == null)
            {
                return;
            }
            ScenarioValues senValues = obj.GetComponent <ScenarioValues>();
            Color          color     = Color.black;

            if (IsActive(obj))
            {
                color = Color.red;
            }
            if (isSelected)
            {
                if (IsActive(obj))
                {
                    color = Color.yellow;
                }
                else
                {
                    color = SelectedColor;
                }
            }
            senValues.StartTime.color    = color;
            senValues.Duration.color     = color;
            senValues.Weather.color      = color;
            senValues.Intensity.color    = color;
            senValues.CloudCovrege.color = color;
        }
        private bool IsActive(GameObject obj)
        {
            ScenarioValues senValues = obj.GetComponent <ScenarioValues>();

            if (senValues.CloudCovrege.color == Color.red || senValues.CloudCovrege.color == Color.yellow)
            {
                return(true);
            }
            return(false);
        }
Esempio n. 4
0
 public ConfigScenarioLine(ScenarioValues line)
 {
     StartTime    = line.StartTime.text;
     Duration     = line.Duration.text;
     Weather      = line.Weather.text;
     Fog          = line.Fog.isOn;
     Lightning    = line.Lightning.isOn;
     Intensity    = line.Intensity.text;
     CloudCovrege = line.CloudCovrege.text;
 }
        //Adds a Scenario to the list and a symbol to the list.
        public int AddScenario(GameObject LinePrefab, int ScenarioID = -1)
        {
            // If the list is full, delete the last element.
            if (ScenarioLines.Count == MaxLines)
            {
                GameObject obj = ScenarioLines[0].gameObject;

                ScenarioValues.Remove(obj.GetComponent <ScenarioValues>());
                Destroy(obj);
                ScenarioLines.RemoveAt(0);
            }

            // Calculate the position of each line in the list.
            foreach (RectTransform senLine in ScenarioLines)
            {
                senLine.position -= new Vector3(0, lineHeight + LineOffset, 0);
            }

            int currentID = ScenarioID == -1 ? id : ScenarioID;

            ScenarioValues senValues = LinePrefab.GetComponent <ScenarioValues>();

            senValues.ScenarioID = currentID;


            ScenarioValues.Add(senValues);

            if (ScenarioInformationGrid.rect.height - (ScenarioLines.Count * (lineHeight + LineOffset)) < lineHeight + LineOffset)
            {
                ScenarioInformationGrid.offsetMin = new Vector2(ScenarioInformationGrid.offsetMin.x, ScenarioInformationGrid.offsetMin.y - (lineHeight + LineOffset));
            }

            ScenarioLines.Add(LinePrefab.GetComponent <RectTransform>());

            if (ScenarioID == -1)
            {
                id++;
            }

            if (OnScenarioAdded != null)
            {
                OnScenarioAdded();
            }

            return(currentID);
        }
Esempio n. 6
0
        private void ColorActive(ScenarioValues senValues, bool isActive)
        {
            Color color;

            if (isActive)
            {
                color = Color.red;
            }
            else
            {
                color = Color.black;
            }
            senValues.StartTime.color    = color;
            senValues.Duration.color     = color;
            senValues.Weather.color      = color;
            senValues.Intensity.color    = color;
            senValues.CloudCovrege.color = color;
        }
Esempio n. 7
0
        public ScenarioValues ConfigLineToScenarioValues(ConfigScenarioLine line)
        {
            GameObject newLine = Instantiate(LinePrefab, DestinyScenarioInformationGrid.transform, false);

            ((RectTransform)DestinyScenarioInformationGrid.transform).SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 1, 30 * DestinyScenarioInformationGrid.transform.childCount);
            ScenarioValues senValues = newLine.GetComponent <ScenarioValues>();

            senValues.StartTime.text    = line.StartTime;
            senValues.Duration.text     = line.Duration;
            senValues.Weather.text      = line.Weather;
            senValues.Fog.isOn          = line.Fog;
            senValues.Lightning.isOn    = line.Lightning;
            senValues.Intensity.text    = line.Intensity;
            senValues.CloudCovrege.text = line.CloudCovrege;
            senValues.ScenarioID        = -5;

            return(senValues);
        }
Esempio n. 8
0
        public ConfigScenarioLine[] ReadFromJSON(string Path)
        {
            string verJSON = System.IO.File.ReadAllText(Path, System.Text.Encoding.UTF8);

            string[]             Lines  = verJSON.Split('|');
            ConfigScenarioLine[] result = new ConfigScenarioLine[Lines.Length];
            for (int i = 0; i < Lines.Length; i++)
            {
                result[i] = JsonUtility.FromJson <ConfigScenarioLine>(Lines[i]);
            }
            foreach (ConfigScenarioLine line in result)
            {
                GameObject newLine = Instantiate(LinePrefab, DestinyScenarioInformationGrid.transform, false);
                ((RectTransform)DestinyScenarioInformationGrid.transform).SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 1, 30 * DestinyScenarioInformationGrid.transform.childCount);
                ScenarioValues senValues = newLine.GetComponent <ScenarioValues>();
                senValues.GetConfigInfo(line);
                DestinyScenarioInfo.AddScenario(newLine);
            }
            return(result);
        }
Esempio n. 9
0
 void Update()
 {
     timeOfDay          = (int)TimeOfDaySlider.value;
     TempScenarioValues = FindActiveScenario();
     if (TempScenarioValues != null)
     {
         if (ActiveScenarioValues != null)
         {
             if (TempScenarioValues != ActiveScenarioValues)
             {
                 ScenarioInfo.RemoveScenarios(ActiveScenarioValues.ScenarioID);
             }
         }
         ActiveScenarioValues = TempScenarioValues;
         SetValuesOfActive(ActiveScenarioValues);
         if (!(ActiveScenarioValues.CloudCovrege.color == Color.red || ActiveScenarioValues.CloudCovrege.color == Color.yellow))
         {
             ColorActive(ActiveScenarioValues, true);
         }
     }
     else
     {
         if (ActiveScenarioValues != null)
         {
             SetValuesOfActive();
             if (DeleteAfterFinished)
             {
                 ScenarioInfo.RemoveScenarios(ActiveScenarioValues.ScenarioID);
             }
             else
             {
                 ColorActive(ActiveScenarioValues, false);
             }
             ActiveScenarioValues = null;
         }
     }
 }
Esempio n. 10
0
        private void SetValuesOfActive(ScenarioValues senValues)
        {
            float temp = 0;

            foreach (var option in CloudCovregeDropdown.options)
            {
                if (option.text == senValues.CloudCovrege.text)
                {
                    CloudCovregeDropdown.value = (int)temp;
                    break;
                }
                temp++;
            }
            float.TryParse(senValues.Intensity.text, out temp);
            IntensitySlider.value = temp;
            if (senValues.Weather.text == "Clear")
            {
                ClearToggle.isOn = true;
            }
            else
            {
                if (senValues.Weather.text == "Rainy")
                {
                    RainyToggle.isOn = true;
                }
                else
                {
                    if (senValues.Weather.text == "Snowy")
                    {
                        SnowyToggle.isOn = true;
                    }
                }
            }

            FogToggle.isOn       = senValues.Fog.isOn;
            LightningToggle.isOn = senValues.Lightning.isOn;
        }
Esempio n. 11
0
        // Remove all Scenarios by ID.
        public void RemoveScenarios(int ScenarioID)
        {
            List <RectTransform> senLines = new List <RectTransform>(ScenarioLines);

            foreach (RectTransform senLine in senLines)
            {
                ScenarioValues senVal = senLine.gameObject.GetComponent <ScenarioValues>();

                // If Scenario should be removed, delete it and position
                // the other elements in the grid accordingly.
                if (senVal.ScenarioID == ScenarioID)
                {
                    ScenarioValues.Remove(senVal);

                    Destroy(senLine.gameObject);

                    int removedIndex = ScenarioLines.IndexOf(senLine);

                    if (removedIndex > 0)
                    {
                        for (int i = removedIndex - 1; i >= 0; --i)
                        {
                            ScenarioLines[i].position += new Vector3(0, lineHeight + LineOffset, 0);
                        }
                    }

                    if (ScenarioInformationGrid.rect.height > originalHeight)
                    {
                        ScenarioInformationGrid.offsetMin = new Vector2(ScenarioInformationGrid.offsetMin.x, ScenarioInformationGrid.offsetMin.y + (lineHeight + LineOffset));
                        VerticalScrollbar.value          += 1 / (lineHeight + LineOffset);
                    }

                    ScenarioLines.Remove(senLine);
                }
            }
        }