//orders the airliners private void orderAirliners(Airport airport, double discount = 0) { DateTime deliveryDate = getDeliveryDate(); Guid id = Guid.NewGuid(); foreach (AirlinerTypeMVVM type in this.SelectedAirliners) { Airliner airliner = new Airliner(id.ToString(), type.Type, GameObject.GetInstance().HumanAirline.Profile.Country.TailNumbers.getNextTailNumber(), deliveryDate); Model.AirlinerModel.Airliners.AddAirliner(airliner); FleetAirliner.PurchasedType pType = FleetAirliner.PurchasedType.Bought; GameObject.GetInstance().HumanAirline.addAirliner(pType, airliner, airport); airliner.clearAirlinerClasses(); AirlinerHelpers.CreateAirlinerClasses(airliner); foreach (AirlinerClass aClass in airliner.Classes) { foreach (AirlinerFacility facility in aClass.getFacilities()) { aClass.setFacility(GameObject.GetInstance().HumanAirline, facility); } } } int totalAmount = this.SelectedAirliners.Count; double price = this.SelectedAirliners.Sum(a => a.Type.Price); double totalPrice = price * ((1 - GeneralHelpers.GetAirlinerOrderDiscount(totalAmount))) * ((100 - discount) / 100); AirlineHelpers.AddAirlineInvoice(GameObject.GetInstance().HumanAirline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Purchases, -totalPrice); }
private void btnConvertToCargo_Click(object sender, RoutedEventArgs e) { double convertPrice = GeneralHelpers.GetInflationPrice(1000 * ((AirlinerPassengerType)this.Airliner.Airliner.Type).MaxSeatingCapacity); if (this.Airliner.Airliner.getPrice() > GameObject.GetInstance().HumanAirline.Money) { WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2109"), Translator.GetInstance().GetString("MessageBox", "2109", "message"), WPFMessageBoxButtons.Ok); } else { WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2123"), string.Format(Translator.GetInstance().GetString("MessageBox", "2123", "message"), this.Airliner.Name, new ValueCurrencyConverter().Convert(convertPrice)), WPFMessageBoxButtons.YesNo); if (result == WPFMessageBoxResult.Yes) { AirlinerPassengerType currentType = this.Airliner.Airliner.Type as AirlinerPassengerType; string airlinerName = string.Format("{0} Freighter", currentType.Name); double cargoSize = AirlinerHelpers.ConvertPassengersToCargoSize(currentType); AirlinerType newCargoType = new AirlinerCargoType(currentType.Manufacturer, airlinerName, currentType.AirlinerFamily, currentType.CockpitCrew, cargoSize, currentType.CruisingSpeed, currentType.Range, currentType.Wingspan, currentType.Length, currentType.FuelConsumption, currentType.Price, currentType.MinRunwaylength, currentType.FuelCapacity, currentType.Body, currentType.RangeType, currentType.Engine, currentType.Produced, currentType.ProductionRate, false); newCargoType.BaseType = currentType; AirlinerTypes.AddType(newCargoType); this.Airliner.Airliner.Type = newCargoType; AirlineHelpers.AddAirlineInvoice(GameObject.GetInstance().HumanAirline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Airline_Expenses, -convertPrice); PageNavigator.NavigateTo(new PageFleetAirliner(this.Airliner)); } } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { Airliner airliner; if (value is Airliner) { airliner = (Airliner)value; } else { airliner = Airliners.GetAirliner(value.ToString()); } return(string.Join("-", from c in airliner.Classes select AirlinerHelpers.GetAirlinerClassCode(c))); }
private void btnConvert_Click(object sender, RoutedEventArgs e) { double price = AirlinerHelpers.GetCargoConvertingPrice(this.Airliner.Airliner.Airliner.Type as AirlinerPassengerType); if (price > GameObject.GetInstance().HumanAirline.Money) { WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2015"), string.Format(Translator.GetInstance().GetString("MessageBox", "2015", "message")), WPFMessageBoxButtons.Ok); } else { WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2014"), string.Format(Translator.GetInstance().GetString("MessageBox", "2014", "message"), new ValueCurrencyConverter().Convert(price)), WPFMessageBoxButtons.YesNo); if (result == WPFMessageBoxResult.Yes) { this.Airliner.convertToCargo(); AirlineHelpers.AddAirlineInvoice(this.Airliner.Airliner.Airliner.Airline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Purchases, -price); } } }
//creates a new game private void createNewGame() { if (txtName.Text.Trim().Length > 2) { object o = null; int startYear = (int)cbStartYear.SelectedItem; int opponents = (int)cbOpponents.SelectedItem; Airline airline = (Airline)cbAirline.SelectedItem; Continent continent = (Continent)cbContinent.SelectedItem; Region region = (Region)cbRegion.SelectedItem; if (this.OpponentType == OpponentSelect.User) { if (cbSameRegion.IsChecked.Value) { o = PopUpSelectOpponents.ShowPopUp(airline, opponents, startYear, airline.Profile.Country.Region); } else { o = PopUpSelectOpponents.ShowPopUp(airline, opponents, startYear, region, continent); } } // popUpSplash.IsOpen = true; DoEvents(); GameTimeZone gtz = (GameTimeZone)cbTimeZone.SelectedItem; GameObject.GetInstance().DayRoundEnabled = cbDayTurnEnabled.IsChecked.Value; GameObject.GetInstance().TimeZone = gtz; GameObject.GetInstance().Difficulty = (DifficultyLevel)cbDifficulty.SelectedItem; GameObject.GetInstance().GameTime = new DateTime(startYear, 1, 1); GameObject.GetInstance().StartDate = GameObject.GetInstance().GameTime; //sets the fuel price GameObject.GetInstance().FuelPrice = Inflations.GetInflation(GameObject.GetInstance().GameTime.Year).FuelPrice; airline.Profile.Country = (Country)cbCountry.SelectedItem; airline.Profile.CEO = txtName.Text.Trim(); GameObject.GetInstance().setHumanAirline(airline); GameObject.GetInstance().MainAirline = GameObject.GetInstance().HumanAirline; if (cbLocalCurrency.IsChecked.Value) { GameObject.GetInstance().CurrencyCountry = airline.Profile.Country; } // AppSettings.GetInstance().resetCurrencyFormat(); Airport airport = (Airport)cbAirport.SelectedItem; AirportHelpers.RentGates(airport, airline, 2); AirportFacility checkinFacility = AirportFacilities.GetFacilities(AirportFacility.FacilityType.CheckIn).Find(f => f.TypeLevel == 1); AirportFacility facility = AirportFacilities.GetFacilities(AirportFacility.FacilityType.Service).Find((delegate(AirportFacility f) { return(f.TypeLevel == 1); })); airport.addAirportFacility(GameObject.GetInstance().HumanAirline, facility, GameObject.GetInstance().GameTime); airport.addAirportFacility(GameObject.GetInstance().HumanAirline, checkinFacility, GameObject.GetInstance().GameTime); if (continent.Uid != "100" || region.Uid != "100") { var airlines = Airlines.GetAirlines(a => a.Profile.Country.Region == region || (region.Uid == "100" && continent.hasRegion(a.Profile.Country.Region)) && a.Profile.Founded <= startYear && a.Profile.Folded > startYear); var airports = Airports.GetAirports(a => a.Profile.Country.Region == region || (region.Uid == "100" && continent.hasRegion(a.Profile.Country.Region)) && a.Profile.Period.From.Year <= startYear && a.Profile.Period.To.Year > startYear); //Airports.RemoveAirports(a => (a.Profile.Country.Region != region && !continent.hasRegion(a.Profile.Country.Region)) || (a.Profile.Town.State != null && a.Profile.Town.State.IsOverseas)); Airports.Clear(); foreach (Airport a in airports) { Airports.AddAirport(a); } Airlines.Clear(); foreach (Airline a in airlines) { Airlines.AddAirline(a); } } PassengerHelpers.CreateAirlineDestinationDemand(); AirlinerHelpers.CreateStartUpAirliners(); if (this.OpponentType == OpponentSelect.Random || o == null) { Setup.SetupMainGame(opponents, cbSameRegion.IsChecked.Value); } else { Setup.SetupMainGame((List <Airline>)o); } airline.MarketFocus = (Airline.AirlineFocus)cbFocus.SelectedItem; GeneralHelpers.CreateHolidays(GameObject.GetInstance().GameTime.Year); //PassengerHelpers.CreateDestinationPassengers(); GameObjectWorker.GetInstance().start(); // AIWorker.GetInstance().start(); PageNavigator.NavigateTo(new PageAirline(GameObject.GetInstance().HumanAirline)); PageNavigator.ClearNavigator(); //GameObject.GetInstance().HumanAirline.Money = 10000000000000; GameObject.GetInstance().NewsBox.addNews(new News(News.NewsType.Standard_News, GameObject.GetInstance().GameTime, Translator.GetInstance().GetString("News", "1001"), string.Format(Translator.GetInstance().GetString("News", "1001", "message"), GameObject.GetInstance().HumanAirline.Profile.CEO, GameObject.GetInstance().HumanAirline.Profile.IATACode))); popUpSplash.IsOpen = false; Action action = () => { Stopwatch swPax = new Stopwatch(); swPax.Start(); PassengerHelpers.CreateDestinationDemand(); Console.WriteLine("Demand have been created in {0} ms.", swPax.ElapsedMilliseconds); swPax.Stop(); }; Task.Factory.StartNew(action); //Task.Run(action); //Task t2 = Task.Factory.StartNew(action, "passengers"); } else { WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2403"), Translator.GetInstance().GetString("MessageBox", "2403"), WPFMessageBoxButtons.Ok); } }