private void btnPurchaseAsSubsidiary_Click(object sender, RoutedEventArgs e)
        {
            double buyingPrice = this.Airline.getValue() * 1000000 * 1.10;

            WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2113"), string.Format(Translator.GetInstance().GetString("MessageBox", "2113", "message"), this.Airline.Profile.Name, buyingPrice), WPFMessageBoxButtons.YesNo);

            if (result == WPFMessageBoxResult.Yes)
            {
                List<AirlineLogo> oldLogos = this.Airline.Profile.Logos;
                string oldColor = this.Airline.Profile.Color;

                //creates independent airlines for each subsidiary
                while (this.Airline.Subsidiaries.Count > 0)
                {
                    SubsidiaryAirline subAirline = this.Airline.Subsidiaries[0];

                    subAirline.Airline = null;

                    this.Airline.removeSubsidiaryAirline(subAirline);
                }

                if (this.Airline.License > GameObject.GetInstance().HumanAirline.License)
                    GameObject.GetInstance().HumanAirline.License = this.Airline.License;

                SubsidiaryAirline sAirline = new SubsidiaryAirline(GameObject.GetInstance().HumanAirline, this.Airline.Profile, this.Airline.Mentality, this.Airline.MarketFocus, this.Airline.License,this.Airline.AirlineRouteFocus);

                AirlineHelpers.SwitchAirline(this.Airline, sAirline);

                GameObject.GetInstance().HumanAirline.addSubsidiaryAirline(sAirline);

                AirlineHelpers.AddAirlineInvoice(GameObject.GetInstance().HumanAirline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Airline_Expenses, -buyingPrice);

                Airlines.RemoveAirline(this.Airline);
                Airlines.AddAirline(sAirline);

                sAirline.Profile.Logos = oldLogos;
                sAirline.Profile.Color = oldColor;

                foreach (AirlinePolicy policy in this.Airline.Policies)
                    sAirline.addAirlinePolicy(policy);

                sAirline.Money = this.Airline.Money;
                sAirline.StartMoney = this.Airline.Money;

                sAirline.Fees = new AirlineFees();

                PageNavigator.NavigateTo(new PageAirline(GameObject.GetInstance().HumanAirline));

            }
        }
Exemplo n.º 2
0
        //adds a subsidiary airline to an airline
        public static void AddSubsidiaryAirline(Airline airline, SubsidiaryAirline sAirline, double money, Airport airportHomeBase)
        {
            AddAirlineInvoice(airline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Airline_Expenses, -money);
            sAirline.Money = money;
            sAirline.StartMoney = money;

            sAirline.Fees = new AirlineFees();

            airline.addSubsidiaryAirline(sAirline);

            if (!AirportHelpers.HasFreeGates(airportHomeBase, sAirline) && airportHomeBase.Terminals.getFreeGates() > 1)
            {
                AirportHelpers.RentGates(airportHomeBase, sAirline, AirportContract.ContractType.Full, 2);
                //sets all the facilities at an airport to none for all airlines
                foreach (Airport airport in Airports.GetAllAirports())
                {

                    foreach (AirportFacility.FacilityType type in Enum.GetValues(typeof(AirportFacility.FacilityType)))
                    {
                        AirportFacility noneFacility = AirportFacilities.GetFacilities(type).Find((delegate(AirportFacility facility) { return facility.TypeLevel == 0; }));

                        airport.addAirportFacility(sAirline, noneFacility, GameObject.GetInstance().GameTime);
                    }

                }

                foreach (AirlinePolicy policy in airline.Policies)
                    sAirline.addAirlinePolicy(policy);

                AirportFacility serviceFacility = AirportFacilities.GetFacilities(AirportFacility.FacilityType.Service).Find(f => f.TypeLevel == 1);
                AirportFacility checkinFacility = AirportFacilities.GetFacilities(AirportFacility.FacilityType.CheckIn).Find(f => f.TypeLevel == 1);

                airportHomeBase.addAirportFacility(sAirline, serviceFacility, GameObject.GetInstance().GameTime);
                airportHomeBase.addAirportFacility(sAirline, checkinFacility, GameObject.GetInstance().GameTime);

            }

            Airlines.AddAirline(sAirline);

        }