//changes the demand for all airports belonging to an airline with a factor public static void ChangePaxDemand(Airline airline, double factor) { foreach (Airport a in airline.Airports) { ChangePaxDemand(a, factor); } }
public PageFinances(Airline airline) { //binds and initializes page InitializeComponent(); this.Language = XmlLanguage.GetLanguage(new CultureInfo(AppSettings.GetInstance().getLanguage().CultureInfo, true).IetfLanguageTag); SetLocalDefaults(airline); // binds top level budgets and buttons Button btnApply = (Button)this.FindName("buttonApply"); Button btnReset = (Button)this.FindName("buttonReset"); Button btn1Year = (Button)this.FindName("_1year"); Button btn5Year = (Button)this.FindName("_5year"); Button btn10Year = (Button)this.FindName("_10year"); Viewbox panelContent = (Viewbox)this.FindName("panelViewbox"); setMaximums(airline); BudgetHelpers.SetDefaults(airline); SetLocalDefaults(airline); SetOverviewPanel(airline, 1); //event handlers btnApply.Click += new RoutedEventHandler(btnApply_Click); btnReset.Click += new RoutedEventHandler(btnReset_Click); btn1Year.Click += new RoutedEventHandler(btn1Year_Click); btn5Year.Click += new RoutedEventHandler(btn5Year_Click); btn10Year.Click += new RoutedEventHandler(btn10Year_Click); this.RemoveLogicalChild(panelContent); base.setContent(panelContent); showPage(this); }
public AirlineAirportFacility(Airline airline, Airport airport, AirportFacility facility, DateTime date) { this.Airline = airline; this.Facility = facility; this.FinishedDate = date; this.Airport = airport; }
public static object ShowPopUp(Airline airline) { PopUpWindow window = new PopUpCodeshareAgreement(airline); window.ShowDialog(); return window.Selected; }
public static object ShowPopUp(Airline airline,Airport airport) { PopUpWindow window = new PopUpAddCooperation(airline,airport); window.ShowDialog(); return window.Selected; }
public AirlineStartData(Airline airline) { this.Airline = airline; this.Routes = new List<StartDataRoute>(); this.Airliners = new List<StartDataAirliners>(); this.OriginRoutes = new List<StartDataRoutes>(); }
public PageAirlinePilots(Airline airline) { this.Airline = airline; InitializeComponent(); StackPanel panelPilots = new StackPanel(); panelPilots.Margin = new Thickness(0, 10, 50, 0); TextBlock txtHeader = new TextBlock(); txtHeader.Uid = "1001"; txtHeader.Margin = new Thickness(0, 0, 0, 0); txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2"); txtHeader.FontWeight = FontWeights.Bold; txtHeader.Text = Translator.GetInstance().GetString("PageAirlinePilots", txtHeader.Uid); panelPilots.Children.Add(txtHeader); ContentControl ccHeader = new ContentControl(); ccHeader.ContentTemplate = this.Resources["PilotsHeader"] as DataTemplate; ccHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; panelPilots.Children.Add(ccHeader); lbPilots = new ListBox(); lbPilots.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbPilots.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem"); lbPilots.ItemTemplate = this.Resources["PilotItem"] as DataTemplate; lbPilots.MaxHeight = GraphicsHelpers.GetContentHeight() / 2; panelPilots.Children.Add(lbPilots); this.Content = panelPilots; showPilots(); }
//adds the value for a statistics type to an airline for a year public void addStatisticsValue(int year, Airline airline, StatisticsType type, int value) { AirportStatisticsValue item = this.Stats.Find(s => s.Year == year && s.Airline == airline && s.Stat.Shortname == type.Shortname); if (item == null) this.Stats.Add(new AirportStatisticsValue(airline, year, type, value)); else item.Value += value; }
//returns the value for a statistics type for an airline for a year public double getStatisticsValue(int year, Airline airline, StatisticsType type) { if (this.Stats.ContainsKey(year)) { AirportStatisticsValue value = this.Stats[year].Find(asv => asv.Airline == airline && asv.Stat == type); if (value != null) return value.Value; } return 0; }
public Terminal(Airport airport, Airline airline,string name, int gates, DateTime deliveryDate) { this.Airport = airport; this.Airline = airline; this.Name = name; this.DeliveryDate = new DateTime(deliveryDate.Year, deliveryDate.Month, deliveryDate.Day); this.Gates = new Gates(gates, this.DeliveryDate); }
public PopUpCodeshareAgreement(Airline airline) { this.Airline = airline; this.DataContext = this.Airline; this.Price = AirlineHelpers.GetCodesharingPrice(this.Airline,GameObject.GetInstance().HumanAirline); this.TicketSalePercent = CodeshareAgreement.TicketSalePercent; InitializeComponent(); }
//generates x number of events for each event type for the current year. Should be called only from OnNewYear public static void GenerateEvents(Airline airline) { Random rnd = new Random(); Dictionary<RandomEvent.EventType, double> eventOccurences = new Dictionary<TheAirline.Model.GeneralModel.RandomEvent.EventType, double>(); int eFreq = 0; double secEvents; double safEvents; double polEvents; double maintEvents; double custEvents; double empEvents; //sets an overall event frequency based on an airlines total overall rating int totalRating = airline.Ratings.CustomerHappinessRating + airline.Ratings.EmployeeHappinessRating + airline.Ratings.SafetyRating + airline.Ratings.SecurityRating; if (totalRating < 300) { eFreq = (int)rnd.Next(1, 6); } else if (totalRating < 200) { eFreq = (int)rnd.Next(4, 10); } else if (totalRating < 100) { eFreq = (int)rnd.Next(8, 16); } else eFreq = (int)rnd.Next(0, 4); //gets the event proportions and multiplies them by total # events to get events per type List<double> probs = GetEventProportions(airline); custEvents = (int)eFreq * probs[0]; empEvents = (int)eFreq * probs[1]; secEvents = (int)eFreq * probs[2]; safEvents = (int)eFreq * probs[3]; maintEvents = (int)eFreq * probs[4]; polEvents = eFreq - custEvents - empEvents - secEvents - maintEvents; eventOccurences.Add(RandomEvent.EventType.Customer, custEvents); eventOccurences.Add(RandomEvent.EventType.Employee, empEvents); eventOccurences.Add(RandomEvent.EventType.Maintenance, maintEvents); eventOccurences.Add(RandomEvent.EventType.Safety, safEvents); eventOccurences.Add(RandomEvent.EventType.Security, secEvents); eventOccurences.Add(RandomEvent.EventType.Political, polEvents); /* //generates the given number of events for each type foreach (KeyValuePair<RandomEvent.EventType, double> v in eventOccurences) { int k = (int)v.Value; List<RandomEvent> list = RandomEvents.GetEvents(v.Key, k, airline); foreach (RandomEvent e in list) { airline.EventLog.Add(e); } } */ }
//adds happiness to an airline public static void AddPassengerHappiness(Airline airline) { lock (HappinessPercent) { if (HappinessPercent.ContainsKey(airline)) HappinessPercent[airline] += 1; else HappinessPercent.Add(airline, 1); } }
//sets the value for a statistics type for an airline for a year public void setStatisticsValue(int year, Airline airline, StatisticsType type, int value) { if (!(this.Stats.ContainsKey(year))) this.Stats.Add(year, new List<AirportStatisticsValue>()); AirportStatisticsValue statValue = this.Stats[year].Find(asv => asv.Airline == airline && asv.Stat == type); if (statValue != null) statValue.Value = value; else this.Stats[year].Add(new AirportStatisticsValue(airline, type, value)); }
public static long GetAvgSubValue(Airline airline) { if (airline.Subsidiaries.Count() == 0) { return 0; } else { return GetTotalSubValues(GameObject.GetInstance().HumanAirline) / GameObject.GetInstance().HumanAirline.Subsidiaries.Count(); } }
public PageAirlineInsurances(Airline airline) { this.Airline = airline; InitializeComponent(); this.DataContext = this.Airline; clearValues(); }
//adds an invoice to an airline public static void AddAirlineInvoice(Airline airline, DateTime date, Invoice.InvoiceType type, double amount) { if (airline.IsHuman && GameObject.GetInstance().HumanAirline == airline) { GameObject.GetInstance().addHumanMoney(amount); GameObject.GetInstance().HumanAirline.addInvoice(new Invoice(date, type, amount), false); } else airline.addInvoice(new Invoice(date, type, amount)); }
public static FleetAirliner BuyAirliner(Airline airline, Airliner airliner, Airport airport, double discount) { FleetAirliner fAirliner = AddAirliner(airline, airliner, airport,false); double price = airliner.getPrice() * ((100 - discount) / 100); AddAirlineInvoice(airline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Purchases, -price); return fAirliner; }
public static FleetAirliner AddAirliner(Airline airline, Airliner airliner, Airport airport) { if (Countries.GetCountryFromTailNumber(airliner.TailNumber).Name != airline.Profile.Country.Name) airliner.TailNumber = airline.Profile.Country.TailNumbers.getNextTailNumber(); FleetAirliner fAirliner = new FleetAirliner(FleetAirliner.PurchasedType.Bought, GameObject.GetInstance().GameTime, airline, airliner, airport); airline.addAirliner(fAirliner); return fAirliner; }
public AirportContract(Airline airline, Airport airport, DateTime date, int numberOfGates, int length, double yearlyPayment,Boolean payFull = false, Boolean isExclusiveDeal = false, Terminal terminal = null) { this.PayFull = payFull; this.Airline = airline; this.Airport = airport; this.ContractDate = date; this.Length = length; this.YearlyPayment = yearlyPayment; this.NumberOfGates = numberOfGates; this.IsExclusiveDeal = isExclusiveDeal; this.Terminal = terminal; this.ExpireDate = this.ContractDate.AddYears(this.Length); }
public PageAirlineSubsidiaries(Airline airline, StandardPage parent) { this.PageParent = parent; this.Airline = airline; InitializeComponent(); StackPanel panelSubsidiaries = new StackPanel(); panelSubsidiaries.Margin = new Thickness(0, 10, 50, 0); TextBlock txtSubsidiariesHeader = new TextBlock(); txtSubsidiariesHeader.Uid = "1001"; txtSubsidiariesHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtSubsidiariesHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2"); txtSubsidiariesHeader.FontWeight = FontWeights.Bold; txtSubsidiariesHeader.Text = Translator.GetInstance().GetString("PageAirlineSubsidiaries", txtSubsidiariesHeader.Uid); panelSubsidiaries.Children.Add(txtSubsidiariesHeader); lbSubsidiaryAirline = new ListBox(); lbSubsidiaryAirline.ItemTemplate = this.Resources["SubsidiaryItem"] as DataTemplate; lbSubsidiaryAirline.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbSubsidiaryAirline.MaxHeight = GraphicsHelpers.GetContentHeight() - 100; showSubsidiaries(); panelSubsidiaries.Children.Add(lbSubsidiaryAirline); WrapPanel panelButtons = new WrapPanel(); panelButtons.Visibility = this.Airline.IsHuman && !(this.Airline is SubsidiaryAirline) && this.Airline.Money>100000 ? Visibility.Visible : Visibility.Collapsed; panelButtons.Margin = new Thickness(0,5,0,0); panelSubsidiaries.Children.Add(panelButtons); Button btnCreate = new Button(); btnCreate.Uid = "200"; btnCreate.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnCreate.Height = Double.NaN; btnCreate.Width = Double.NaN; btnCreate.Content = Translator.GetInstance().GetString("PageAirlineSubsidiaries",btnCreate.Uid); btnCreate.Click+=new RoutedEventHandler(btnCreate_Click); btnCreate.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); panelButtons.Children.Add(btnCreate); if (this.Airline.IsHuman) panelSubsidiaries.Children.Add(createTransferFundsPanel()); this.Content = panelSubsidiaries; }
public PageAirlineFleet(Airline airline) { InitializeComponent(); this.Airline = airline; foreach (FleetAirliner fa in this.Airline.DeliveredFleet) _FleetDelivered.Add(fa); StackPanel panelFleet = new StackPanel(); WrapPanel panelMenuButtons = new WrapPanel(); panelFleet.Children.Add(panelMenuButtons); ucSelectButton sbOverview = new ucSelectButton(); sbOverview.Uid = "1001"; sbOverview.Content = Translator.GetInstance().GetString("PageAirlineFleet", sbOverview.Uid); sbOverview.Click += new RoutedEventHandler(sbOverview_Click); sbOverview.IsSelected = true; panelMenuButtons.Children.Add(sbOverview); ucSelectButton sbDetailed = new ucSelectButton(); sbDetailed.Uid = "1002"; sbDetailed.Content = Translator.GetInstance().GetString("PageAirlineFleet", sbDetailed.Uid); sbDetailed.Click += new RoutedEventHandler(sbDetailed_Click); panelMenuButtons.Children.Add(sbDetailed); ucSelectButton sbOrdered = new ucSelectButton(); sbOrdered.Uid = "1009"; sbOrdered.Content = Translator.GetInstance().GetString("PageAirlineFleet", sbOrdered.Uid); sbOrdered.Click += new RoutedEventHandler(sbOrdered_Click); panelMenuButtons.Children.Add(sbOrdered); panelOverview = createOverviewPanel(); panelDetailed = createDetailedPanel(); panelDetailed.Visibility = System.Windows.Visibility.Collapsed; panelDetailed.ToolTip = UICreator.CreateToolTip("View detailed information for this aircraft"); panelOrdered = createOrderedPanel(); panelOrdered.Visibility = System.Windows.Visibility.Collapsed; panelOrdered.ToolTip = UICreator.CreateToolTip("View ordered airliners"); panelFleet.Children.Add(panelOverview); panelFleet.Children.Add(panelDetailed); panelFleet.Children.Add(panelOrdered); this.Content = panelFleet; }
public PopUpAddCooperation(Airline airline, Airport airport) { this.Types = new List<CooperationType>(); this.Airline = airline; this.Airport = airport; foreach (CooperationType type in CooperationTypes.GetCooperationTypes()) { if (!this.Airport.Cooperations.Exists(c => c.Airline == airline && c.Type == type) && type.AirportSizeRequired<=this.Airport.Profile.Size) this.Types.Add(type); } InitializeComponent(); }
//creates an airliner for an airline public static FleetAirliner CreateAirliner(Airline airline, AirlinerType type) { Guid id = Guid.NewGuid(); Airliner airliner = new Airliner(id.ToString(), type, airline.Profile.Country.TailNumbers.getNextTailNumber(), GameObject.GetInstance().GameTime); Airliners.AddAirliner(airliner); FleetAirliner fAirliner = new FleetAirliner(FleetAirliner.PurchasedType.Bought, GameObject.GetInstance().GameTime, airline, airliner, airline.Airports[0]); airliner.clearAirlinerClasses(); AirlinerHelpers.CreateAirlinerClasses(airliner); return fAirliner; }
public Scenario(string name,string description, Airline airline, Airport homebase, int startyear, int endyear, long startcash,DifficultyLevel difficulty) { this.Name = name; this.Airline = airline; this.Homebase = homebase; this.StartYear = startyear; this.StartCash = startcash; this.Description = description; this.Difficulty = difficulty; this.EndYear = endyear; this.OpponentAirlines = new List<ScenarioAirline>(); this.Destinations = new List<Airport>(); this.Fleet = new Dictionary<AirlinerType, int>(); this.Routes = new List<ScenarioAirlineRoute>(); this.Failures = new List<ScenarioFailure>(); this.PassengerDemands = new List<ScenarioPassengerDemand>(); }
public AirlinesMVVM(Airline airline) { this.Airline = airline; this.Profit = this.Airline.getProfit(); this.AvgFleetAge = this.Airline.getAverageFleetAge(); StatisticsType passengersType = StatisticsTypes.GetStatisticsType("Passengers"); StatisticsType passengersAvgType = StatisticsTypes.GetStatisticsType("Passengers%"); StatisticsType arrivalsType = StatisticsTypes.GetStatisticsType("Arrivals"); StatisticsType cargoType = StatisticsTypes.GetStatisticsType("Cargo"); StatisticsType cargoAvgType = StatisticsTypes.GetStatisticsType("Cargo%"); this.Passengers = this.Airline.Statistics.getStatisticsValue(GameObject.GetInstance().GameTime.Year, passengersType); this.PassengersPerFlight = this.Airline.Statistics.getStatisticsValue(GameObject.GetInstance().GameTime.Year, passengersAvgType); this.Flights = this.Airline.Statistics.getStatisticsValue(GameObject.GetInstance().GameTime.Year, arrivalsType); this.Cargo = this.Airline.Statistics.getStatisticsValue(GameObject.GetInstance().GameTime.Year, cargoType); this.CargoPerFlight = this.Airline.Statistics.getStatisticsValue(GameObject.GetInstance().GameTime.Year, cargoAvgType); }
//orders a number of airliners for an airline public static void OrderAirliners(Airline airline, List<AirlinerOrder> orders, Airport airport, DateTime deliveryDate, double discount) { Guid id = Guid.NewGuid(); foreach (AirlinerOrder order in orders) { for (int i = 0; i < order.Amount; i++) { Airliner airliner = new Airliner(id.ToString(), order.Type, airline.Profile.Country.TailNumbers.getNextTailNumber(), deliveryDate); Airliners.AddAirliner(airliner); FleetAirliner.PurchasedType pType = FleetAirliner.PurchasedType.Bought; airline.addAirliner(pType, airliner, airport); airliner.clearAirlinerClasses(); foreach (AirlinerClass aClass in order.Classes) { AirlinerClass tClass = new AirlinerClass(aClass.Type, aClass.SeatingCapacity); tClass.RegularSeatingCapacity = aClass.RegularSeatingCapacity; foreach (AirlinerFacility facility in aClass.getFacilities()) tClass.setFacility(airline, facility); airliner.addAirlinerClass(tClass); } } } int totalAmount = orders.Sum(o => o.Amount); double price = orders.Sum(o => o.Type.Price * o.Amount); double totalPrice = price * ((1 - GeneralHelpers.GetAirlinerOrderDiscount(totalAmount))) * ((100 - discount) / 100); AirlineHelpers.AddAirlineInvoice(airline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Purchases, -totalPrice); }
//simulates all flight for an airline for the current day public static void SimulateAirlineFlights(Airline airline) { Stopwatch sw = new Stopwatch(); sw.Start(); //foreach (FleetAirliner airliner in airline.Fleet.FindAll(f => f.Status != FleetAirliner.AirlinerStatus.Stopped)) Parallel.ForEach(airline.Fleet.FindAll(f => f.Status != FleetAirliner.AirlinerStatus.Stopped), airliner => { if (airliner.CurrentFlight != null) { //Boolean stopoverRoute = airliner.CurrentFlight.Entry.MainEntry != null; SimulateLanding(airliner); } var dayEntries = airliner.Routes.SelectMany(r => r.TimeTable.getEntries(GameObject.GetInstance().GameTime.DayOfWeek)).Where(e => e.Airliner == airliner).OrderBy(e => e.Time); if (GameObject.GetInstance().GameTime > airliner.GroundedToDate) { foreach (RouteTimeTableEntry entry in dayEntries) { if (entry.TimeTable.Route.HasStopovers) SimulateStopoverFlight(entry); else SimulateFlight(entry); } CheckForService(airliner); } }); sw.Stop(); }
public FleetAirliner(PurchasedType purchased, DateTime purchasedDate, Airline airline, Airliner airliner, Airport homebase) { this.Airliner = airliner; this.Purchased = purchased; this.PurchasedDate = purchasedDate; this.Airliner.Airline = airline; this.Homebase = homebase; this.Name = airliner.TailNumber; this.Statistics = new AirlinerStatistics(this); this.LastCMaintenance = this.Airliner.BuiltDate; this.LastAMaintenance = this.Airliner.BuiltDate; this.LastBMaintenance = this.Airliner.BuiltDate; this.LastDMaintenance = this.Airliner.BuiltDate; this.Status = AirlinerStatus.Stopped; this.MaintRoutes = new List<RouteModel.Route>(); this.CurrentPosition = this.Homebase;//new GeoCoordinate(this.Homebase.Profile.Coordinates.Latitude,this.Homebase.Profile.Coordinates.Longitude); this.Routes = new List<Route>(); this.Pilots = new List<Pilot>(); this.InsurancePolicies = new List<AirlinerInsurance>(); this.MaintenanceHistory = new Dictionary<Invoice, string>(); }
public PageAirline(Airline airline) { InitializeComponent(); this.Uid = "1000"; this.Title = Translator.GetInstance().GetString("PageAirline", this.Uid); this.Airline = airline; StackPanel airportPanel = new StackPanel(); airportPanel.Margin = new Thickness(10, 0, 10, 0); airportPanel.Children.Add(createQuickInfoPanel()); if (this.Airline.Contract != null) airportPanel.Children.Add(createManufacturerContractPanel()); if (this.Airline.IsHuman) airportPanel.Children.Add(createHumanControllingPanel()); if (GameObject.GetInstance().HumanAirline == GameObject.GetInstance().MainAirline && !this.Airline.IsHuman && !this.Airline.IsSubsidiary) airportPanel.Children.Add(createPurchaseAirlinePanel()); StandardContentPanel panelContent = new StandardContentPanel(); panelContent.setContentPage(airportPanel, StandardContentPanel.ContentLocation.Left); StackPanel panelSideMenu = new PanelAirline(this.Airline, this); panelContent.setContentPage(panelSideMenu, StandardContentPanel.ContentLocation.Right); base.setContent(panelContent); base.setHeaderContent(string.Format("{0} - {1}", this.Title, this.Airline.Profile.Name)); showPage(this); }
//removes an airline from the list public static void RemoveAirline(Airline airline) { airlines.Remove(airline); }
public CodeshareAgreement(Airline airline1, Airline airline2, CodeshareType type) { this.Airline1 = airline1; this.Airline2 = airline2; this.Type = type; }
//adds an airline to the collection public static void AddAirline(Airline airline) { airlines.Add(airline); }
public AllianceMember(Airline airline, DateTime joinedDate) { this.Airline = airline; this.JoinedDate = joinedDate; this.ExitedDate = new DateTime(2199, 1, 1); }
public AirlineShare(Airline airline, double price) { this.Price = price; this.Airline = airline; }
//returns if the list of airlines contains an airline public static Boolean ContainsAirline(Airline airline) { return(airlines.Contains(airline)); }
//returns the start data for an airline public static AirlineStartData GetAirlineStartData(Airline airline) { return(startData.Find(s => s.Airline == airline)); }