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
        }
        //adds a facility to the list
        public static void AddFacility(AirlinerFacility facility)
        {
            if (!facilities.ContainsKey(facility.Type))
                facilities.Add(facility.Type, new List<AirlinerFacility>());

            facilities[facility.Type].Add(facility);
        }
 //returns the list of facilities for a specific type
 public static List<AirlinerFacility> GetFacilities(AirlinerFacility.FacilityType type)
 {
     if (facilities.ContainsKey(type))
         return facilities[type];
     else
         return new List<AirlinerFacility>();
 }
 // chs, 2011-13-10 added function to return a specific airliner facility
 //returns a facility based on name and type
 public static AirlinerFacility GetFacility(AirlinerFacility.FacilityType type, string uid)
 {
     if (GetFacilities(type).Count > 0)
         return GetFacilities(type).Find((delegate(AirlinerFacility f) { return f.Uid == uid; }));
     else
         return null;
 }
Beispiel #5
0
        //gets the price for the airliner based on age
        public long getPrice()
        {
            double basePrice = this.Type.Price;

            double facilityPrice = 0;

            var classes = new List <AirlinerClass>(this.Classes);

            foreach (AirlinerClass aClass in classes)
            {
                AirlinerFacility audioFacility = aClass.getFacility(AirlinerFacility.FacilityType.Audio);
                AirlinerFacility videoFacility = aClass.getFacility(AirlinerFacility.FacilityType.Video);
                AirlinerFacility seatFacility  = aClass.getFacility(AirlinerFacility.FacilityType.Seat);

                double audioPrice = audioFacility.PricePerSeat * audioFacility.PercentOfSeats * aClass.SeatingCapacity;
                double videoPrice = videoFacility.PricePerSeat * videoFacility.PercentOfSeats * aClass.SeatingCapacity;
                double seatPrice  = seatFacility.PricePerSeat * seatFacility.PercentOfSeats * aClass.SeatingCapacity;

                facilityPrice += audioPrice + videoPrice + seatPrice;
            }


            basePrice += facilityPrice;

            int    age = getAge();
            double devaluationPercent = 1 - (0.02 * (double)age);


            return(Convert.ToInt64(basePrice * devaluationPercent * (this.Condition / 100)));
        }
        //returns the list of facilities for a specific type after a specific year
        public static List<AirlinerFacility> GetFacilities(AirlinerFacility.FacilityType type, int year)
        {
            if (facilities.ContainsKey(type))
                return facilities[type].FindAll((delegate(AirlinerFacility f) { return f.FromYear <= year; }));

            else
                return new List<AirlinerFacility>();
        }
        public static object ShowPopUp(AirlinerClass airlinerClass, AirlinerFacility.FacilityType type)
        {
            PopUpWindow window = new PopUpAirlinerFacility(airlinerClass, type);

            window.ShowDialog();

            return window.Selected == null ? null : window.Selected;
        }
Beispiel #8
0
        //sets the facility for a facility type
        public void setFacility(Airline airline, AirlinerFacility facility)
        {
            this.Facilities[facility.Type] = facility;

            if (airline != null)
            {
                AirlineHelpers.AddAirlineInvoice(airline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Purchases, -facility.PricePerSeat * facility.PercentOfSeats / 100.0 * this.SeatingCapacity);
            }
        }
        //adds a facility to the list
        public static void AddFacility(AirlinerFacility facility)
        {
            if (!facilities.ContainsKey(facility.Type))
            {
                facilities.Add(facility.Type, new List <AirlinerFacility>());
            }

            facilities[facility.Type].Add(facility);
        }
        public AirlinerFacilityMVVM(AirlinerFacility.FacilityType type,AirlinerClassMVVM airlinerClass)
        {
            this.Facilities = new List<AirlinerFacility>();

            this.AirlinerClass = airlinerClass;
            this.Type = type;
        }
 public AirlinerClassFacilityMVVM(AirlinerFacility.FacilityType type)
 {
     this.Type = type;
     this.Facilities = new List<AirlinerFacility>();
 }
Beispiel #12
0
 //returns the current facility for a facility type
 public AirlinerFacility getFacility(AirlinerFacility.FacilityType type)
 {
     return this.Facilities[type];
 }
 //returns the facility of a specific type
 public AirlinerFacility getFacility(AirlinerFacility.FacilityType type)
 {
     return this.Facilities.Find(f => f.Type == type);
 }
 //adds a facility to the configuration
 public void addFacility(AirlinerFacility facility)
 {
     this.Facilities.Add(facility);
 }
 public AirlinerFacilityItem(Airline airline, AirlinerClass aClass, AirlinerFacility facility)
 {
     this.Airline = airline;
     this.AirlinerClass = aClass;
     this.Facility = facility;
 }
 private void setSeating(AirlinerFacility oldValue)
 {
     if (this.Type == AirlinerFacility.FacilityType.Seat && _selectedFacility != null && oldValue != null)
     {
         this.AirlinerClass.ChangedFacility = true;
         double diff = oldValue.SeatUses / _selectedFacility.SeatUses;
         this.AirlinerClass.Seating = Convert.ToInt16(Convert.ToDouble(this.AirlinerClass.Seating) * diff);
         this.AirlinerClass.MaxSeats = Convert.ToInt16(Convert.ToDouble(this.AirlinerClass.MaxSeats) * diff);
         this.AirlinerClass.ChangedFacility = false;
     }
 }
Beispiel #17
0
 //force sets the facility for a facility type without cost
 public void forceSetFacility(AirlinerFacility facility)
 {
     this.Facilities[facility.Type] = facility;
 }
Beispiel #18
0
 //force sets the facility for a facility type without cost
 public void forceSetFacility(AirlinerFacility facility)
 {
     this.Facilities[facility.Type] = facility;
 }
Beispiel #19
0
 //returns the current facility for a facility type
 public AirlinerFacility getFacility(AirlinerFacility.FacilityType type)
 {
     if (this.Facilities.ContainsKey(type))
         return this.Facilities[type];
     else
         return null;
 }
Beispiel #20
0
        //sets the facility for a facility type
        public void setFacility(Airline airline, AirlinerFacility facility)
        {
            this.Facilities[facility.Type] = facility;

            if (airline != null)
                AirlineHelpers.AddAirlineInvoice(airline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Purchases, -facility.PricePerSeat * facility.PercentOfSeats / 100.0 * this.SeatingCapacity);
        }
Beispiel #21
0
 //returns the basic facility for a specific type
 public static AirlinerFacility GetBasicFacility(AirlinerFacility.FacilityType type)
 {
     return facilities[type][0];
 }
        public AirlinerFacilityMVVM(AirlinerFacility.FacilityType type,AirlinerClassMVVM airlinerClass)
        {
            this.Facilities = new ObservableCollection<AirlinerFacility>();

            this.AirlinerClass = airlinerClass;
            this.Type = type;
        }
Beispiel #23
0
 //adds a facility to the configuration
 public void addFacility(AirlinerFacility facility)
 {
     this.Facilities.Add(facility);
 }