Exemplo n.º 1
0
        private void btnApply_Click(object sender, RoutedEventArgs e)
        {
            int serviceDays            = 3;
            WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2902"), string.Format(Translator.GetInstance().GetString("MessageBox", "2902", "message"), serviceDays), WPFMessageBoxButtons.YesNo);

            if (result == WPFMessageBoxResult.Yes)
            {
                foreach (FleetAirliner airliner in this.AirlinersToMaintain)
                {
                    serviceDays = airliner.Airliner.Classes.Count == this.Classes.Count ? 1 : 3;

                    airliner.Airliner.clearAirlinerClasses();

                    foreach (AirlinerClass aClass in this.Classes)
                    {
                        AirlinerClass tClass = new AirlinerClass(aClass.Type, aClass.SeatingCapacity);
                        tClass.RegularSeatingCapacity = aClass.RegularSeatingCapacity;

                        foreach (AirlinerFacility facility in aClass.getFacilities())
                        {
                            tClass.setFacility(GameObject.GetInstance().HumanAirline, facility);
                        }

                        airliner.Airliner.addAirlinerClass(tClass);
                    }
                    airliner.GroundedToDate = GameObject.GetInstance().GameTime.AddDays(serviceDays);
                }
            }
        }
Exemplo n.º 2
0
        private void cbAirliner_Checked(object sender, RoutedEventArgs e)
        {
            int maxNumberOfAirliners = this.AirlineFacility.ServiceLevel;

            FleetAirliner airliner = (FleetAirliner)((CheckBox)sender).Tag;

            if (this.AirlinersToMaintain.Count == 0 || (this.AirlinersToMaintain.Exists(a => a.Airliner.Type == airliner.Airliner.Type) && this.AirlinersToMaintain.Count + 1 <= maxNumberOfAirliners))
            {
                this.AirlinersToMaintain.Add(airliner);

                AirlinerType type = this.AirlinersToMaintain[0].Airliner.Type;
                if (this.Classes == null || this.Classes.Count == 0)
                {
                    AirlinerClass eClass = new AirlinerClass(AirlinerClass.ClassType.Economy_Class, ((AirlinerPassengerType)type).MaxSeatingCapacity);
                    eClass.createBasicFacilities(null);
                    this.Classes.Add(eClass);

                    showClasses();
                }

                btnEquipped.IsEnabled = true;
                btnApply.IsEnabled    = true;
            }
            else
            {
                if (this.AirlinersToMaintain.Count == maxNumberOfAirliners)
                {
                    WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2901"), string.Format(Translator.GetInstance().GetString("MessageBox", "2901", "message"), maxNumberOfAirliners), WPFMessageBoxButtons.Ok);
                }

                ((CheckBox)sender).IsChecked = false;
            }
        }
Exemplo n.º 3
0
        private void link_Click(object sender, RoutedEventArgs e)
        {
            AirlinerType type = this.AirlinersToMaintain[0].Airliner.Type;

            if (this.Classes == null)
            {
                AirlinerClass eClass = new AirlinerClass(AirlinerClass.ClassType.Economy_Class, ((AirlinerPassengerType)type).MaxSeatingCapacity);
                eClass.createBasicFacilities(null);
                this.Classes.Add(eClass);
            }

            AirlinerClass aClass = (AirlinerClass)((Hyperlink)sender).Tag;

            AirlinerClass newClass = (AirlinerClass)PopUpAirlinerClassConfiguration.ShowPopUp(aClass);

            AirlinerClass economyClass = this.Classes.Find(c => c.Type == AirlinerClass.ClassType.Economy_Class);

            if (newClass != null)
            {
                AirlinerClass airlinerClass = new AirlinerClass(newClass.Type, newClass.SeatingCapacity);
                airlinerClass.RegularSeatingCapacity = newClass.RegularSeatingCapacity;

                int seatingDiff = ((AirlinerPassengerType)type).MaxSeatingCapacity;

                economyClass.RegularSeatingCapacity += seatingDiff;

                AirlinerFacility seatingFacility = economyClass.getFacility(AirlinerFacility.FacilityType.Seat);

                int extraSeats = (int)(seatingDiff / seatingFacility.SeatUses);

                economyClass.SeatingCapacity += extraSeats;
            }
        }
        private void cbStandardConfiguration_Checked(object sender, RoutedEventArgs e)
        {
            btnEquipped.IsEnabled           = false;
            btnApplyConfiguration.IsEnabled = false;
            AirlinerType type = (AirlinerType)((CheckBox)sender).Tag;

            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);

            List <AirlinerClass> classes = new List <AirlinerClass>();

            foreach (AirlinerClassConfiguration aClass in ((AirlinerTypeConfiguration)airlinerTypeConfiguration).Classes)
            {
                AirlinerClass airlinerClass = new AirlinerClass(aClass.Type, aClass.SeatingCapacity);
                airlinerClass.RegularSeatingCapacity = aClass.RegularSeatingCapacity;

                foreach (AirlinerFacility facility in aClass.getFacilities())
                {
                    airlinerClass.setFacility(GameObject.GetInstance().HumanAirline, facility);
                }

                classes.Add(airlinerClass);
            }

            if (classes != null)
            {
                this.Classes = classes;

                panelClasses.Children.Clear();

                foreach (AirlinerClass aClass in this.Classes)
                {
                    panelClasses.Children.Add(createAirlineClassLink(aClass));
                }
            }
        }
 //public int CabinCrew { get; set; }
 public RouteAirlinerClass(AirlinerClass.ClassType type,SeatingType seating, double fareprice)
 {
     this.Facilities = new List<RouteFacility>();
     this.FarePrice =  fareprice;
     this.Seating =  seating;
     this.Type = type;
 }
Exemplo n.º 6
0
        public AirlinerOrderMVVM(AirlinerType type, AirlinerOrdersMVVM order, int amount = 1)
        {
            this.Type      = type;
            this.Order     = order;
            this.Amount    = amount;
            this._classes  = new List <AirlinerClass>();
            this.Homebases = new List <Airport>();

            if (this.Type.TypeAirliner == AirlinerType.TypeOfAirliner.Passenger)
            {
                AirlinerClass eClass = new AirlinerClass(AirlinerClass.ClassType.Economy_Class, ((AirlinerPassengerType)type).MaxSeatingCapacity);
                eClass.createBasicFacilities(null);
                this.Classes.Add(eClass);
            }

            long minRunway = this.Type.MinRunwaylength;

            //var homebases = GameObject.GetInstance().HumanAirline.Airports.FindAll(a => (a.hasContractType(GameObject.GetInstance().HumanAirline, AirportContract.ContractType.Full_Service) || a.getCurrentAirportFacility(GameObject.GetInstance().HumanAirline, AirportFacility.FacilityType.Service).TypeLevel > 0) && a.getMaxRunwayLength() >= minRunway);

            var homebases = AirlineHelpers.GetHomebases(GameObject.GetInstance().HumanAirline, minRunway);

            foreach (var homebase in homebases)
            {
                this.Homebases.Add(homebase);
            }
        }
        public PopUpAirlinerSeatsConfiguration(AirlinerType type, List <AirlinerClass> classes)
        {
            this.FreeClassTypes = new ObservableCollection <AirlinerClass.ClassType>();
            this.Classes        = new ObservableCollection <AirlinerClassMVVM>();
            this.Type           = type;

            AirlinerClass economyClass = classes.Find(c => c.Type == AirlinerClass.ClassType.Economy_Class);

            foreach (AirlinerClass aClass in classes)
            {
                int maxseats             = aClass.Type == AirlinerClass.ClassType.Economy_Class ? aClass.SeatingCapacity : economyClass.RegularSeatingCapacity - 1;
                AirlinerClassMVVM nClass = new AirlinerClassMVVM(aClass.Type, aClass.SeatingCapacity, maxseats, aClass.Type != AirlinerClass.ClassType.Economy_Class);
                this.Classes.Add(nClass);

                foreach (AirlinerFacility facility in aClass.getFacilities())
                {
                    nClass.Facilities.Where(f => f.Type == facility.Type).First().SelectedFacility = facility;
                }
            }

            this.CanAddNewClass = this.Classes.Count < ((AirlinerPassengerType)this.Type).MaxAirlinerClasses;

            if (this.Classes.Count < 3)
            {
                this.FreeClassTypes.Clear();
                this.FreeClassTypes.Add(AirlinerClass.ClassType.Business_Class);
                this.FreeClassTypes.Add(AirlinerClass.ClassType.First_Class);
            }

            InitializeComponent();
        }
Exemplo n.º 8
0
        public AirlinerClassMVVM(AirlinerClass type, int seating, int regularSeating, int maxseats, Boolean changeableSeats = false)
        {
            this.Type    = type.Type;
            this.Seating = seating;
            this.RegularSeatingCapacity = regularSeating;
            this.ChangeableSeats        = changeableSeats;
            this.MaxSeats         = maxseats;
            this.MaxSeatsCapacity = maxseats;
            this.ChangedFacility  = false;

            this.Facilities = new ObservableCollection <AirlinerFacilityMVVM>();

            foreach (AirlinerFacility.FacilityType facType in Enum.GetValues(typeof(AirlinerFacility.FacilityType)))
            {
                AirlinerFacilityMVVM 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;

                this.Facilities.Add(facility);
            }
        }
Exemplo n.º 9
0
        public PageShowRoute(Route route)
        {
            this.Classes = new ObservableCollection <MVVMRouteClass>();

            this.Route       = new HumanRouteMVVM(route);
            this.DataContext = this.Route;


            foreach (AirlinerClass.ClassType type in AirlinerClass.GetAirlinerTypes())
            {
                if (this.Route.Route is PassengerRoute)
                {
                    RouteAirlinerClass rClass = ((PassengerRoute)this.Route.Route).getRouteAirlinerClass(type);
                    MVVMRouteClass     mClass = new MVVMRouteClass(type, rClass.Seating, rClass.FarePrice);

                    this.Classes.Add(mClass);
                }
            }


            InitializeComponent();


            this.Loaded += PageShowRoute_Loaded;
        }
Exemplo n.º 10
0
        public static object ShowPopUp(AirlinerClass airlinerClass, AirlinerFacility.FacilityType type)
        {
            PopUpWindow window = new PopUpAirlinerFacility(airlinerClass, type);

            window.ShowDialog();

            return(window.Selected == null ? null : window.Selected);
        }
        public static object ShowPopUp(AirlinerClass aClass)
        {
            PopUpWindow window = new PopUpAirlinerClassConfiguration(aClass);

            window.ShowDialog();

            return(window.Selected);
        }
        private void link_Click(object sender, RoutedEventArgs e)
        {
            AirlinerClass aClass = (AirlinerClass)((Hyperlink)sender).Tag;

            PopUpAirlinerClassConfiguration.ShowPopUp(aClass);

            customConfiguration = true;
        }
        private void btnLoadConfiguration_Click(object sender, RoutedEventArgs e)
        {
            ComboBox cbConfigurations = new ComboBox();

            cbConfigurations.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbConfigurations.SelectedValuePath   = "Name";
            cbConfigurations.DisplayMemberPath   = "Name";
            cbConfigurations.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            cbConfigurations.Width = 200;

            foreach (AirlinerConfiguration confItem in Configurations.GetConfigurations(Configuration.ConfigurationType.Airliner).Where(a => ((AirlinerConfiguration)a).MinimumSeats <= this.Airliner.Airliner.getTotalSeatCapacity() && ((AirlinerConfiguration)a).Classes.Count <= ((AirlinerPassengerType)this.Airliner.Airliner.Type).MaxAirlinerClasses))
            {
                cbConfigurations.Items.Add(confItem);
            }

            cbConfigurations.SelectedIndex = 0;


            if (TheAirline.GraphicsModel.UserControlModel.PopUpWindowsModel.PopUpSingleElement.ShowPopUp(Translator.GetInstance().GetString("PageAirlineWages", "1013"), cbConfigurations) == TheAirline.GraphicsModel.UserControlModel.PopUpWindowsModel.PopUpSingleElement.ButtonSelected.OK && cbConfigurations.SelectedItem != null)
            {
                this.Classes.Clear();

                AirlinerConfiguration configuration = (AirlinerConfiguration)cbConfigurations.SelectedItem;

                foreach (AirlinerClassConfiguration aClass in configuration.Classes)
                {
                    AirlinerClass     nClass = new AirlinerClass(aClass.Type, aClass.SeatingCapacity);
                    AirlinerClassMVVM tClass = new AirlinerClassMVVM(nClass, aClass.SeatingCapacity, aClass.RegularSeatingCapacity, aClass.RegularSeatingCapacity);

                    foreach (AirlinerFacility facility in aClass.getFacilities())
                    {
                        tClass.Facilities.First(f => f.Type == facility.Type).SelectedFacility = facility;
                    }

                    foreach (AirlinerFacility.FacilityType fType in Enum.GetValues(typeof(AirlinerFacility.FacilityType)))
                    {
                        if (!aClass.Facilities.Exists(f => f.Type == fType))
                        {
                            tClass.Facilities.First(f => f.Type == fType).SelectedFacility = AirlinerFacilities.GetBasicFacility(fType);
                        }
                    }

                    this.Classes.Add(tClass);
                }
                int seatingDiff = ((AirlinerPassengerType)this.Airliner.Airliner.Type).MaxSeatingCapacity - configuration.MinimumSeats;

                AirlinerClassMVVM economyClass = this.Classes.First(c => c.Type == AirlinerClass.ClassType.Economy_Class);

                economyClass.RegularSeatingCapacity += seatingDiff;

                AirlinerFacility seatingFacility = economyClass.Facilities.First(f => f.Type == AirlinerFacility.FacilityType.Seat).SelectedFacility;

                int extraSeats = (int)(seatingDiff / seatingFacility.SeatUses);

                economyClass.Seating += extraSeats;
            }
        }
        private void ButtonDelete_Click(object sender, RoutedEventArgs e)
        {
            AirlinerClass aClass = this.Classes[this.Classes.Count - 1];

            this.Classes.Remove(aClass);

            // chs, 2011-11-10 added so seat capacity is correctly calculated
            this.Classes[0].SeatingCapacity        += aClass.RegularSeatingCapacity;
            this.Classes[0].RegularSeatingCapacity += aClass.RegularSeatingCapacity;

            showAirlinerClasses();
        }
Exemplo n.º 15
0
        public FleetAirlinerMVVM(FleetAirliner airliner)
        {
            this.Airliner = airliner;
            this.Classes  = new ObservableCollection <AirlinerClassMVVM>();

            AirlinerClass tClass = this.Airliner.Airliner.Classes[0];

            foreach (AirlinerClass aClass in this.Airliner.Airliner.Classes)
            {
                int maxCapacity;

                if (airliner.Airliner.Type.TypeAirliner == AirlinerType.TypeOfAirliner.Passenger)
                {
                    maxCapacity = ((AirlinerPassengerType)airliner.Airliner.Type).MaxSeatingCapacity;
                }
                else
                {
                    maxCapacity = tClass.RegularSeatingCapacity;
                }

                Boolean changeable = this.Airliner.Airliner.Classes.IndexOf(aClass) > 0;

                int maxSeats;

                if (this.Airliner.Airliner.Classes.Count == 3)
                {
                    if (this.Airliner.Airliner.Classes.IndexOf(aClass) == 1)
                    {
                        maxSeats = maxCapacity - 1 - this.Airliner.Airliner.Classes[2].RegularSeatingCapacity;
                    }
                    else
                    {
                        maxSeats = maxCapacity - 1 - this.Airliner.Airliner.Classes[1].RegularSeatingCapacity;
                    }
                }
                else
                {
                    maxSeats = maxCapacity - 1;
                }


                AirlinerClassMVVM amClass = new AirlinerClassMVVM(aClass.Type, aClass.SeatingCapacity, aClass.RegularSeatingCapacity, maxSeats, changeable);
                this.Classes.Add(amClass);
            }

            this.AMaintenanceInterval = this.Airliner.AMaintenanceInterval;
            this.BMaintenanceInterval = this.Airliner.BMaintenanceInterval;
            this.CMaintenanceInterval = this.Airliner.CMaintenanceInterval;
            this.DMaintenanceInterval = this.Airliner.DMaintenanceInterval;

            this.SchedCMaintenance = this.Airliner.SchedCMaintenance;
            this.SchedDMaintenance = this.Airliner.SchedDMaintenance;
        }
        private void btnLoadConfiguration_Click(object sender, RoutedEventArgs e)
        {
            AirlinerPassengerType airlinerType = ((AirlinerPassengerType)this.Airliner.Airliner.Type);

            ComboBox cbConfigurations = new ComboBox();

            cbConfigurations.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbConfigurations.SelectedValuePath   = "Name";
            cbConfigurations.DisplayMemberPath   = "Name";
            cbConfigurations.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            cbConfigurations.Width = 200;

            foreach (AirlinerConfiguration confItem in Configurations.GetConfigurations(Configuration.ConfigurationType.Airliner).FindAll(c => ((AirlinerConfiguration)c).getNumberOfClasses() <= airlinerType.MaxAirlinerClasses && ((AirlinerConfiguration)c).MinimumSeats <= airlinerType.MaxSeatingCapacity))
            {
                cbConfigurations.Items.Add(confItem);
            }

            cbConfigurations.SelectedIndex = 0;

            if (PopUpSingleElement.ShowPopUp("Select configuration", cbConfigurations) == PopUpSingleElement.ButtonSelected.OK && cbConfigurations.SelectedItem != null)
            {
                AirlinerConfiguration configuration = (AirlinerConfiguration)cbConfigurations.SelectedItem;

                this.Airliner.Airliner.clearAirlinerClasses();

                foreach (AirlinerClassConfiguration aClass in configuration.Classes)
                {
                    AirlinerClass airlinerClass = new AirlinerClass(aClass.Type, aClass.SeatingCapacity);
                    airlinerClass.RegularSeatingCapacity = aClass.RegularSeatingCapacity;

                    foreach (AirlinerFacility facility in aClass.getFacilities())
                    {
                        airlinerClass.setFacility(this.Airliner.Airliner.Airline, facility);
                    }

                    this.Airliner.Airliner.addAirlinerClass(airlinerClass);
                }

                int seatingDiff = airlinerType.MaxSeatingCapacity - configuration.MinimumSeats;

                this.Airliner.Airliner.getAirlinerClass(AirlinerClass.ClassType.Economy_Class).RegularSeatingCapacity += seatingDiff;

                AirlinerFacility seatingFacility = this.Airliner.Airliner.getAirlinerClass(AirlinerClass.ClassType.Economy_Class).getFacility(AirlinerFacility.FacilityType.Seat);

                int extraSeats = (int)(seatingDiff / seatingFacility.SeatUses);

                this.Airliner.Airliner.getAirlinerClass(AirlinerClass.ClassType.Economy_Class).SeatingCapacity += extraSeats;

                showFacilities();
            }
        }
Exemplo n.º 17
0
        //creates a hyperlink for an airliner class
        private TextBlock createAirlineClassLink(AirlinerClass aClass)
        {
            TextBlock txtLink = new TextBlock();

            txtLink.Margin = new Thickness(0, 0, 20, 0);

            Hyperlink link = new Hyperlink();

            link.Tag    = aClass;
            link.Click += link_Click;
            link.Inlines.Add(new TextUnderscoreConverter().Convert(aClass.Type).ToString());
            txtLink.Inlines.Add(link);

            return(txtLink);
        }
        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();
        }
        private void btnSaveChanges_Click(object sender, RoutedEventArgs e)
        {
            this.Airliner.Airliner.Airliner.clearAirlinerClasses();

            foreach (AirlinerClassMVVM aClass in this.Airliner.Classes)
            {
                AirlinerClass nClass = new AirlinerClass(aClass.Type, aClass.RegularSeatingCapacity);
                nClass.SeatingCapacity = aClass.Seating;

                foreach (AirlinerFacilityMVVM aFacility in aClass.Facilities)
                {
                    nClass.forceSetFacility(aFacility.SelectedFacility);
                }

                this.Airliner.Airliner.Airliner.addAirlinerClass(nClass);
            }
        }
        private void ButtonAdd_Click(object sender, RoutedEventArgs e)
        {
            int seating = (int)((Button)sender).Tag;

            AirlinerClass aClass = new AirlinerClass(this.CurrentClass, seating);

            aClass.forceSetFacility(this.Classes[0].getFacility(AirlinerFacility.FacilityType.Audio));
            aClass.forceSetFacility(this.Classes[0].getFacility(AirlinerFacility.FacilityType.Seat));
            aClass.forceSetFacility(this.Classes[0].getFacility(AirlinerFacility.FacilityType.Video));

            this.Classes.Add(aClass);

            // chs, 2011-11-10 added so seat capacity is correctly calculated
            this.Classes[0].SeatingCapacity        -= aClass.SeatingCapacity;
            this.Classes[0].RegularSeatingCapacity -= aClass.SeatingCapacity;

            showAirlinerClasses();
        }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            List <AirlinerClass> classes = new List <AirlinerClass>();

            foreach (AirlinerClassMVVM mvvmClass in this.Classes)
            {
                AirlinerClass aClass = new AirlinerClass(mvvmClass.Type, mvvmClass.Seating);

                foreach (AirlinerClassFacilityMVVM facility in mvvmClass.Facilities)
                {
                    aClass.forceSetFacility(facility.SelectedFacility);
                }

                classes.Add(aClass);
            }

            this.Selected = classes;
            this.Close();
        }
Exemplo n.º 22
0
        public AirlinerOrderMVVM(AirlinerType type, int amount = 1)
        {
            this.Type      = type;
            this.Amount    = amount;
            this.Classes   = new List <AirlinerClass>();
            this.Homebases = new List <Airport>();

            if (this.Type.TypeAirliner == AirlinerType.TypeOfAirliner.Passenger)
            {
                AirlinerClass eClass = new AirlinerClass(AirlinerClass.ClassType.Economy_Class, ((AirlinerPassengerType)type).MaxSeatingCapacity);
                eClass.createBasicFacilities(null);
                this.Classes.Add(eClass);
            }

            long minRequiredRunway = this.Type.MinRunwaylength;

            foreach (var homebase in GameObject.GetInstance().HumanAirline.Airports.FindAll(a => a.getCurrentAirportFacility(GameObject.GetInstance().HumanAirline, AirportFacility.FacilityType.Service).TypeLevel > 0 && a.getMaxRunwayLength() >= minRequiredRunway))
            {
                this.Homebases.Add(homebase);
            }
        }
Exemplo n.º 23
0
        //returns the code for an airliner class
        public static string GetAirlinerClassCode(AirlinerClass aClass)
        {
            string symbol = "Y";

            if (aClass.Type == AirlinerClass.ClassType.Business_Class)
            {
                symbol = "C";
            }

            if (aClass.Type == AirlinerClass.ClassType.First_Class)
            {
                symbol = "F";
            }

            if (aClass.Type == AirlinerClass.ClassType.Economy_Class)
            {
                symbol = "Y";
            }

            return(string.Format("{0}{1}", aClass.SeatingCapacity, symbol));
        }
        //orders the airliners
        private void orderAirliners(double discount = 0)
        {
            DateTime deliveryDate = this.Orders.getDeliveryDate();

            Guid id = Guid.NewGuid();

            foreach (AirlinerOrderMVVM order in this.Orders.Orders)
            {
                for (int i = 0; i < order.Amount; i++)
                {
                    Airliner airliner = new Airliner(id.ToString(), order.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, order.Homebase);

                    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(GameObject.GetInstance().HumanAirline, facility);
                        }

                        airliner.addAirlinerClass(tClass);
                    }
                }
            }

            int    totalAmount = this.Orders.Orders.Sum(o => o.Amount);
            double price       = this.Orders.Orders.Sum(o => o.Type.Price * o.Amount);

            double totalPrice = price * ((1 - GeneralHelpers.GetAirlinerOrderDiscount(totalAmount))) * ((100 - discount) / 100);

            AirlineHelpers.AddAirlineInvoice(GameObject.GetInstance().HumanAirline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Purchases, -totalPrice);
        }
Exemplo n.º 25
0
        public PopUpAirlinerFacility(AirlinerClass airlinerClass, AirlinerFacility.FacilityType type)
        {
            InitializeComponent();

            this.AirlinerClass = airlinerClass;
            this.Type          = type;

            this.Title = "Select " + type.ToString().ToLower();

            this.Width = 400;

            this.Height = 120;

            this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;

            StackPanel mainPanel = new StackPanel();

            mainPanel.Margin = new Thickness(10, 10, 10, 10);

            cbFacility = new ComboBox();
            cbFacility.ItemTemplate = this.Resources["AirlinerFacilityItem"] as DataTemplate;
            cbFacility.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");

            foreach (AirlinerFacility facility in AirlinerFacilities.GetFacilities(this.Type, GameObject.GetInstance().GameTime.Year))
            {
                cbFacility.Items.Add(facility);
            }

            cbFacility.SelectedItem = this.AirlinerClass.getFacility(this.Type);

            mainPanel.Children.Add(cbFacility);

            mainPanel.Children.Add(createButtonsPanel());

            this.Content = mainPanel;
            // int serviceLevel, double percentOfSeats, double pricePerSeat
        }
        private void btnOrder_Click(object sender, RoutedEventArgs e)
        {
            Boolean hasHomebases = true;

            foreach (AirlinerOrderMVVM order in this.Orders.Orders)
            {
                if (order.Homebase == null)
                {
                    hasHomebases = false;
                }
            }
            Boolean contractedOrder = false;
            Boolean tryOrder        = true;

            DateTime deliveryDate = this.Orders.getDeliveryDate();

            if (!hasHomebases)
            {
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2002"), Translator.GetInstance().GetString("MessageBox", "2002", "message"), WPFMessageBoxButtons.Ok);
            }
            else
            {
                if (GameObject.GetInstance().HumanAirline.Contract != null)
                {
                    if (GameObject.GetInstance().HumanAirline.Contract.Manufacturer == this.Manufacturer)
                    {
                        contractedOrder = true;
                    }
                    else
                    {
                        double terminationFee      = GameObject.GetInstance().HumanAirline.Contract.getTerminationFee();
                        WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2010"), string.Format(Translator.GetInstance().GetString("MessageBox", "2010", "message"), GameObject.GetInstance().HumanAirline.Contract.Manufacturer.Name, terminationFee), WPFMessageBoxButtons.YesNo);

                        if (result == WPFMessageBoxResult.Yes)
                        {
                            AirlineHelpers.AddAirlineInvoice(GameObject.GetInstance().HumanAirline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Purchases, -terminationFee);
                            GameObject.GetInstance().HumanAirline.Contract = null;

                            this.Contract.Contracted = null;
                        }
                        tryOrder = result == WPFMessageBoxResult.Yes;
                    }
                }

                if (tryOrder)
                {
                    int    totalAmount = this.Orders.Orders.Sum(o => o.Amount);
                    double price       = this.Orders.Orders.Sum(o => o.Type.Price * o.Amount);

                    double totalPrice = price * ((1 - GeneralHelpers.GetAirlinerOrderDiscount(totalAmount)));

                    if (contractedOrder)
                    {
                        totalPrice = totalPrice * ((100 - GameObject.GetInstance().HumanAirline.Contract.Discount) / 100);
                    }

                    double downpaymentPrice = 0;

                    downpaymentPrice = totalPrice * (GameObject.GetInstance().Difficulty.PriceLevel / 10);

                    if (cbDownPayment.IsChecked.Value)
                    {
                        if (downpaymentPrice > GameObject.GetInstance().HumanAirline.Money)
                        {
                            WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2001"), Translator.GetInstance().GetString("MessageBox", "2001", "message"), WPFMessageBoxButtons.Ok);
                        }
                        else
                        {
                            WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2009"), string.Format(Translator.GetInstance().GetString("MessageBox", "2009", "message"), totalPrice, downpaymentPrice), WPFMessageBoxButtons.YesNo);

                            if (result == WPFMessageBoxResult.Yes)
                            {
                                foreach (AirlinerOrderMVVM order in this.Orders.Orders)
                                {
                                    for (int i = 0; i < order.Amount; i++)
                                    {
                                        Guid id = Guid.NewGuid();

                                        Airliner airliner = new Airliner(id.ToString(), order.Type, GameObject.GetInstance().HumanAirline.Profile.Country.TailNumbers.getNextTailNumber(), deliveryDate);

                                        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(GameObject.GetInstance().HumanAirline, facility);
                                            }

                                            airliner.addAirlinerClass(tClass);
                                        }


                                        Model.AirlinerModel.Airliners.AddAirliner(airliner);

                                        FleetAirliner.PurchasedType pType = FleetAirliner.PurchasedType.BoughtDownPayment;
                                        GameObject.GetInstance().HumanAirline.addAirliner(pType, airliner, order.Homebase);
                                    }
                                }
                                if (contractedOrder)
                                {
                                    GameObject.GetInstance().HumanAirline.Contract.PurchasedAirliners += this.Orders.Orders.Sum(o => o.Amount);
                                }
                                AirlineHelpers.AddAirlineInvoice(GameObject.GetInstance().HumanAirline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Purchases, -downpaymentPrice);

                                TabControl tab_main = UIHelpers.FindChild <TabControl>(this.Tag as Page, "tabMenu");

                                if (tab_main != null)
                                {
                                    var matchingItem =
                                        tab_main.Items.Cast <TabItem>()
                                        .Where(item => item.Tag.ToString() == "Order")
                                        .FirstOrDefault();

                                    tab_main.SelectedItem = matchingItem;
                                }
                            }
                        }
                    }
                    else
                    {
                        if (totalPrice > GameObject.GetInstance().HumanAirline.Money)
                        {
                            WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2001"), Translator.GetInstance().GetString("MessageBox", "2001", "message"), WPFMessageBoxButtons.Ok);
                        }
                        else
                        {
                            if (this.Orders.Orders.Sum(o => o.Amount) > 0)
                            {
                                WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2008"), string.Format(Translator.GetInstance().GetString("MessageBox", "2008", "message"), totalPrice), WPFMessageBoxButtons.YesNo);

                                if (result == WPFMessageBoxResult.Yes)
                                {
                                    orderAirliners(contractedOrder ? GameObject.GetInstance().HumanAirline.Contract.Discount : 0);

                                    TabControl tab_main = UIHelpers.FindChild <TabControl>(this.Tag as Page, "tabMenu");

                                    if (tab_main != null)
                                    {
                                        var matchingItem =
                                            tab_main.Items.Cast <TabItem>()
                                            .Where(item => item.Tag.ToString() == "Order")
                                            .FirstOrDefault();

                                        tab_main.SelectedItem = matchingItem;
                                    }
                                }

                                if (contractedOrder)
                                {
                                    GameObject.GetInstance().HumanAirline.Contract.PurchasedAirliners += this.Orders.Orders.Sum(o => o.Amount);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 27
0
 //returns the flight airliner class for a specific class type
 public FlightAirlinerClass getFlightAirlinerClass(AirlinerClass.ClassType type)
 {
     return this.Classes.Find(c => c.AirlinerClass.Type == type);
 }
 //returns the service level for a specific class
 public double getServiceLevel(AirlinerClass.ClassType type)
 {
     return this.Classes.Find(c => c.Type == type).getFacilities().Sum(f => f.ServiceLevel);
 }
 //returns the route airliner class for a specific class type
 public RouteAirlinerClass getRouteAirlinerClass(AirlinerClass.ClassType type)
 {
     return this.Classes.Find(cl => cl.Type == type);
 }
 //returns the price for a specific class
 public double getFarePrice(AirlinerClass.ClassType type)
 {
     return this.Classes.Find(c => c.Type == type).FarePrice;
 }
Exemplo n.º 31
0
        //returns the airliner classes for an airliner
        public static List <AirlinerClass> GetAirlinerClasses(AirlinerType type)
        {
            List <AirlinerClass> classes = new List <AirlinerClass>();

            if (type is AirlinerPassengerType)
            {
                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)
                {
                    AirlinerConfiguration configuration = null;

                    int numOfClasses = rnd.Next(0, ((AirlinerPassengerType)type).MaxAirlinerClasses) + 1;

                    if (GameObject.GetInstance().GameTime.Year >= (int)AirlinerClass.ClassType.Business_Class)
                    {
                        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");
                        }
                    }

                    foreach (AirlinerClassConfiguration aClass in configuration.Classes)
                    {
                        AirlinerClass airlinerClass = new AirlinerClass(aClass.Type, aClass.SeatingCapacity);
                        airlinerClass.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);
                    }

                    int seatingDiff = ((AirlinerPassengerType)type).MaxSeatingCapacity - configuration.MinimumSeats;

                    AirlinerClass economyClass = classes.Find(c => c.Type == AirlinerClass.ClassType.Economy_Class);
                    economyClass.RegularSeatingCapacity += seatingDiff;

                    AirlinerFacility seatingFacility = economyClass.getFacility(AirlinerFacility.FacilityType.Seat);

                    int extraSeats = (int)(seatingDiff / seatingFacility.SeatUses);

                    economyClass.SeatingCapacity += extraSeats;
                }
                else
                {
                    foreach (AirlinerClassConfiguration aClass in ((AirlinerTypeConfiguration)airlinerTypeConfiguration).Classes)
                    {
                        AirlinerClass airlinerClass = new AirlinerClass(aClass.Type, aClass.SeatingCapacity);
                        airlinerClass.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)
            {
                AirlinerClass cargoClass = new AirlinerClass(AirlinerClass.ClassType.Economy_Class, 0);
                classes.Add(cargoClass);
            }

            return(classes);
        }
Exemplo n.º 32
0
 public RouteClassConfiguration(AirlinerClass.ClassType type)
 {
     this.Type = type;
     this.Facilities = new List<RouteFacility>();
 }
 public AirlinerClassItem(AirlinerClass aClass, Boolean canDelete)
 {
     this.AirlinerClass = aClass;
     this.CanDelete     = canDelete;
 }