Пример #1
0
        //calculates employee happiness as a function of wages, discounts, and free pilots (relative to workload)
        public static double GetEmployeeHappiness(Airline airline)
        {
            Dictionary <Airline, Double>  wages            = StatisticsHelpers.GetEmployeeWages();
            Dictionary <Airline, Double>  discounts        = StatisticsHelpers.GetEmployeeDiscounts();
            Dictionary <Airline, Double>  unassignedPilots = StatisticsHelpers.GetUnassignedPilots();
            IDictionary <Airline, Double> scaleWages       = StatisticsHelpers.GetRatingScale(wages);
            IDictionary <Airline, Double> scaleDiscounts   = StatisticsHelpers.GetRatingScale(discounts);
            IDictionary <Airline, Double> scaleUPilots     = StatisticsHelpers.GetRatingScale(unassignedPilots);

            double airlineWages            = scaleWages[airline];
            double airlineDiscounts        = scaleDiscounts[airline];
            double airlineUnassignedPilots = scaleUPilots[airline];

            return((airlineWages * 0.7) + (airlineUnassignedPilots * 0.2) + (airlineDiscounts * 0.1));
        }
Пример #2
0
        //calculates customer happiness as a function of average ticket price, crowding on flights, and on-time % - for an airline
        public static double GetCustomerHappiness(Airline airline)
        {
            int negInt = -1;
            Dictionary <Airline, Double>  fillAverages  = StatisticsHelpers.GetFillAverages();
            Dictionary <Airline, Double>  onTimePercent = StatisticsHelpers.GetTotalOnTime();
            Dictionary <Airline, Double>  ticketPPD     = StatisticsHelpers.GetTotalPPD();
            IDictionary <Airline, Double> scaleAvgFill  = StatisticsHelpers.GetRatingScale(fillAverages);
            IDictionary <Airline, Double> scaleOnTimeP  = StatisticsHelpers.GetRatingScale(onTimePercent);
            IDictionary <Airline, Double> scalePPD      = StatisticsHelpers.GetRatingScale(ticketPPD);
            IDictionary <Airline, Double> scaleLuxury   = StatisticsHelpers.GetRatingScale(GetAirlinesLuxuryLevels());

            double airlineAvgFill = scaleAvgFill[airline];
            double airlineOTP     = scaleOnTimeP[airline];
            double airlinePPD     = scalePPD[airline];
            double airlineLuxury  = scaleLuxury[airline];

            return(((airlinePPD * negInt + 100) * 0.4) + (airlineAvgFill * 0.2) + (airlineOTP * 0.2) + (airlineLuxury * 0.2));
        }
Пример #3
0
        public AirportMVVM(Airport airport)
        {
            this.Airport = airport;

            this.TerminalGatePrice = this.Airport.getTerminalGatePrice();
            this.TerminalPrice     = this.Airport.getTerminalPrice();

            this.Cooperations      = new ObservableCollection <Cooperation>();
            this.Terminals         = new ObservableCollection <AirportTerminalMVVM>();
            this.BuildingTerminals = new ObservableCollection <AirportTerminalMVVM>();

            foreach (Terminal terminal in this.Airport.Terminals.getTerminals())
            {
                Boolean isSellable = terminal.Airline != null && terminal.Airline == GameObject.GetInstance().HumanAirline;

                if (terminal.IsBuilt)
                {
                    this.Terminals.Add(new AirportTerminalMVVM(terminal, terminal.IsBuyable, isSellable));
                }
                else
                {
                    this.BuildingTerminals.Add(new AirportTerminalMVVM(terminal, terminal.IsBuyable, isSellable));
                }
            }
            this.Contracts = new ObservableCollection <ContractMVVM>();

            foreach (AirportContract contract in this.Airport.AirlineContracts)
            {
                this.Contracts.Add(new ContractMVVM(contract));
            }

            foreach (Cooperation cooperation in this.Airport.Cooperations)
            {
                this.Cooperations.Add(cooperation);
            }

            AirportHelpers.CreateAirportWeather(this.Airport);

            this.Weather = this.Airport.Weather.ToList();

            if (!GameObject.GetInstance().DayRoundEnabled)
            {
                this.CurrentWeather = this.Weather[0].Temperatures[GameObject.GetInstance().GameTime.Hour];
            }

            this.FreeGates = this.Airport.Terminals.NumberOfFreeGates;

            this.Demands = new List <DemandMVVM>();

            var demands = this.Airport.getDestinationDemands().Where(a => a != null && GeneralHelpers.IsAirportActive(a)).OrderByDescending(a => this.Airport.getDestinationPassengersRate(a, AirlinerClass.ClassType.Economy_Class));

            var internationalDemand = demands.Where(a => new CountryCurrentCountryConverter().Convert(a.Profile.Country) != new CountryCurrentCountryConverter().Convert(this.Airport.Profile.Country));
            var domesticDemand      = demands.Where(a => new CountryCurrentCountryConverter().Convert(a.Profile.Country) == new CountryCurrentCountryConverter().Convert(this.Airport.Profile.Country));

            foreach (Airport destination in internationalDemand)
            {
                this.Demands.Add(new DemandMVVM(destination, (int)this.Airport.getDestinationPassengersRate(destination, AirlinerClass.ClassType.Economy_Class), (int)this.Airport.Profile.Pax, (int)this.Airport.getDestinationCargoRate(destination), DemandMVVM.DestinationType.International));
            }

            foreach (Airport destination in domesticDemand)
            {
                this.Demands.Add(new DemandMVVM(destination, (int)this.Airport.getDestinationPassengersRate(destination, AirlinerClass.ClassType.Economy_Class), (int)this.Airport.Profile.Pax, (int)this.Airport.getDestinationCargoRate(destination), DemandMVVM.DestinationType.Domestic));
            }

            this.AirportFacilities = this.Airport.getAirportFacilities().FindAll(f => f.Airline == null && f.Facility.TypeLevel != 0).Select(f => f.Facility).Distinct().ToList();

            this.AirlineFacilities         = new ObservableCollection <AirlineAirportFacilityMVVM>();
            this.BuildingAirlineFacilities = new ObservableCollection <AirlineAirportFacilityMVVM>();

            foreach (var facility in this.Airport.getAirportFacilities().FindAll(f => f.Airline != null))
            {
                if (facility.Facility.TypeLevel != 0)
                {
                    Alliance alliance = facility.Airline.Alliances.Count == 0 ? null : facility.Airline.Alliances[0];

                    AirlineAirportFacilityMVVM airlineFacility = new AirlineAirportFacilityMVVM(facility, alliance);

                    if (airlineFacility.IsDelivered)
                    {
                        if (facility == Airport.getAirlineAirportFacility(facility.Airline, facility.Facility.Type))
                        {
                            this.AirlineFacilities.Add(airlineFacility);
                        }
                    }
                    else
                    {
                        this.BuildingAirlineFacilities.Add(airlineFacility);
                    }
                }
            }

            this.AirlineStatistics = new List <AirportStatisticsMVMM>();

            foreach (Airline airline in Airlines.GetAllAirlines())
            {
                StatisticsType passengersType    = StatisticsTypes.GetStatisticsType("Passengers");
                StatisticsType passengersAvgType = StatisticsTypes.GetStatisticsType("Passengers%");
                StatisticsType arrivalsType      = StatisticsTypes.GetStatisticsType("Arrivals");

                double passengers    = this.Airport.Statistics.getStatisticsValue(GameObject.GetInstance().GameTime.Year, airline, passengersType);
                double passengersAvg = this.Airport.Statistics.getStatisticsValue(GameObject.GetInstance().GameTime.Year, airline, passengersAvgType);
                double arrivals      = this.Airport.Statistics.getStatisticsValue(GameObject.GetInstance().GameTime.Year, airline, arrivalsType);

                int routes = airline.Routes.Count(r => r.Destination1 == this.Airport || r.Destination2 == this.Airport);

                this.AirlineStatistics.Add(new AirportStatisticsMVMM(airline, passengers, passengersAvg, arrivals, routes));
            }

            this.Traffic = new List <AirportTrafficMVVM>();

            var passengerDestinations = from a in Airports.GetAllActiveAirports() orderby this.Airport.getDestinationPassengerStatistics(a) descending select a;

            var cargoDestinations = from a in Airports.GetAllActiveAirports() orderby this.Airport.getDestinationCargoStatistics(a) descending select a;

            foreach (Airport a in passengerDestinations.Take(20))
            {
                this.Traffic.Add(new AirportTrafficMVVM(a, this.Airport.getDestinationPassengerStatistics(a), AirportTrafficMVVM.TrafficType.Passengers));
            }

            foreach (Airport a in cargoDestinations.Take(20))
            {
                this.Traffic.Add(new AirportTrafficMVVM(a, Convert.ToInt64(this.Airport.getDestinationCargoStatistics(a)), AirportTrafficMVVM.TrafficType.Cargo));
            }

            this.Flights = new List <DestinationFlightsMVVM>();

            var airportRoutes = AirportHelpers.GetAirportRoutes(this.Airport).Where(r => r.getAirliners().Count > 0);

            foreach (Route airportRoute in airportRoutes)
            {
                double distance = MathHelpers.GetDistance(airportRoute.Destination1, airportRoute.Destination2);

                Airport destination = airportRoute.Destination1 == this.Airport ? airportRoute.Destination2 : airportRoute.Destination1;
                if (this.Flights.Exists(f => f.Airline == airportRoute.Airline && f.Airport == destination))
                {
                    DestinationFlightsMVVM flight = this.Flights.First(f => f.Airline == airportRoute.Airline && f.Airport == destination);

                    flight.Flights += airportRoute.TimeTable.getEntries(destination).Count;

                    foreach (AirlinerType aircraft in airportRoute.getAirliners().Select(a => a.Airliner.Type))
                    {
                        if (!flight.Aircrafts.Contains(aircraft))
                        {
                            flight.Aircrafts.Add(aircraft);
                        }
                    }
                }
                else
                {
                    this.Flights.Add(new DestinationFlightsMVVM(destination, airportRoute.Airline, distance, airportRoute.getAirliners().Select(a => a.Airliner.Type).ToList(), airportRoute.TimeTable.getEntries(destination).Count));
                }
            }

            /*
             * Dictionary<Airport, int> destinations = new Dictionary<Airport, int>();
             * foreach (Route route in AirportHelpers.GetAirportRoutes(this.Airport).FindAll(r => r.getAirliners().Count > 0))
             * {
             *  if (route.Destination1 != this.Airport)
             *  {
             *      if (!destinations.ContainsKey(route.Destination1))
             *          destinations.Add(route.Destination1, 0);
             *      destinations[route.Destination1] += route.TimeTable.getEntries(route.Destination1).Count;
             *
             *
             *  }
             *  if (route.Destination2 != this.Airport)
             *  {
             *      if (!destinations.ContainsKey(route.Destination2))
             *          destinations.Add(route.Destination2, 0);
             *      destinations[route.Destination2] += route.TimeTable.getEntries(route.Destination2).Count;
             *  }
             * }
             *
             * foreach (Airport a in destinations.Keys)
             *  this.Flights.Add(new DestinationFlightsMVVM(a, destinations[a]));
             */

            this.Hubs = new ObservableCollection <Hub>();

            foreach (Hub hub in this.Airport.getHubs())
            {
                this.Hubs.Add(hub);
            }

            this.CanBuildHub        = canBuildHub();
            this.CanMakeCooperation = GameObject.GetInstance().HumanAirline.Airports.Exists(a => a == this.Airport);

            this.LocalTime = MathHelpers.ConvertDateTimeToLoalTime(GameObject.GetInstance().GameTime, this.Airport.Profile.TimeZone);

            this.ShowLocalTime = !GameObject.GetInstance().DayRoundEnabled;

            this.AirlineReputations = new List <AirlineReputationMVVM>();

            IDictionary <Airline, double> airlineScores = new Dictionary <Airline, double>();

            foreach (Airline airline in Airlines.GetAllAirlines())
            {
                airlineScores.Add(airline, this.Airport.getAirlineReputation(airline));
            }

            foreach (KeyValuePair <Airline, double> score in StatisticsHelpers.GetRatingScale(airlineScores))
            {
                this.AirlineReputations.Add(new AirlineReputationMVVM(score.Key, (int)score.Value));
            }
        }