本文整理汇总了C#中TheAirline.Model.AirportModel.Airport.getDestinationCargoRate方法的典型用法代码示例。如果您正苦于以下问题:C# Airport.getDestinationCargoRate方法的具体用法?C# Airport.getDestinationCargoRate怎么用?C# Airport.getDestinationCargoRate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TheAirline.Model.AirportModel.Airport
的用法示例。
在下文中一共展示了Airport.getDestinationCargoRate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFlightCargo
public static double GetFlightCargo(Airport airportCurrent, Airport airportDestination, FleetAirliner airliner)
{
double destinationFacilityFactor = airportDestination.getAirportFacility(GameObject.GetInstance().HumanAirline, AirportFacility.FacilityType.Cargo, true).ServiceLevel;
double distance = MathHelpers.GetDistance(airportCurrent, airportDestination);
double capacity = ((AirlinerCargoType)airliner.Airliner.Type).CargoSize;
double demand = (double)airportCurrent.getDestinationCargoRate(airportDestination) * (destinationFacilityFactor / 100);
double cargoDemand = demand * 1000;
List<Route> routes = new List<Route>();
foreach (Airline airline in Airlines.GetAllAirlines())
{
var aRoutes = new List<Route>(airline.Routes);
routes.AddRange(aRoutes.Where(r => r.Type == Route.RouteType.Cargo || r.Type == Route.RouteType.Mixed).Where(r => (r.HasAirliner) && (r.Destination1 == airportCurrent || r.Destination1 == airportDestination) && (r.Destination2 == airportDestination || r.Destination2 == airportCurrent)));
routes.AddRange(aRoutes.Where(r => r.Type == Route.RouteType.Mixed || r.Type == Route.RouteType.Cargo).Where(r => r.Stopovers.SelectMany(s => s.Legs.Where(l => r.HasAirliner && (l.Destination1 == airportCurrent || l.Destination1 == airportDestination) && (l.Destination2 == airportDestination || l.Destination2 == airportCurrent))).Count() > 0));
}
double flightsPerDay = Convert.ToDouble(routes.Sum(r => r.TimeTable.Entries.Count)) / 7;
cargoDemand = cargoDemand / flightsPerDay;
double totalCapacity = 0;
if (routes.Count > 0 && routes.Count(r => r.HasAirliner) > 0)
totalCapacity = routes.Where(r => r.HasAirliner).Sum(r => r.getAirliners().Max(a => ((AirlinerCargoType)a.Airliner.Type).CargoSize));//SelectMany(r => r.Stopovers.Where(s=>s.Legs.Count >0))).Sum(s=>s.;//a => a.Routes.SelectMany(r=>r.Stopovers.SelectMany(s=>s.Legs.Where(l=>r.HasAirliner && (l.Destination1 == airportCurrent || l.Destination1 == airportDestination) && (l.Destination2 == airportDestination || l.Destination2 == airportCurrent))).Sum(r=>r.getAirliners().Max(a=>a.Airliner.getTotalSeatCapacity()));
else
totalCapacity = 0;// routes.Where(r => r.HasAirliner).Sum(r => r.getAirliners().Max(a => a.Airliner.getTotalSeatCapacity()));
double capacityPercent = cargoDemand > totalCapacity ? 1 : cargoDemand / totalCapacity;
double basicCargoPrice = GetCargoPrice(airportCurrent, airportDestination);
double cargoPrice = airliner.CurrentFlight.getCargoPrice();
double priceDiff = basicCargoPrice / cargoPrice;
double cargoPriceDiff = priceDiff < 0.75 ? priceDiff : 1;
cargoPriceDiff *= GameObject.GetInstance().Difficulty.PriceLevel;
double randomCargo = Convert.ToDouble(rnd.Next(97, 103)) / 100;
int cargo = (int)Math.Min(capacity, (capacity * capacityPercent * randomCargo * cargoPriceDiff));
return cargo;
}