//returns the destination passengers for a specific destination for a class public ushort getDestinationPassengersRate(Airport destination, AirlinerClass.ClassType type) { DestinationDemand pax = this.DestinationPassengers.Find(a => a.Destination == destination.Profile.IATACode); var values = Enum.GetValues(typeof(AirlinerClass.ClassType)); int classFactor = 0; int i = 1; foreach (AirlinerClass.ClassType value in values) { if (value == type) { classFactor = i; } i++; } if (pax == null) { return(this.Statics.getDestinationPassengersRate(destination, type)); } else { return((ushort)(this.Statics.getDestinationPassengersRate(destination, type) + (ushort)(pax.Rate / classFactor))); } }
//returns the destination cargo for a specific destination public ushort getDestinationCargoRate(Airport destination) { DestinationDemand cargo = this.CargoDemand.Find(a => a.Destination == destination.Profile.IATACode); if (cargo == null) { return(0); } else { return(cargo.Rate); } }
//returns the destination cargo for a specific destination public ushort getDestinationCargoRate(Airport destination) { DestinationDemand cargo = this.DestinationCargo.Find(a => a.Destination == destination.Profile.IATACode); if (cargo == null) { return(this.Statics.getDestinationCargoRate(destination)); } else { return((ushort)(cargo.Rate + (ushort)this.Statics.getDestinationCargoRate(destination))); } }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { DestinationDemand destination = (DestinationDemand)value; if (GameObject.GetInstance().HumanAirline.Airports.Contains(Airports.GetAirport(destination.Destination))) { return(Visibility.Visible); } else { return(Visibility.Collapsed); } }
//adds a cargo rate value to a destination public void addDestinationCargoRate(Airport destination, ushort rate) { lock (this.DestinationCargo) { DestinationDemand destinationCargo = getDestinationCargoObject(destination); if (destinationCargo != null) { destinationCargo.Rate += rate; } else { this.DestinationCargo.Add(new DestinationDemand(destination.Profile.IATACode, rate)); } } }
//adds a passenger rate value to a destination public void addDestinationPassengersRate(Airport destination, ushort rate) { lock (this.DestinationPassengers) { DestinationDemand destinationPassengers = getDestinationPassengersObject(destination); if (destinationPassengers != null) { destinationPassengers.Rate += rate; } else { this.DestinationPassengers.Add(new DestinationDemand(destination.Profile.IATACode, rate)); } } }
//shows the passengers private void showDemand() { lbPassengers.Items.Clear(); List <Airport> airports; if (domesticDemand) { airports = Airports.GetAirports(a => a != this.Airport && a.Profile.Country == this.Airport.Profile.Country).OrderByDescending(a => this.Airport.getDestinationPassengersRate(a, AirlinerClass.ClassType.Economy_Class)).ToList(); } else { airports = Airports.GetAirports(a => a != this.Airport && a.Profile.Country != this.Airport.Profile.Country).OrderByDescending(a => this.Airport.getDestinationPassengersRate(a, AirlinerClass.ClassType.Economy_Class)).ToList(); } foreach (Airport airport in airports) { int passengers = this.Airport.getDestinationPassengersRate(airport, AirlinerClass.ClassType.Economy_Class); int cargo = this.Airport.getDestinationCargoRate(airport); if (passengers > 0 || cargo > 0) { DestinationDemand passengerDemand = new DestinationDemand(airport.Profile.IATACode, (ushort)passengers); DestinationDemand cargoDemand = new DestinationDemand(airport.Profile.IATACode, (ushort)cargo); int demand = passengers; int covered = 0; List <Route> routes = AirportHelpers.GetAirportRoutes(airport, this.Airport).Where(r => r.Type == Route.RouteType.Mixed || r.Type == Route.RouteType.Passenger).ToList(); foreach (Route route in routes) { RouteAirlinerClass raClass = ((PassengerRoute)route).getRouteAirlinerClass(AirlinerClass.ClassType.Economy_Class); double avgPassengers = route.Statistics.getStatisticsValue(raClass, StatisticsTypes.GetStatisticsType("Passengers%")); double flights = route.TimeTable.Entries.Count; double routeCovered = avgPassengers / (7.0 / flights); covered += (int)routeCovered; } KeyValuePair <DestinationDemand, int> paxDemand = new KeyValuePair <DestinationDemand, int>(passengerDemand, Math.Max(0, demand - covered)); KeyValuePair <DestinationDemand, int> cDemand = new KeyValuePair <DestinationDemand, int>(cargoDemand, 0); KeyValuePair <KeyValuePair <DestinationDemand, int>, KeyValuePair <DestinationDemand, int> > totalDemand = new KeyValuePair <KeyValuePair <DestinationDemand, int>, KeyValuePair <DestinationDemand, int> >(paxDemand, cDemand); lbPassengers.Items.Add(totalDemand); } } }
//adds a cargo rate for a destination public void addDestinationCargoRate(DestinationDemand cargo) { this.Statics.addCargoDemand(cargo); }
//adds a passenger rate for a destination public void addDestinationPassengersRate(DestinationDemand passengers) { this.Statics.addPassengerDemand(passengers); }
//adds cargo demand to the airport public void addCargoDemand(DestinationDemand demand) { lock (this.CargoDemand) this.CargoDemand.Add(demand); }
//adds passenger demand to the airport public void addPassengerDemand(DestinationDemand demand) { lock (this.PassengerDemand) this.PassengerDemand.Add(demand); }