Example #1
0
        public static void ProcessWeather()
        {
            int i = 0;
            int x;

            if (E_Globals.CurrentWeather > 0)
            {
                if (E_Globals.CurrentWeather == (int)Enums.WeatherType.Rain || E_Globals.CurrentWeather == (int)Enums.WeatherType.Storm)
                {
                    PlayWeatherSound("Rain.ogg", true);
                }
                x = ClientDataBase.Rand(1, 101 - E_Globals.CurrentWeatherIntensity);
                if (x == 1)
                {
                    //Add a new particle
                    for (i = 1; i <= MAX_WEATHER_PARTICLES; i++)
                    {
                        if (WeatherParticle[i].InUse == 0)
                        {
                            if (ClientDataBase.Rand(1, 3) == 1)
                            {
                                WeatherParticle[i].InUse    = 1;
                                WeatherParticle[i].type     = E_Globals.CurrentWeather;
                                WeatherParticle[i].Velocity = ClientDataBase.Rand(8, 14);
                                WeatherParticle[i].X        = (E_Globals.TileView.Left * 32) - 32;
                                WeatherParticle[i].Y        = (E_Globals.TileView.Top * 32) + ClientDataBase.Rand(-32, (int)E_Graphics.GameWindow.Size.Y);
                            }
                            else
                            {
                                WeatherParticle[i].InUse    = 1;
                                WeatherParticle[i].type     = E_Globals.CurrentWeather;
                                WeatherParticle[i].Velocity = ClientDataBase.Rand(10, 15);
                                WeatherParticle[i].X        = (E_Globals.TileView.Left * 32) + ClientDataBase.Rand(-32, (int)E_Graphics.GameWindow.Size.X);
                                WeatherParticle[i].Y        = (E_Globals.TileView.Top * 32) - 32;
                            }
                            //Exit For
                        }
                    }
                }
            }
            else
            {
                StopWeatherSound();
            }
            if (E_Globals.CurrentWeather == (int)Enums.WeatherType.Storm)
            {
                x = ClientDataBase.Rand(1, 400 - E_Globals.CurrentWeatherIntensity);
                if (x == 1)
                {
                    //Draw Thunder
                    E_Globals.DrawThunder = ClientDataBase.Rand(15, 22);
                    E_Sound.PlayExtraSound("Thunder.ogg");
                }
            }
            for (i = 1; i <= MAX_WEATHER_PARTICLES; i++)
            {
                if (WeatherParticle[i].InUse == 1)
                {
                    if (WeatherParticle[i].X > E_Globals.TileView.Right * 32 || WeatherParticle[i].Y > E_Globals.TileView.Bottom * 32)
                    {
                        WeatherParticle[i].InUse = 0;
                    }
                    else
                    {
                        WeatherParticle[i].X = WeatherParticle[i].X + WeatherParticle[i].Velocity;
                        WeatherParticle[i].Y = WeatherParticle[i].Y + WeatherParticle[i].Velocity;
                    }
                }
            }
        }