Example #1
0
 /// <summary>
 /// Do an update frame for Procedural mode
 /// </summary>
 private void ProceduralUpdate()
 {
     if (transitionCoroutine == null) //when no weather transition occuring
     {
         WeatherTypes currentWeather      = GetWeather();
         WeatherEvent currentWeatherEvent = WeatherEventFromWeatherType(weatherLastFrame);
         if (currentWeather != weatherLastFrame) //If the weather changed this frame
         {
             WeatherEvent newWeatherEvent = WeatherEventFromWeatherType(currentWeather);
             if (currentWeatherEvent == null)
             {
                 Debug.LogError("No weather event set for " + weatherLastFrame);
                 return;
             }
             if (newWeatherEvent == null)
             {
                 Debug.LogError("No weather event set for " + currentWeather);
                 return;
             }
             transitionCoroutine = StartCoroutine(Transition(currentWeatherEvent, newWeatherEvent, weatherEventTransitionTime, currentWeatherEvent.Intensity));
             weatherLastFrame    = currentWeather;
         }
         else //No weather changed, update intensity
         {
             float   intensity = GetIntensityValueAt(weatherQueryLocation.position); //Generators.GetIntensityNoise(weatherQueryLocation.position.x + trackedX, weatherQueryLocation.position.y + trackedY, worldSize.x, worldSize.y, proceduralScale, 0.00f);
             Vector2 wind      = GetWindValueAt(weatherQueryLocation.position);
             currentWeatherEvent.IntensityData = new IntensityData(intensity, temperatureLastFrame, humidityLastFrame, wind, currentWeather);
             intensityPlot.AddKey(new Keyframe(timeExtension.CheckedTimeSinceLevelLoad, currentWeatherEvent.IntensityData.intensity));
         }
     }
 }
Example #2
0
    public static Color ToColor(this WeatherTypes weatherType)
    {
        switch (weatherType)
        {
        case WeatherTypes.None:
            return(Color.clear);

        case WeatherTypes.Clear:
            return(Color.yellow);

        case WeatherTypes.Rain:
            return(Color.blue);

        case WeatherTypes.Snow:
            return(Color.white);

        case WeatherTypes.Overcast:
            return(Color.grey);

        case WeatherTypes.Storm:
            return(Color.black);

        case WeatherTypes.Hail:
            return(Color.cyan);

        default:
            Debug.LogWarning("No color for " + weatherType);
            return(Color.green);
        }
    }
Example #3
0
 private void startRain()
 {
     if (isRaining)
     {
         rainElapsed += 1;
         if (rainElapsed >= rainTime)
         {
             stopRain();
         }
         return;
         ////already raining
     }
     if (Common.getRandom(1, 50) == 25)
     {
         if (!isRaining)
         {
             rainIntensity = (WeatherTypes)Common.getRandom(1, 3);
             rain          = DSound.loadOgg(DSound.SoundPath + "\\wr" + rainIntensity + ".ogg");
             rain.play(true);
             isRaining = true;
         }
         ////if !isRaining
     }
     ////if random
 }
        void SetWeather()
        {
            // Always disable weather inside
            if (isInside)
            {
                if (RainParticles) RainParticles.SetActive(false);
                if (SnowParticles) SnowParticles.SetActive(false);
                return;
            }

            // Always snow in desert climate
            if (currentClimateType == DFLocation.ClimateBaseType.Desert &&
                currentWeatherType == WeatherTypes.Snow_Normal)
            {
                currentWeatherType = WeatherTypes.None;
                WeatherType = WeatherTypes.None;
            }

            switch (WeatherType)
            {
                case WeatherTypes.None:
                    if (RainParticles) RainParticles.SetActive(false);
                    if (SnowParticles) SnowParticles.SetActive(false);
                    break;
                case WeatherTypes.Rain_Normal:
                    if (RainParticles) RainParticles.SetActive(true);
                    if (SnowParticles) SnowParticles.SetActive(false);
                    break;
                case WeatherTypes.Snow_Normal:
                    if (RainParticles) RainParticles.SetActive(false);
                    if (SnowParticles) SnowParticles.SetActive(true);
                    break;
            }
        }
        public static WeatherEnum GetWorldWeather(WeatherTypes FieldWeather)
        {
            switch (FieldWeather)
            {
            case WeatherTypes.Clear:
                return(WeatherEnum.Clear);

            case WeatherTypes.Foggy:
                return(WeatherEnum.Fog);

            case WeatherTypes.Hailstorm:
                return(WeatherEnum.Blizzard);

            case WeatherTypes.Rain:
                return(WeatherEnum.Rain);

            case WeatherTypes.Sandstorm:
                return(WeatherEnum.Sandstorm);

            case WeatherTypes.Sunny:
                return(WeatherEnum.Sunny);

            case WeatherTypes.Snow:
                return(WeatherEnum.Snow);

            case WeatherTypes.Underwater:
                return(WeatherEnum.Underwater);

            default:
                return(WeatherEnum.Clear);
            }
        }
        void SetWeather()
        {
            // Always disable weather inside
            if (isInside)
            {
                if (RainParticles)
                {
                    RainParticles.SetActive(false);
                }
                if (SnowParticles)
                {
                    SnowParticles.SetActive(false);
                }
                return;
            }

            // Always snow in desert climate
            if (currentClimateType == DFLocation.ClimateBaseType.Desert &&
                currentWeatherType == WeatherTypes.Snow_Normal)
            {
                currentWeatherType = WeatherTypes.None;
                WeatherType        = WeatherTypes.None;
            }

            switch (WeatherType)
            {
            case WeatherTypes.None:
                if (RainParticles)
                {
                    RainParticles.SetActive(false);
                }
                if (SnowParticles)
                {
                    SnowParticles.SetActive(false);
                }
                break;

            case WeatherTypes.Rain_Normal:
                if (RainParticles)
                {
                    RainParticles.SetActive(true);
                }
                if (SnowParticles)
                {
                    SnowParticles.SetActive(false);
                }
                break;

            case WeatherTypes.Snow_Normal:
                if (RainParticles)
                {
                    RainParticles.SetActive(false);
                }
                if (SnowParticles)
                {
                    SnowParticles.SetActive(true);
                }
                break;
            }
        }
Example #7
0
        public static void SetWeatherType(object sender, string cmd, string[] param,
                                          out Dictionary <string, object> returnVal)
        {
            StringBuilder msgSB = new StringBuilder();

            WeatherTypes wt      = WeatherTypes.Rain;
            var          foundWT = false;

            for (int i = 0; i < param.Length; i++)
            {
                if (Enum.TryParse(param[i], out wt))
                {
                    foundWT = true;
                    break;
                }
            }
            if (foundWT)
            {
                WorldInst.List[0].Weather.SetWeatherType(wt);
                msgSB.AppendFormat("Applied WeatherType: {0}", wt);
            }
            else
            {
                msgSB.Append("No valid WeatherType found!");
            }

            returnVal = new Dictionary <string, object>
            {
                { "type", WSProtocolType.chatData },
                { "sender", "SERVER" },
                { "rawText", msgSB.ToString() },
            };
        }
Example #8
0
 public IntensityData(float intensity, TemperatureVariables temperature, HumidityVariables humidity, Vector2 wind, WeatherTypes weatherType)
 {
     this.intensity   = intensity;
     this.temperature = temperature;
     this.humidity    = humidity;
     this.wind        = wind;
     this.weatherType = weatherType;
 }
Example #9
0
    // Update is called once per frame
    void Update()
    {
        Vector2      position = new Vector2(transform.position.x, transform.position.z);
        WeatherTypes weather  = weatherManager.GetWeather(position);

        outputText.text             = weather.ToString();
        selfRenderer.material.color = weather.ToColor();
    }
Example #10
0
        protected override void Parse(BigEndianReader reader)
        {
            reader.ReadByte();             // ID

            _WeatherType = (WeatherTypes)reader.ReadByte();
            _Density     = reader.ReadByte();
            _Temperature = reader.ReadByte();
        }
Example #11
0
        protected override void Parse( BigEndianReader reader )
        {
            reader.ReadByte(); // ID

            _WeatherType = (WeatherTypes)reader.ReadByte();
            _Density = reader.ReadByte();
            _Temperature = reader.ReadByte();
        }
Example #12
0
        public static void Restart()
        {
            Array        weathers = Enum.GetValues(typeof(WeatherTypes));
            WeatherTypes currentWeatherForScripts = (WeatherTypes)weathers.GetValue(RandForNewWeather(weathers.Length));

            currentWeather = Scripts.SuitableWeather(Shilka.currentScript, currentWeatherForScripts);

            Restart(currentWeather, newWeatherCycle: 0);
        }
Example #13
0
        public Weather()
        {
            double d1, d2 = 0.1;

            type      = (WeatherTypes)StaticRandom.Rand(6);
            windSpeed = new double[500];
            double rand = StaticRandom.RandDouble() * 3.0;

            switch (type)
            {
            case WeatherTypes.Sun:
            case WeatherTypes.Frost:
                d1 = 10.0;
                break;

            case WeatherTypes.SunWind:
            case WeatherTypes.FrostWind:
                d1   = 4.0;
                rand = StaticRandom.RandDouble() * 2.0 + 3.0;
                break;

            case WeatherTypes.RainWind:
                d1   = 4.0;
                rand = StaticRandom.RandDouble() * 2.0 + 3.0;
                d2   = 0.2;
                break;

            case WeatherTypes.Neuter:
            default:
                d1 = 7.0;
                break;
            }
            for (int i = 0; i < windSpeed.Length; i++)
            {
                rand = rand + (StaticRandom.RandDouble() - 0.5) / d1;
                if (rand < 0)
                {
                    rand = 0;
                }
                int j = StaticRandom.Rand(26);
                if (j == 1)
                {
                    windSpeed[i] = rand + d2 * rand;
                }
                else
                if (j == 2)
                {
                    windSpeed[i] = rand - d2 * rand;
                }
                else
                {
                    windSpeed[i] = rand;
                }
            }
        }
Example #14
0
 /// <summary>
 /// Lookup a weather event from its weathertype
 /// </summary>
 /// <param name="weather">The weathertype to look up</param>
 /// <returns>The found WeatherEvent or null if none was found</returns>
 private WeatherEvent WeatherEventFromWeatherType(WeatherTypes weather)
 {
     for (int i = 0; i < activeWeatherSet.WeatherEvents.Length; i++)
     {
         if (activeWeatherSet.WeatherEvents[i].WeatherType == weather)
         {
             return(activeWeatherSet.WeatherEvents[i]);
         }
     }
     return(null);
 }
Example #15
0
        // Use this for initialization
        protected virtual void Start()
        {
            //Temporary - DEBUGGING
            activeWeatherSet = weatherSets[0];


            weatherLastFrame = GetWeather();
            WeatherEvent currentWeatherEvent = WeatherEventFromWeatherType(weatherLastFrame);

            currentWeatherEvent.OnActivate();
        }
Example #16
0
 public void SetNextWeather(string name)
 {
     WeatherTypes.TryGetValue(name, out NextWeatherType);
     if (NextWeatherType == null)
     {
         NextWeatherType = CurrentWeatherType;
     }
     else
     {
         CurrentWeatherChangeTime = 0.0f;
     }
 }
Example #17
0
 void Update()
 {
     // Update weather if context changes
     if (WeatherType != currentWeatherType ||
         playerEnterExit.IsPlayerInside != isInside ||
         playerGPS.ClimateSettings.ClimateType != currentClimateType)
     {
         isInside           = playerEnterExit.IsPlayerInside;
         currentClimateType = playerGPS.ClimateSettings.ClimateType;
         currentWeatherType = WeatherType;
         SetWeather();
     }
 }
Example #18
0
        public override void Invoke()
        {
            try {
                string  S    = CompressedCallSite("https://api.weather.gov/gridpoints/MKX/80,70/forecast/hourly", Gov_User);
                JObject item = JObject.Parse(S);
                var     X    = item["properties"]["periods"][0];
                _temp = X.Value <int>("temperature");
                _forcastDescription = X.Value <string>("shortForecast");
                _Success            = true;
                _type = convert(_forcastDescription);
            }

            catch (Exception x) { _exception = x.ToString(); }
        }
Example #19
0
        private void TransformWeather(string webresponse)
        {
            const string forcastFormat = "{3}, {2}. [{1}-{0}] Precipitation {4}%.";

            //WeatherResponse response = new WeatherResponse();
            System.Text.StringBuilder forcast = new System.Text.StringBuilder();

            XmlReader reader = XmlReader.Create(new System.IO.StringReader(webresponse));

            while (reader.Read())
            {
                if ((reader.NodeType == XmlNodeType.Element))
                {
                    switch (reader.Name)
                    {
                    case "current":
                        _Temp = int.Parse(reader.GetAttribute("temperature"));
                        //_skycode = int.Parse(reader.GetAttribute("skycode"));
                        string skyTxt = reader.GetAttribute("skytext");
                        _type = ConvertType(skyTxt);
                        forcast.Append("Now ").Append(_Temp).Append(" ").Append(skyTxt).Append(Environment.NewLine);
                        break;

                    case "forecast":
                        string   low        = reader.GetAttribute("low");
                        string   high       = reader.GetAttribute("high");
                        string   skyText    = reader.GetAttribute("skytextday");
                        DateTime forcastDay = DateTime.Parse(reader.GetAttribute("date"));
                        string   day        = reader.GetAttribute("day");
                        string   percept    = reader.GetAttribute("precip");
                        if (string.IsNullOrWhiteSpace(percept))
                        {
                            percept = "0";
                        }
                        if (forcastDay >= DateTime.Today)
                        {
                            forcast.Append(string.Format(forcastFormat, low, high, skyText, day, percept)).Append(Environment.NewLine);
                        }
                        break;

                    case "toolbar":
                        int Timeout = int.Parse(reader.GetAttribute("timewindow"));
                        //if (Timeout > _cacheTimeout) _cacheTimeout = Timeout;
                        break;
                    }
                }
            }
            _forcast = forcast.ToString();
        }
Example #20
0
        public void ObserverUpdate(WeatherTypes weather)
        {
            switch (weather)
            {
            case WeatherTypes.RAIN:
                Console.WriteLine("Ant: Back to the holes! TSUNAMI!");
                break;

            case WeatherTypes.SUNNY:
                Console.WriteLine("Ant: Come out of the holes, work!");
                break;

            case WeatherTypes.CLOUDLY:
                Console.WriteLine("Ant: Being sad. Sad weather...");
                break;
            }
        }
Example #21
0
        public void ObserverUpdate(WeatherTypes weather)
        {
            switch (weather)
            {
            case WeatherTypes.RAIN:
                Console.WriteLine("Plant: Finaly, water!");
                break;

            case WeatherTypes.SUNNY:
                Console.WriteLine("Plant: Hot.. I hope I get water!");
                break;

            case WeatherTypes.CLOUDLY:
                Console.WriteLine("Plant: Please let it go rain soon!");
                break;
            }
        }
Example #22
0
        public override void Invoke()
        {
            try
            {
                string value = GetValue;
                //JavaScriptSerializer jsSerialization = new JavaScriptSerializer();
                OpenWeatherMapObject weatherObject = JsonConvert.DeserializeObject <OpenWeatherMapObject>(value); //jsSerialization.Deserialize<OpenWeatherMapObject>(value);
                _Temp    = (int)weatherObject.main.temp;
                _forcast = GenerateForcast(weatherObject.main, weatherObject.weather[0]);
                _type    = GetWeatherType(weatherObject.weather[0].id);

                _sunRise   = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(weatherObject.sys.sunrise).ToLocalTime();
                _sunSet    = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds(weatherObject.sys.sunset).ToLocalTime();
                _solarNoon = DateTime.Now;
                _status    = string.Empty;
                _Success   = true;
            }
            catch (Exception x) { _err = x.ToString(); _Success = false; }
        }
Example #23
0
        /// <summary>
        /// Change the weater, example which triggers the observers to do something based on the new weather
        /// </summary>
        public void ChangeWeather()
        {
            if (currentWeather == WeatherTypes.RAIN)
            {
                currentWeather = WeatherTypes.SUNNY;
            }
            else if (currentWeather == WeatherTypes.SUNNY)
            {
                currentWeather = WeatherTypes.CLOUDLY;
            }
            else
            {
                currentWeather = WeatherTypes.RAIN;
            }

            Console.WriteLine("Weather changed to " + currentWeather.ToString());

            NotifyObservers();

            Console.WriteLine(" ");
        }
        private string GetWaterTypeImageUrl(WeatherTypes type)
        {
            var imageUrl = string.Empty;

            if (!MapperHelper.WeaterTypeToItemId.ContainsKey(type))
            {
                return(imageUrl);
            }

            var weaterTypeItem = Sitecore.Context.Database.GetItem(new ID(MapperHelper.WeaterTypeToItemId[type]));

            ImageField imageField = weaterTypeItem.Fields["image"];

            if (imageField?.MediaItem != null)
            {
                var image = new MediaItem(imageField.MediaItem);
                imageUrl = StringUtil.EnsurePrefix('/', MediaManager.GetMediaUrl(image));
            }

            return(imageUrl);
        }
        void SetWeather()
        {
            switch (WeatherType)
            {
            case WeatherTypes.None:
                if (RainParticles)
                {
                    RainParticles.SetActive(false);
                }
                if (SnowParticles)
                {
                    SnowParticles.SetActive(false);
                }
                break;

            case WeatherTypes.Rain_Normal:
                if (RainParticles)
                {
                    RainParticles.SetActive(true);
                }
                if (SnowParticles)
                {
                    SnowParticles.SetActive(false);
                }
                break;

            case WeatherTypes.Snow_Normal:
                if (RainParticles)
                {
                    RainParticles.SetActive(false);
                }
                if (SnowParticles)
                {
                    SnowParticles.SetActive(true);
                }
                break;
            }
            lastWeatherType = WeatherType;
        }
Example #26
0
        private static string GetPants(WeatherTypes weather)
        {
            switch (weather)
            {
            case WeatherTypes.Sunny:
                return("kratasy");

            case WeatherTypes.Rainy:
                return("nepromokave kalhoty");

            case WeatherTypes.Snow:
                return("oteplovaky");

            case WeatherTypes.Cloudy:
            case WeatherTypes.Hail:
                return("dlouhe kalhoty");

            case WeatherTypes.Foggy:
                return("nic");

            default:
                throw new ArgumentOutOfRangeException(nameof(weather), weather, null);
            }
        }
Example #27
0
        public static string GetShoes(WeatherTypes weather)
        {
            switch (weather)
            {
            case WeatherTypes.Sunny:
                return("zabky");

            case WeatherTypes.Rainy:
                return("holinky");

            case WeatherTypes.Snow:
                return("zimni boty");

            case WeatherTypes.Cloudy:
            case WeatherTypes.Hail:
                return("nepromokave boty");

            case WeatherTypes.Foggy:
                return("pevna obuv");

            default:
                throw new ArgumentOutOfRangeException(nameof(weather), weather, null);
            }
        }
Example #28
0
 protected override void ReadProperties(PacketReader stream)
 {
     base.ReadProperties(stream);
     this.type = (WeatherTypes)stream.ReadByte();
 }
Example #29
0
 private void FillWeatherTypeSelectList(WeatherTypes? selected = null)
 {
     ViewBag.Types = selected.TranslatedSelectList();
 }
 void Update()
 {
     // Update weather if context changes
     if (WeatherType != currentWeatherType ||
         playerEnterExit.IsPlayerInside != isInside ||
         playerGPS.ClimateSettings.ClimateType != currentClimateType)
     {
         isInside = playerEnterExit.IsPlayerInside;
         currentClimateType = playerGPS.ClimateSettings.ClimateType;
         currentWeatherType = WeatherType;
         SetWeather();
     }
 }
Example #31
0
 public SpecialCard(int ID, string Name, string Art, Abilities Ability, WeatherTypes WeatherType) : base(ID, Name, Art, true)
 {
     this.Ability     = Ability;
     this.WeatherType = WeatherType;
 }
Example #32
0
        public void Init(GameFileCache gameFileCache, Action <string> updateStatus, Timecycle timecycle)
        {
            Timecycle = timecycle;
            var rpfman = gameFileCache.RpfMan;

            //TODO: RpfMan should be able to get the right version? or maybe let gameFileCache do it!
            string filename = "common.rpf\\data\\levels\\gta5\\weather.xml";

            if (gameFileCache.EnableDlc)
            {
                filename = "update\\update.rpf\\common\\data\\levels\\gta5\\weather.xml";
            }

            XmlDocument weatherxml = rpfman.GetFileXml(filename);

            XmlElement weather = weatherxml.DocumentElement;

            XmlNodeList weathergpufx = weather.SelectNodes("WeatherGpuFx/Item");

            WeatherGpuFx.Clear();
            for (int i = 0; i < weathergpufx.Count; i++)
            {
                var weathergpufxi = new WeatherGpuFx();
                weathergpufxi.Init(weathergpufx[i]);
                WeatherGpuFx[weathergpufxi.Name] = weathergpufxi;
            }

            XmlNodeList weathertypes = weather.SelectNodes("WeatherTypes/Item");

            WeatherTypes.Clear();
            for (int i = 0; i < weathertypes.Count; i++)
            {
                var weathertype = new WeatherType();
                weathertype.Init(gameFileCache, weathertypes[i]);
                WeatherTypes[weathertype.Name] = weathertype;
            }

            XmlNodeList weathercycles = weather.SelectNodes("WeatherCycles/Item");

            WeatherCycles.Clear();
            for (int i = 0; i < weathercycles.Count; i++)
            {
                var weathercycle = new WeatherCycle();
                weathercycle.Init(weathercycles[i]);
                WeatherCycles.Add(weathercycle);
            }



            if (WeatherTypes.Count > 0)
            {
                CurrentWeatherType   = WeatherTypes.Values.First();
                CurrentWeatherRegion = CurrentWeatherType.GetRegion(Region);
                NextWeatherType      = CurrentWeatherType;
                NextWeatherRegion    = NextWeatherType.GetRegion(Region);
            }


            TimecycleMods = new TimecycleMods();
            TimecycleMods.Init(gameFileCache, updateStatus);


            Inited = true;
        }
Example #33
0
 public void SetWeatherType(WeatherTypes type)
 {
     BaseWeather.SetWeatherType(type);
 }
Example #34
0
 public static void Restart(Weather.WeatherTypes newWeather, int?newWeatherCycle = null)
 {
     currentWeather = newWeather;
     weatherCycle   = newWeatherCycle ?? Constants.WEATHER_CYCLE;
 }
Example #35
0
 public bool SetWeather(WeatherTypes iWeather)
 {
     return Server.Server_SetWeather((int)iWeather);
 }