//checks an airport for extending of runway public static void CheckForExtendRunway(Airport airport) { int minYearsBetweenExpansions = 5; long maxRunwayLenght = (from r in airport.Runways select r.Length).Max(); long longestRequiredRunwayLenght = AirlinerTypes.GetTypes(a => a.Produced.From <= GameObject.GetInstance().GameTime&& a.Produced.To >= GameObject.GetInstance().GameTime).Max(a => a.MinRunwaylength); var airportRoutes = AirportHelpers.GetAirportRoutes(airport); var routeAirliners = airportRoutes.SelectMany(r => r.getAirliners()); long longestRunwayInUse = routeAirliners.Count() > 0 ? routeAirliners.Max(a => a.Airliner.Type.MinRunwaylength) : 0; if (maxRunwayLenght < longestRequiredRunwayLenght / 2 && maxRunwayLenght < longestRunwayInUse * 3 / 4 && GameObject.GetInstance().GameTime.AddYears(-minYearsBetweenExpansions) > airport.LastExpansionDate) { List <string> runwayNames = (from r in Airports.GetAllAirports().SelectMany(a => a.Runways) select r.Name).Distinct().ToList(); foreach (Runway r in airport.Runways) { runwayNames.Remove(r.Name); } Runway.SurfaceType surface = airport.Runways[0].Surface; long lenght = Math.Min(longestRequiredRunwayLenght * 3 / 4, longestRunwayInUse * 2); Runway runway = new Runway(runwayNames[rnd.Next(runwayNames.Count)], lenght, surface, GameObject.GetInstance().GameTime.AddDays(90), false); airport.Runways.Add(runway); airport.LastExpansionDate = GameObject.GetInstance().GameTime; } }
private void btnOk_Click(object sender, RoutedEventArgs e) { string name = txtName.Text.Trim(); Runway.SurfaceType type = (Runway.SurfaceType)cbSurface.SelectedItem; int lenght = Convert.ToInt32(cbLenght.SelectedItem); Runway runway = new Runway(name, lenght, type, GameObject.GetInstance().GameTime.AddDays(90), false); this.Selected = runway; this.Close(); }