private void btnHub_Click(object sender, RoutedEventArgs e)
        {
            StackPanel panelHubs = new StackPanel();

            foreach (HubType type in HubTypes.GetHubTypes())
            {
                if (AirlineHelpers.CanCreateHub(GameObject.GetInstance().HumanAirline, this.Airport, type))
                {
                    panelHubs.Children.Add(createHubType(type, panelHubs));
                }
            }

            if (panelHubs.Children.Count == 0)
            {
                panelHubs.Children.Add(UICreator.CreateTextBlock("You can't etablish any hubs at this airport"));
            }

            if (PopUpSingleElement.ShowPopUp("Select hub type", panelHubs) == PopUpSingleElement.ButtonSelected.OK && panelHubs.Tag != null)
            {
                HubType type = (HubType)panelHubs.Tag;

                if (AirportHelpers.GetHubPrice(this.Airport, type) > GameObject.GetInstance().HumanAirline.Money)
                {
                    WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2212"), Translator.GetInstance().GetString("MessageBox", "2212", "message"), WPFMessageBoxButtons.Ok);
                }
                else
                {
                    this.Airport.addHub(new Hub(GameObject.GetInstance().HumanAirline, type));

                    showHubs();

                    AirlineHelpers.AddAirlineInvoice(GameObject.GetInstance().HumanAirline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Purchases, -AirportHelpers.GetHubPrice(this.Airport, type));
                }
            }
        }
Exemple #2
0
        private void btnCreateHub_Click(object sender, RoutedEventArgs e)
        {
            HubType type = HubTypes.GetHubType(HubType.TypeOfHub.Hub);//(HubType)cbHubType.SelectedItem;

            if (AirportHelpers.GetHubPrice(this.Airport.Airport, type) > GameObject.GetInstance().HumanAirline.Money)
            {
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2212"), Translator.GetInstance().GetString("MessageBox", "2212", "message"), WPFMessageBoxButtons.Ok);
            }
            else
            {
                WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2213"), string.Format(Translator.GetInstance().GetString("MessageBox", "2213", "message"), AirportHelpers.GetHubPrice(this.Airport.Airport, type)), WPFMessageBoxButtons.YesNo);


                if (result == WPFMessageBoxResult.Yes)
                {
                    this.Airport.addHub(new Hub(GameObject.GetInstance().HumanAirline, type));

                    AirlineHelpers.AddAirlineInvoice(GameObject.GetInstance().HumanAirline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Purchases, -AirportHelpers.GetHubPrice(this.Airport.Airport, type));
                }
            }
        }