//sets the values private void setValues() { this.Finances.Clear(); foreach (Invoice.InvoiceType type in Enum.GetValues(typeof(Invoice.InvoiceType))) { this.Finances.Add(new AirlineFinanceMVVM(this.Airline, type)); } this.Money = this.Airline.Money; this.Balance = this.Airline.Money - this.Airline.StartMoney; double tMoney = GameObject.GetInstance().HumanMoney; this.CockpitCrew = this.Airline.Pilots.Count; this.CabinCrew = this.Airline.Routes.Where(r => r.Type == Route.RouteType.Passenger).Sum(r => ((PassengerRoute)r).getTotalCabinCrew()); this.SupportCrew = this.Airline.Airports.SelectMany(a => a.getCurrentAirportFacilities(this.Airline)).Where(a => a.EmployeeType == AirportFacility.EmployeeTypes.Support).Sum(a => a.NumberOfEmployees); this.MaintenanceCrew = this.Airline.Airports.SelectMany(a => a.getCurrentAirportFacilities(this.Airline)).Where(a => a.EmployeeType == AirportFacility.EmployeeTypes.Maintenance).Sum(a => a.NumberOfEmployees); foreach (AirlineFacility facility in AirlineFacilities.GetFacilities(f => f.FromYear <= GameObject.GetInstance().GameTime.Year).OrderBy(f => f.Name)) { this.Facilities.Add(new AirlineFacilityMVVM(this.Airline, facility, this.Airline.Facilities.Exists(f => f.Uid == facility.Uid) ? AirlineFacilityMVVM.MVVMType.Purchased : AirlineFacilityMVVM.MVVMType.Available)); } foreach (AdvertisementType.AirlineAdvertisementType type in Enum.GetValues(typeof(AdvertisementType.AirlineAdvertisementType))) { if (GameObject.GetInstance().GameTime.Year >= (int)type) { AirlineAdvertisementMVVM advertisement = new AirlineAdvertisementMVVM(type); advertisement.Types = AdvertisementTypes.GetTypes(type); this.Advertisements.Add(advertisement); } } this.MaxSubsidiaryMoney = this.Airline.Money / 2; this.License = this.Airline.License; if (this.Airline.IsSubsidiary) { this.AirlineAirlines.Add(((SubsidiaryAirline)this.Airline).Airline); foreach (SubsidiaryAirline airline in ((SubsidiaryAirline)this.Airline).Airline.Subsidiaries) { this.AirlineAirlines.Add(airline); } } else { foreach (SubsidiaryAirline airline in this.Subsidiaries) { this.AirlineAirlines.Add(airline); } this.AirlineAirlines.Add(this.Airline); } this.MaxLoan = AirlineHelpers.GetMaxLoanAmount(this.Airline); }
private void btnUpgradeLicens_Click(object sender, RoutedEventArgs e) { double upgradeLicensPrice = GeneralHelpers.GetInflationPrice(1000000); Airline.AirlineLicense nextLicenseType = this.Airline.License + 1; WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2119"), string.Format(Translator.GetInstance().GetString("MessageBox", "2119", "message"), new TextUnderscoreConverter().Convert(nextLicenseType), new ValueCurrencyConverter().Convert(upgradeLicensPrice)), WPFMessageBoxButtons.YesNo); if (result == WPFMessageBoxResult.Yes) { this.Airline.License = nextLicenseType; this.Airline.Airline.License = nextLicenseType; AirlineHelpers.AddAirlineInvoice(this.Airline.Airline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Airline_Expenses, -upgradeLicensPrice); } }
//sets the values private void setValues() { this.Finances.Clear(); foreach (Invoice.InvoiceType type in Enum.GetValues(typeof(Invoice.InvoiceType))) this.Finances.Add(new AirlineFinanceMVVM(this.Airline, type)); this.Money = this.Airline.Money; this.Balance = this.Airline.Money - this.Airline.StartMoney; double tMoney = GameObject.GetInstance().HumanMoney; this.CabinCrew = this.Airline.Routes.Where(r => r.Type == Route.RouteType.Passenger).Sum(r => ((PassengerRoute)r).getTotalCabinCrew()); this.SupportCrew = this.Airline.Airports.SelectMany(a => a.getCurrentAirportFacilities(this.Airline)).Where(a => a.EmployeeType == AirportFacility.EmployeeTypes.Support).Sum(a => a.NumberOfEmployees); this.MaintenanceCrew = this.Airline.Airports.SelectMany(a => a.getCurrentAirportFacilities(this.Airline)).Where(a => a.EmployeeType == AirportFacility.EmployeeTypes.Maintenance).Sum(a => a.NumberOfEmployees); this.MaintenanceCrew += this.Airline.Airports.Where(a=>a.getCurrentAirportFacility(this.Airline,AirportFacility.FacilityType.Service).TypeLevel > 0).Sum(a=>this.Airline.Fleet.Count(f=>f.Homebase == a)); this.NeededPilots = this.DeliveredFleet.Sum(f => f.Airliner.Type.CockpitCrew - f.Pilots.Count); foreach (AirlineFacility facility in AirlineFacilities.GetFacilities(f => f.FromYear <= GameObject.GetInstance().GameTime.Year).OrderBy(f => f.Name)) { if (this.Airline.Facilities.Exists(f => f.Uid == facility.Uid) || this.Airline.IsHuman) { if (facility is PilotTrainingFacility && !this.Airline.Facilities.Exists(f=>f.Uid == facility.Uid)) this.TrainingFacilities.Add(new AirlineFacilityMVVM(this.Airline,facility, this.Airline.Facilities.Exists(f => f.Uid == facility.Uid) ? AirlineFacilityMVVM.MVVMType.Purchased : AirlineFacilityMVVM.MVVMType.Available)); else this.Facilities.Add(new AirlineFacilityMVVM(this.Airline, facility, this.Airline.Facilities.Exists(f => f.Uid == facility.Uid) ? AirlineFacilityMVVM.MVVMType.Purchased : AirlineFacilityMVVM.MVVMType.Available)); } } foreach (AdvertisementType.AirlineAdvertisementType type in Enum.GetValues(typeof(AdvertisementType.AirlineAdvertisementType))) { if (GameObject.GetInstance().GameTime.Year >= (int)type) { AirlineAdvertisementMVVM advertisement = new AirlineAdvertisementMVVM(type); advertisement.Types = AdvertisementTypes.GetTypes(type); this.Advertisements.Add(advertisement); } } this.MaxSubsidiaryMoney = this.Airline.Money / 2; this.MaxTransferFunds = this.Airline.Money / 2; this.License = this.Airline.License; if (this.Airline.IsSubsidiary) { this.AirlineAirlines.Add(((SubsidiaryAirline)this.Airline).Airline); foreach (SubsidiaryAirline airline in ((SubsidiaryAirline)this.Airline).Airline.Subsidiaries) this.AirlineAirlines.Add(airline); } else { foreach (SubsidiaryAirline airline in this.Subsidiaries) this.AirlineAirlines.Add(airline); this.AirlineAirlines.Add(this.Airline); } foreach (Airline airline in this.AirlineAirlines) if (airline != GameObject.GetInstance().HumanAirline) this.FundsAirlines.Add(airline); this.MaxLoan = AirlineHelpers.GetMaxLoanAmount(this.Airline); }