public GetFacility ( |
||
type | ||
return |
public AirlinerClassMVVM( AirlinerClass type, int seating, int regularSeating, int maxseats, Boolean changeableSeats = false) { Type = type.Type; Seating = seating; RegularSeatingCapacity = regularSeating; ChangeableSeats = changeableSeats; MaxSeats = maxseats; MaxSeatsCapacity = maxseats; ChangedFacility = false; Facilities = new ObservableCollection<AirlinerFacilityMVVM>(); foreach (AirlinerFacility.FacilityType facType in Enum.GetValues(typeof(AirlinerFacility.FacilityType))) { var facility = new AirlinerFacilityMVVM(facType, this); foreach (AirlinerFacility fac in AirlinerFacilities.GetFacilities(facType)) { facility.Facilities.Add(fac); } AirlinerFacility selectedFacility = type.GetFacility(facType) == null ? AirlinerFacilities.GetBasicFacility(facType) : type.GetFacility(facType); facility.SelectedFacility = selectedFacility; Facilities.Add(facility); } }
public PopUpAirlinerClassConfiguration(AirlinerClass aClass) { InitializeComponent(); this.AirlinerClass = aClass; this.Title = new TextUnderscoreConverter().Convert(aClass.Type.ToString()).ToString(); this.Width = 400; this.Height = 200; this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; StackPanel panelClassFacilities = new StackPanel(); TextBlock txtHeader = new TextBlock(); txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush"); txtHeader.FontWeight = FontWeights.Bold; txtHeader.Text = string.Format("{0}", new TextUnderscoreConverter().Convert(aClass.Type, null, null, null)); panelClassFacilities.Children.Add(txtHeader); lbFacilities = new ListBox[Enum.GetValues(typeof(AirlinerFacility.FacilityType)).Length]; int i = 0; foreach (AirlinerFacility.FacilityType type in Enum.GetValues(typeof(AirlinerFacility.FacilityType))) { AirlinerFacility facility = aClass.GetFacility(type); lbFacilities[i] = new ListBox(); lbFacilities[i].ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbFacilities[i].ItemTemplate = this.Resources["FleetFacilityItem"] as DataTemplate; panelClassFacilities.Children.Add(lbFacilities[i]); i++; } panelClassFacilities.Children.Add(createButtonsPanel()); this.Content = panelClassFacilities; showFacilities(); }
public static List<AirlinerClass> GetAirlinerClasses(AirlinerType type) { var classes = new List<AirlinerClass>(); var passengerType = type as AirlinerPassengerType; if (passengerType != null) { Configuration airlinerTypeConfiguration = Configurations.GetConfigurations(Configuration.ConfigurationType.AirlinerType) .Find( c => ((AirlinerTypeConfiguration) c).Airliner == type && ((AirlinerTypeConfiguration) c).Period.From <= GameObject.GetInstance().GameTime && ((AirlinerTypeConfiguration) c).Period.To > GameObject.GetInstance().GameTime); if (airlinerTypeConfiguration == null) { int seatingDiff = 0; AirlinerConfiguration configuration = null; int numOfClasses = Rnd.Next(0, passengerType.MaxAirlinerClasses) + 1; if (GameObject.GetInstance().GameTime.Year >= (int) AirlinerClass.ClassType.BusinessClass) { if (numOfClasses == 1) { configuration = (AirlinerConfiguration) Configurations.GetStandardConfiguration("200"); } if (numOfClasses == 2) { configuration = (AirlinerConfiguration) Configurations.GetStandardConfiguration("202"); } if (numOfClasses == 3) { configuration = (AirlinerConfiguration) Configurations.GetStandardConfiguration("203"); } } else { if (numOfClasses == 1) { configuration = (AirlinerConfiguration) Configurations.GetStandardConfiguration("200"); } if (numOfClasses == 2) { configuration = (AirlinerConfiguration) Configurations.GetStandardConfiguration("201"); } if (numOfClasses == 3) { configuration = (AirlinerConfiguration) Configurations.GetStandardConfiguration("201"); } } if (configuration != null) { foreach (AirlinerClassConfiguration aClass in configuration.Classes) { var airlinerClass = new AirlinerClass(aClass.Type, aClass.SeatingCapacity) {RegularSeatingCapacity = aClass.RegularSeatingCapacity}; foreach (AirlinerFacility facility in aClass.GetFacilities()) { airlinerClass.SetFacility(null, facility); } foreach ( AirlinerFacility.FacilityType fType in Enum.GetValues(typeof (AirlinerFacility.FacilityType)) ) { if (!aClass.Facilities.Exists(f => f.Type == fType)) { airlinerClass.SetFacility(null, AirlinerFacilities.GetBasicFacility(fType)); } } airlinerClass.SeatingCapacity = Convert.ToInt16( Convert.ToDouble(airlinerClass.RegularSeatingCapacity) /airlinerClass.GetFacility(AirlinerFacility.FacilityType.Seat).SeatUses); classes.Add(airlinerClass); } seatingDiff = passengerType.MaxSeatingCapacity - configuration.MinimumSeats; } AirlinerClass economyClass = classes.Find(c => c.Type == AirlinerClass.ClassType.EconomyClass); economyClass.RegularSeatingCapacity += seatingDiff; AirlinerFacility seatingFacility = economyClass.GetFacility(AirlinerFacility.FacilityType.Seat); var extraSeats = (int) (seatingDiff/seatingFacility.SeatUses); economyClass.SeatingCapacity += extraSeats; } else { foreach ( AirlinerClassConfiguration aClass in ((AirlinerTypeConfiguration) airlinerTypeConfiguration).Classes) { var airlinerClass = new AirlinerClass(aClass.Type, aClass.SeatingCapacity) {RegularSeatingCapacity = aClass.RegularSeatingCapacity}; foreach (AirlinerFacility facility in aClass.GetFacilities()) { airlinerClass.SetFacility(null, facility); } airlinerClass.SeatingCapacity = Convert.ToInt16( Convert.ToDouble(airlinerClass.RegularSeatingCapacity) /airlinerClass.GetFacility(AirlinerFacility.FacilityType.Seat).SeatUses); classes.Add(airlinerClass); } } } else if (type is AirlinerCargoType) { var cargoClass = new AirlinerClass(AirlinerClass.ClassType.EconomyClass, 0); classes.Add(cargoClass); } else if (type.TypeAirliner == AirlinerType.TypeOfAirliner.Helicopter) { var helicopterClass = new AirlinerClass(AirlinerClass.ClassType.EconomyClass, 0); classes.Add(helicopterClass); } return classes; }