public Manufacturer(string name, string shortname, Country country, Boolean isReal) { this.Name = name; this.ShortName = shortname; this.Country = country; this.IsReal = isReal; }
//returns a random last name public string getRandomLastName(Country country) { if (!this.LastNames.ContainsKey(country)) { var countries = this.FirstNames.Select(n => n.Key); country = countries.ElementAt(rnd.Next(countries.Count())); } return getRandomElement(this.LastNames[country]); }
public Manufacturer(string name, string shortname, Country country) { this.Name = name; this.ShortName = shortname; this.Country = country; }
public CountryTailNumber(Country country) { this.Country = country; }
//sets the airports view private void setAirportsView(int year, Country country) { GameObject.GetInstance().GameTime = new DateTime(year, 1, 1); try { airportsView.Filter = o => { Airport a = o as Airport; return ((Country)new CountryCurrentCountryConverter().Convert(a.Profile.Country)) == (Country)new CountryCurrentCountryConverter().Convert(country) && (a.Profile.Town.State == null || !a.Profile.Town.State.IsOverseas) && GeneralHelpers.IsAirportActive(a);// && a.Terminals.getNumberOfGates() > 10 //a.Profile.Period.From<=GameObject.GetInstance().GameTime && a.Profile.Period.To > GameObject.GetInstance().GameTime; }; } catch (Exception ex) { string exception = ex.ToString(); } if (cbAirport.SelectedIndex == -1) cbAirport.SelectedIndex = 0; }
//returns if there is flight restrictions for airlines to one of the destinations public static Boolean HasRestriction(Airline airline, Country dest1, Country dest2, DateTime date) { return HasRestriction(airline.Profile.Country, dest2, date, FlightRestriction.RestrictionType.Airlines) || HasRestriction(airline.Profile.Country,dest1,date,FlightRestriction.RestrictionType.Airlines); }
//returns if there is flight restrictions between two countries public static Boolean HasRestriction(Country country1, Country country2, DateTime date) { return HasRestriction(country1, country2, date, FlightRestriction.RestrictionType.Flights) || HasRestriction(country2, country1, date, FlightRestriction.RestrictionType.Flights); }
//returns if there is flight restrictions from one country to another public static Boolean HasRestriction(Country from, Country to, DateTime date, FlightRestriction.RestrictionType type) { FlightRestriction restriction = GetRestrictions().Find(r=>(r.From == from || (r.From is Union && ((Union)r.From).isMember(from,date))) && (r.To == to || (r.To is Union && ((Union)r.To).isMember(to,date))) && (date>=r.StartDate && date<=r.EndDate) && r.Type == type); //FlightRestriction res = GetRestrictions().Find(r => r.From == from && r.To == to && r.Type == type); return restriction != null; }
//adds a country to the list public static void AddCountry(Country country) { countries.Add(country.Uid, country); }
/*!loads the countries. */ private static void LoadCountries() { List<XmlElement> territoryElements = new List<XmlElement>(); XmlDocument doc = new XmlDocument(); doc.Load(AppSettings.getDataPath() + "\\countries.xml"); XmlElement root = doc.DocumentElement; XmlNodeList countriesList = root.SelectNodes("//country"); foreach (XmlElement element in countriesList) { XmlElement territoryElement = (XmlElement)element.SelectSingleNode("territoryof"); if (territoryElement != null) { territoryElements.Add(element); } else { string section = root.Name; string uid = element.Attributes["uid"].Value; string shortname = element.Attributes["shortname"].Value; string flag = element.Attributes["flag"].Value; Region region = Regions.GetRegion(element.Attributes["region"].Value); string tailformat = element.Attributes["tailformat"].Value; Country country = new Country(section, uid, shortname, region, tailformat); country.Flag = AppSettings.getDataPath() + "\\graphics\\flags\\" + flag + ".png"; Countries.AddCountry(country); XmlNodeList currenciesList = element.SelectNodes("currency"); foreach (XmlElement currencyElement in currenciesList) { string currencySymbol = currencyElement.Attributes["symbol"].Value; ; double currencyRate = Convert.ToDouble(currencyElement.Attributes["rate"].Value, CultureInfo.GetCultureInfo("en-US").NumberFormat); CountryCurrency.CurrencyPosition currencyPosition = (CountryCurrency.CurrencyPosition)Enum.Parse(typeof(CountryCurrency.CurrencyPosition), currencyElement.Attributes["position"].Value); DateTime currencyFromDate = new DateTime(1900, 1, 1); DateTime currencyToDate = new DateTime(2199, 12, 31); if (currencyElement.HasAttribute("from")) currencyFromDate = Convert.ToDateTime(currencyElement.Attributes["from"].Value); if (currencyElement.HasAttribute("to")) currencyToDate = Convert.ToDateTime(currencyElement.Attributes["to"].Value); country.addCurrency(new CountryCurrency(currencyFromDate, currencyToDate, currencySymbol, currencyPosition, currencyRate)); } if (element.SelectSingleNode("translations") != null) Translator.GetInstance().addTranslation(root.Name, element.Attributes["uid"].Value, element.SelectSingleNode("translations")); } } //reads all countries which is a territory for another foreach (XmlElement element in territoryElements) { string section = root.Name; string uid = element.Attributes["uid"].Value; string shortname = element.Attributes["shortname"].Value; string flag = element.Attributes["flag"].Value; Region region = Regions.GetRegion(element.Attributes["region"].Value); string tailformat = element.Attributes["tailformat"].Value; XmlElement territoryElement = (XmlElement)element.SelectSingleNode("territoryof"); Country territoryOf = Countries.GetCountry(territoryElement.Attributes["uid"].Value); Country country = new TerritoryCountry(section, uid, shortname, region, tailformat, territoryOf); country.Flag = AppSettings.getDataPath() + "\\graphics\\flags\\" + flag + ".png"; Countries.AddCountry(country); if (element.SelectSingleNode("translations") != null) Translator.GetInstance().addTranslation(root.Name, element.Attributes["uid"].Value, element.SelectSingleNode("translations")); } }
//returns the current country for the country public Country getCurrentCountry(DateTime date, Country originalCountry) { if (this.Type == TemporaryType.ManyToOne) { if (date < this.StartDate) return this.CountryBefore; if (date >= this.StartDate && date <= this.EndDate) return this; if (date > this.EndDate) return this.CountryAfter; } if (this.Type == TemporaryType.OneToMany) { OneToManyCountry tCountry = this.Countries.Find(c => c.Country == originalCountry); if (tCountry == null) return originalCountry; if (date >= tCountry.StartDate && date <= tCountry.EndDate) return this; else return originalCountry; } return null; }
public TemporaryCountry(TemporaryType type, Country country, DateTime startDate, DateTime endDate) : base(Country.Section, country.Uid, country.ShortName, country.Region, country.TailNumberFormat) { this.Type = type; this.StartDate = startDate; this.EndDate = endDate; this.Countries = new List<OneToManyCountry>(); this.CountryAfter = this; this.CountryBefore = this; }
//returns a temporary country which a country is a part of public static TemporaryCountry GetTemporaryCountry(Country country,DateTime date) { if (country == null) return null; TemporaryCountry tCountry = tCountries.Find(c => c.StartDate<date && c.EndDate>date && (c.CountryBefore == country || c.CountryAfter == country || c.Countries.Find(tc=>tc.Country.Uid==country.Uid)!=null)); return tCountry; }
public OneToManyCountry(Country country, DateTime startDate, DateTime endDate) { this.StartDate = startDate; this.EndDate = endDate; this.Country = country; }
public TerritoryCountry(string section, string uid, string shortName, Region region, string tailNumberFormat, Country mainCountry) : base(section,uid,shortName,region,tailNumberFormat) { this.MainCountry = mainCountry; }
//adds a country to the routes public void addCountry(Country country) { this.Countries.Add(country); }
//returns all airports from a specific country public static List<Airport> GetAirports(Country country) { return GetAirports(delegate(Airport airport) { return airport.Profile.Country == country; }); }
/*! loads the temporary countries */ private static void LoadTemporaryCountries() { XmlDocument doc = new XmlDocument(); doc.Load(AppSettings.getDataPath() + "\\temporary countries.xml"); XmlElement root = doc.DocumentElement; XmlNodeList countriesList = root.SelectNodes("//country"); foreach (XmlElement element in countriesList) { string section = root.Name; string uid = element.Attributes["uid"].Value; string shortname = element.Attributes["shortname"].Value; string flag = element.Attributes["flag"].Value; Region region = Regions.GetRegion(element.Attributes["region"].Value); string tailformat = element.Attributes["tailformat"].Value; TemporaryCountry.TemporaryType tempType = (TemporaryCountry.TemporaryType)Enum.Parse(typeof(TemporaryCountry.TemporaryType), element.Attributes["type"].Value); XmlElement periodElement = (XmlElement)element.SelectSingleNode("period"); DateTime startDate = Convert.ToDateTime(periodElement.Attributes["start"].Value, new CultureInfo("en-US", false)); DateTime endDate = Convert.ToDateTime(periodElement.Attributes["end"].Value, new CultureInfo("en-US", false)); Country country = new Country(section, uid, shortname, region, tailformat); if (element.SelectSingleNode("translations") != null) Translator.GetInstance().addTranslation(root.Name, element.Attributes["uid"].Value, element.SelectSingleNode("translations")); XmlElement historyElement = (XmlElement)element.SelectSingleNode("history"); TemporaryCountry tCountry = new TemporaryCountry(tempType, country, startDate, endDate); if (tempType == TemporaryCountry.TemporaryType.ManyToOne) { Country before = Countries.GetCountry(historyElement.Attributes["before"].Value); Country after = Countries.GetCountry(historyElement.Attributes["after"].Value); tCountry.CountryBefore = before; tCountry.CountryAfter = after; } if (tempType == TemporaryCountry.TemporaryType.OneToMany) { XmlNodeList tempCountriesList = historyElement.SelectNodes("tempcountries/tempcountry"); foreach (XmlElement tempCountryElement in tempCountriesList) { Country tempCountry = Countries.GetCountry(tempCountryElement.Attributes["id"].Value); DateTime cStartDate = Convert.ToDateTime(tempCountryElement.Attributes["start"].Value, new CultureInfo("en-US", false)); DateTime cEndDate = Convert.ToDateTime(tempCountryElement.Attributes["end"].Value, new CultureInfo("en-US", false)); tCountry.Countries.Add(new OneToManyCountry(tempCountry, cStartDate, cEndDate)); } } tCountry.Flag = AppSettings.getDataPath() + "\\graphics\\flags\\" + flag + ".png"; TemporaryCountries.AddCountry(tCountry); } }