Ejemplo n.º 1
0
        public void MakeWeatherRateList()
        {
            if (Weathers == null)
            {
                throw new Exception("Weathers has to be loaded for WeatherRates to be read");
            }

            WeatherRates = new Dictionary <int, WeatherRate>();

            try
            {
                using (TextFieldParser parser = new TextFieldParser(new StringReader(Resources.weatherrate_exh)))
                {
                    parser.TextFieldType = FieldType.Delimited;
                    parser.SetDelimiters(",");
                    int rowCount = 0;
                    parser.ReadFields();
                    while (!parser.EndOfData)
                    {
                        WeatherRate rate = new WeatherRate();

                        rate.AllowedWeathers = new List <Weather>();

                        //Processing row
                        rowCount++;
                        string[] fields = parser.ReadFields();

                        rate.Index = int.Parse(fields[0]);

                        for (int i = 1; i < 17;)
                        {
                            int weatherId = int.Parse(fields[i]);

                            if (weatherId == 0)
                            {
                                break;
                            }

                            rate.AllowedWeathers.Add(Weathers[weatherId]);

                            i += 2;
                        }

                        WeatherRates.Add(rate.Index, rate);
                    }

                    //   Console.WriteLine($"{rowCount} weatherRates read");
                }
            }
            catch (Exception exc)
            {
                WeatherRates = null;
#if DEBUG
                throw exc;
#endif
            }
        }
Ejemplo n.º 2
0
        private void GetWeathers()
        {
            if (this.Value == null)
            {
                return;
            }

            this.weathers.Clear();

            WeatherRate weatherRate = GameDataService.WeatherRates !.GetRow((uint)this.Value.WeatherRate);

            if (weatherRate != null && weatherRate.UnkStruct0 != null)
            {
                foreach (WeatherRate.UnkStruct0Struct wr in weatherRate.UnkStruct0)
                {
                    if (wr.Weather == 0)
                    {
                        continue;
                    }

                    this.weathers.Add(GameDataService.Weathers !.Get(wr.Weather));
                }
            }
        }