Пример #1
0
        private void ButtonSell_Click(object sender, RoutedEventArgs e)
        {
            HumanFacilityType type   = (HumanFacilityType)((Button)sender).Tag;
            Boolean           hasHub = this.Airport.getHubs().Count(h => h.Airline == GameObject.GetInstance().HumanAirline) > 0;

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

            if ((type.CurrentFacility.TypeLevel == 1 && type.CurrentFacility.Type == AirportFacility.FacilityType.Service && this.Airport.hasAsHomebase(GameObject.GetInstance().HumanAirline)))
            {
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2203"), Translator.GetInstance().GetString("MessageBox", "2203", "message"), WPFMessageBoxButtons.Ok);
            }
            else if (type.CurrentFacility.Type == AirportFacility.FacilityType.Service && hasHub && type.CurrentFacility == Hub.MinimumServiceFacility)
            {
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2214"), string.Format(Translator.GetInstance().GetString("MessageBox", "2214", "message"), Hub.MinimumServiceFacility.Name), WPFMessageBoxButtons.Ok);
            }
            else if (type.CurrentFacility.Type == AirportFacility.FacilityType.Cargo && type.CurrentFacility.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"), type.CurrentFacility.Name), WPFMessageBoxButtons.YesNo);

                if (result == WPFMessageBoxResult.Yes)
                {
                    this.Airport.downgradeFacility(GameObject.GetInstance().HumanAirline, type.NextFacility.Type);

                    showFacilitiesInformation();
                }
            }
        }
Пример #2
0
        private void ButtonBuy_Click(object sender, RoutedEventArgs e)
        {
            HumanFacilityType type = (HumanFacilityType)((Button)sender).Tag;

            if (type.NextFacility.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"), type.NextFacility.Name, type.NextFacility.Price), WPFMessageBoxButtons.YesNo);

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

                    if (this.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.addAirportFacility(GameObject.GetInstance().HumanAirline, type.NextFacility, GameObject.GetInstance().GameTime.AddDays(type.NextFacility.BuildingDays));

                    showFacilitiesInformation();
                }
            }
        }