Exemple #1
0
        private void btnQuickUpgradeFacility_Click(object sender, RoutedEventArgs e)
        {
            AirlineAirportFacilityMVVM currentFacility = (AirlineAirportFacilityMVVM)((Button)sender).Tag;

            List <AirportFacility> facilities = AirportFacilities.GetFacilities(currentFacility.Facility.Facility.Type);

            facilities = facilities.OrderBy(f => f.TypeLevel).ToList();

            int index = facilities.FindIndex(f => currentFacility.Facility.Facility == f);

            AirportFacility facility = facilities[index + 1];

            if (facility.Price > GameObject.GetInstance().HumanAirline.Money)
            {
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2201"), Translator.GetInstance().GetString("MessageBox", "2201", "message"), WPFMessageBoxButtons.Ok);
            }
            else
            {
                WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2202"), string.Format(Translator.GetInstance().GetString("MessageBox", "2202", "message"), facility.Name, new ValueCurrencyConverter().Convert(facility.Price)), WPFMessageBoxButtons.YesNo);

                if (result == WPFMessageBoxResult.Yes)
                {
                    double price = facility.Price;

                    if (this.Airport.Airport.Profile.Country != GameObject.GetInstance().HumanAirline.Profile.Country)
                    {
                        price = price * 1.25;
                    }

                    AirlineHelpers.AddAirlineInvoice(GameObject.GetInstance().HumanAirline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Purchases, -price);

                    this.Airport.addAirlineFacility(facility);
                }
            }
        }
Exemple #2
0
        private void btnDeleteFacility_Click(object sender, RoutedEventArgs e)
        {
            AirlineAirportFacilityMVVM facility = (AirlineAirportFacilityMVVM)((Button)sender).Tag;

            Boolean hasHub = this.Airport.Airport.getHubs().Count(h => h.Airline == GameObject.GetInstance().HumanAirline) > 0;

            Boolean hasCargoRoute           = GameObject.GetInstance().HumanAirline.Routes.Exists(r => (r.Destination1 == this.Airport.Airport || r.Destination2 == this.Airport.Airport) && r.Type == Model.AirlinerModel.RouteModel.Route.RouteType.Cargo);
            Boolean airportHasCargoTerminal = this.Airport.Airport.getCurrentAirportFacility(null, AirportFacility.FacilityType.Cargo) != null && this.Airport.Airport.getCurrentAirportFacility(null, AirportFacility.FacilityType.Cargo).TypeLevel > 0;

            if ((facility.Facility.Facility.TypeLevel == 1 && facility.Facility.Facility.Type == AirportFacility.FacilityType.Service && this.Airport.Airport.hasAsHomebase(GameObject.GetInstance().HumanAirline)))
            {
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2203"), Translator.GetInstance().GetString("MessageBox", "2203", "message"), WPFMessageBoxButtons.Ok);
            }
            else if (facility.Facility.Facility.Type == AirportFacility.FacilityType.Service && hasHub && facility.Facility.Facility == Hub.MinimumServiceFacility)
            {
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2214"), string.Format(Translator.GetInstance().GetString("MessageBox", "2214", "message"), Hub.MinimumServiceFacility.Name), WPFMessageBoxButtons.Ok);
            }
            else if (facility.Facility.Facility.Type == AirportFacility.FacilityType.Cargo && facility.Facility.Facility.TypeLevel == 1 && hasCargoRoute && !airportHasCargoTerminal)
            {
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2223"), Translator.GetInstance().GetString("MessageBox", "2223", "message"), WPFMessageBoxButtons.Ok);
            }
            else
            {
                WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2204"), string.Format(Translator.GetInstance().GetString("MessageBox", "2204", "message"), facility.Facility.Facility.Name), WPFMessageBoxButtons.YesNo);

                if (result == WPFMessageBoxResult.Yes)
                {
                    this.Airport.removeAirlineFacility(facility);
                }
            }
        }
Exemple #3
0
        //removes an airline facility from the airport
        public void removeAirlineFacility(AirlineAirportFacilityMVVM facility)
        {
            this.Airport.downgradeFacility(facility.Facility.Airline, facility.Facility.Facility.Type);

            this.AirlineFacilities.Remove(facility);

            if (this.Airport.getAirlineAirportFacility(facility.Facility.Airline, facility.Facility.Facility.Type).Facility.TypeLevel > 0)
            {
                Alliance alliance = facility.Facility.Airline.Alliances.Count == 0 ? null : facility.Facility.Airline.Alliances[0];
                this.AirlineFacilities.Add(new AirlineAirportFacilityMVVM(this.Airport.getAirlineAirportFacility(facility.Facility.Airline, facility.Facility.Facility.Type), alliance));
            }
        }
Exemple #4
0
        //adds an airline facility to the airport
        public void addAirlineFacility(AirportFacility facility)
        {
            AirlineAirportFacility nextFacility = new AirlineAirportFacility(GameObject.GetInstance().HumanAirline, this.Airport, facility, GameObject.GetInstance().GameTime.AddDays(facility.BuildingDays));

            this.Airport.setAirportFacility(nextFacility);

            AirlineAirportFacilityMVVM currentFacility = this.AirlineFacilities.Where(f => f.Facility.Facility.Type == facility.Type).FirstOrDefault();

            if (currentFacility != null)
            {
                this.AirlineFacilities.Remove(currentFacility);
            }

            Alliance alliance = nextFacility.Airline.Alliances.Count == 0 ? null : nextFacility.Airline.Alliances[0];


            this.AirlineFacilities.Add(new AirlineAirportFacilityMVVM(nextFacility, alliance));
        }
Exemple #5
0
        //removes an airline facility from the airport
        public void removeAirlineFacility(AirlineAirportFacilityMVVM facility)
        {
            this.Airport.removeFacility(facility.Facility.Airline, facility.Facility.Facility);

            this.AirlineFacilities.Remove(facility);

            if (this.Airport.getAirlineAirportFacility(facility.Facility.Airline, facility.Facility.Facility.Type).Facility.TypeLevel > 0)
            {
                Alliance alliance = facility.Facility.Airline.Alliances.Count == 0 ? null : facility.Facility.Airline.Alliances[0];

                AirlineAirportFacilityMVVM airlineFacility = new AirlineAirportFacilityMVVM(this.Airport.getAirlineAirportFacility(facility.Facility.Airline, facility.Facility.Facility.Type), alliance);

                if (airlineFacility.IsDelivered)
                {
                    this.AirlineFacilities.Add(airlineFacility);
                }
                else
                {
                    this.BuildingAirlineFacilities.Add(airlineFacility);
                }
            }
        }
Exemple #6
0
        //adds an airline facility to the airport
        public void addAirlineFacility(AirportFacility facility)
        {
            AirlineAirportFacility nextFacility = new AirlineAirportFacility(GameObject.GetInstance().HumanAirline, this.Airport, facility, GameObject.GetInstance().GameTime.AddDays(facility.BuildingDays));

            this.Airport.addAirportFacility(nextFacility);

            /*
             * AirlineAirportFacilityMVVM currentFacility = this.AirlineFacilities.Where(f => f.Facility.Facility.Type == facility.Type).FirstOrDefault();
             *
             * if (currentFacility != null)
             *  removeAirlineFacility(currentFacility);
             *
             * Alliance alliance = nextFacility.Airline.Alliances.Count == 0 ? null : nextFacility.Airline.Alliances[0];
             *
             * this.AirlineFacilities.Add(new AirlineAirportFacilityMVVM(nextFacility,alliance));
             * */
            this.AirlineFacilities.Clear();
            this.BuildingAirlineFacilities.Clear();

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

                    AirlineAirportFacilityMVVM airlineFacility = new AirlineAirportFacilityMVVM(tFacility, alliance);

                    if (airlineFacility.IsDelivered)
                    {
                        this.AirlineFacilities.Add(airlineFacility);
                    }
                    else
                    {
                        this.BuildingAirlineFacilities.Add(airlineFacility);
                    }
                }
            }
        }
Exemple #7
0
        //removes an airline facility from the airport
        public void removeAirlineFacility(AirlineAirportFacilityMVVM facility)
        {
            this.Airport.downgradeFacility(facility.Facility.Airline, facility.Facility.Facility.Type);

            this.AirlineFacilities.Remove(facility);

            if (this.Airport.getAirlineAirportFacility(facility.Facility.Airline, facility.Facility.Facility.Type).Facility.TypeLevel > 0)
            {
                Alliance alliance = facility.Facility.Airline.Alliances.Count == 0 ? null : facility.Facility.Airline.Alliances[0];
                this.AirlineFacilities.Add(new AirlineAirportFacilityMVVM(this.Airport.getAirlineAirportFacility(facility.Facility.Airline, facility.Facility.Facility.Type),alliance));
            }
        }
Exemple #8
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));
            }
        }
Exemple #9
0
        //removes an airline facility from the airport
        public void removeAirlineFacility(AirlineAirportFacilityMVVM facility)
        {
            this.Airport.removeFacility(facility.Facility.Airline, facility.Facility.Facility);

            this.AirlineFacilities.Remove(facility);

            if (this.Airport.getAirlineAirportFacility(facility.Facility.Airline, facility.Facility.Facility.Type).Facility.TypeLevel > 0)
            {
                Alliance alliance = facility.Facility.Airline.Alliances.Count == 0 ? null : facility.Facility.Airline.Alliances[0];

                AirlineAirportFacilityMVVM airlineFacility = new AirlineAirportFacilityMVVM(this.Airport.getAirlineAirportFacility(facility.Facility.Airline, facility.Facility.Facility.Type),alliance);

                if (airlineFacility.IsDelivered)
                    this.AirlineFacilities.Add(airlineFacility);
                else
                    this.BuildingAirlineFacilities.Add(airlineFacility);
            }
        }
Exemple #10
0
        //adds an airline facility to the airport
        public void addAirlineFacility(AirportFacility facility)
        {
            AirlineAirportFacility nextFacility = new AirlineAirportFacility(GameObject.GetInstance().HumanAirline,this.Airport, facility, GameObject.GetInstance().GameTime.AddDays(facility.BuildingDays));
            this.Airport.addAirportFacility(nextFacility);

            /*
            AirlineAirportFacilityMVVM currentFacility = this.AirlineFacilities.Where(f => f.Facility.Facility.Type == facility.Type).FirstOrDefault();

            if (currentFacility != null)
                removeAirlineFacility(currentFacility);

            Alliance alliance = nextFacility.Airline.Alliances.Count == 0 ? null : nextFacility.Airline.Alliances[0];

            this.AirlineFacilities.Add(new AirlineAirportFacilityMVVM(nextFacility,alliance));
             * */
            this.AirlineFacilities.Clear();
            this.BuildingAirlineFacilities.Clear();

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

                    AirlineAirportFacilityMVVM airlineFacility = new AirlineAirportFacilityMVVM(tFacility, alliance);

                    if (airlineFacility.IsDelivered)
                        this.AirlineFacilities.Add(airlineFacility);
                    else
                        this.BuildingAirlineFacilities.Add(airlineFacility);
                }
        }
Exemple #11
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));
        }
        //removes an airline facility from the airport
        public void removeAirlineFacility(AirlineAirportFacilityMVVM facility)
        {
            Airport.RemoveFacility(facility.Facility.Airline, facility.Facility.Facility);

            AirlineFacilities.Remove(facility);

            if (
                Airport.GetAirlineAirportFacility(facility.Facility.Airline, facility.Facility.Facility.Type)
                    .Facility.TypeLevel > 0)
            {
                Alliance alliance = facility.Facility.Airline.Alliances.Count == 0
                    ? null
                    : facility.Facility.Airline.Alliances[0];

                var airlineFacility =
                    new AirlineAirportFacilityMVVM(
                        Airport.GetAirlineAirportFacility(
                            facility.Facility.Airline,
                            facility.Facility.Facility.Type),
                        alliance);

                if (airlineFacility.IsDelivered)
                {
                    AirlineFacilities.Add(airlineFacility);
                }
                else
                {
                    BuildingAirlineFacilities.Add(airlineFacility);
                }
            }
        }