Пример #1
0
        private void PageAirport_OnTimeChanged()
        {
            if (this.IsLoaded)
            {
                GameTimeZone tz = this.Airport.Profile.TimeZone;

                txtLocalTime.Text = string.Format("{0} {1}", MathHelpers.ConvertDateTimeToLoalTime(GameObject.GetInstance().GameTime, tz).ToShortTimeString(), tz.ShortName);
            }
        }
Пример #2
0
        //shows the departures or arrivals
        private void showFlights(Boolean arrivals)
        {
            lbFlights.Items.Clear();

            var entries = arrivals ?   GeneralHelpers.GetAirportArrivals(this.Airport, GameObject.GetInstance().GameTime.DayOfWeek) : GeneralHelpers.GetAirportDepartures(this.Airport, GameObject.GetInstance().GameTime.DayOfWeek);

            GameTimeZone tz = this.Airport.Profile.TimeZone;

            foreach (RouteTimeTableEntry entry in entries)
            {
                if (arrivals)
                {
                    TimeSpan flightTime = MathHelpers.GetFlightTime(entry.getDepartureAirport().Profile.Coordinates, entry.Destination.Airport.Profile.Coordinates, entry.Airliner.Airliner.Type);
                    lbFlights.Items.Add(new AirportFlightItem(MathHelpers.ConvertDateTimeToLoalTime(MathHelpers.ConvertEntryToDate(entry).Add(flightTime), tz), entry.Airliner.Airliner.Airline, entry.Destination.Airport == entry.TimeTable.Route.Destination1 ? entry.TimeTable.Route.Destination2 : entry.TimeTable.Route.Destination1, entry.Destination.FlightCode));
                }
                else
                {
                    lbFlights.Items.Add(new AirportFlightItem(MathHelpers.ConvertDateTimeToLoalTime(MathHelpers.ConvertEntryToDate(entry), tz), entry.Airliner.Airliner.Airline, entry.Destination.Airport, entry.Destination.FlightCode));
                }
            }

            /*
             *          GameTimeZone tz = this.Airport.Profile.TimeZone;
             *
             *          lbArrivals.Items.Clear();
             *          lbDepartures.Items.Clear();
             *
             *
             *
             *          foreach (RouteTimeTableEntry entry in GeneralHelpers.GetAirportDepartures(this.Airport, 2))
             *          {
             *              if (entry.Airliner.CurrentFlight != null && entry.Airliner.CurrentFlight.Entry == entry)
             *                  lbDepartures.Items.Add(new AirportFlightItem(MathHelpers.ConvertDateTimeToLoalTime(MathHelpers.ConvertEntryToDate(entry), tz), entry.Airliner.Airliner.Airline, entry.Destination.Airport, entry.Destination.FlightCode, "Planned"));
             *              else
             *                  lbDepartures.Items.Add(new AirportFlightItem(MathHelpers.ConvertDateTimeToLoalTime(MathHelpers.ConvertEntryToDate(entry), tz), entry.Airliner.Airliner.Airline, entry.Destination.Airport, entry.Destination.FlightCode, "Planned"));
             *          }
             *
             *          foreach (RouteTimeTableEntry entry in GeneralHelpers.GetAirportArrivals(this.Airport, 2))
             *          {
             *              TimeSpan flightTime = MathHelpers.GetFlightTime(entry.getDepartureAirport().Profile.Coordinates, entry.Destination.Airport.Profile.Coordinates, entry.Airliner.Airliner.Type);
             *
             *              if (entry.Airliner.CurrentFlight != null && entry == entry.Airliner.CurrentFlight.Entry && entry.Airliner.Status == FleetAirliner.AirlinerStatus.On_route)
             *                  lbArrivals.Items.Add(new AirportFlightItem(MathHelpers.ConvertDateTimeToLoalTime(MathHelpers.ConvertEntryToDate(entry).Add(flightTime), tz), entry.Airliner.Airliner.Airline, entry.Destination.Airport == entry.TimeTable.Route.Destination1 ? entry.TimeTable.Route.Destination2 : entry.TimeTable.Route.Destination1, entry.Destination.FlightCode, string.Format("{0:HH:mm}", entry.Airliner.CurrentFlight.getExpectedLandingTime())));
             *              else
             *                  lbArrivals.Items.Add(new AirportFlightItem(MathHelpers.ConvertDateTimeToLoalTime(MathHelpers.ConvertEntryToDate(entry).Add(flightTime), tz), entry.Airliner.Airliner.Airline, entry.Destination.Airport == entry.TimeTable.Route.Destination1 ? entry.TimeTable.Route.Destination2 : entry.TimeTable.Route.Destination1, entry.Destination.FlightCode, string.Format("{0:HH:mm}", "Planned")));
             *          }   */
        }
        //shows the departures or arrivals
        private void showFlights(Boolean arrivals)
        {
            lbFlights.Items.Clear();

            var entries = arrivals ? GeneralHelpers.GetAirportArrivals(this.Airport, GameObject.GetInstance().GameTime.DayOfWeek) : GeneralHelpers.GetAirportDepartures(this.Airport, GameObject.GetInstance().GameTime.DayOfWeek);

            GameTimeZone tz = this.Airport.Profile.TimeZone;

            foreach (RouteTimeTableEntry entry in entries)
            {
                if (arrivals)
                {
                    TimeSpan flightTime = MathHelpers.GetFlightTime(entry.getDepartureAirport().Profile.Coordinates, entry.Destination.Airport.Profile.Coordinates, entry.Airliner.Airliner.Type);
                    lbFlights.Items.Add(new AirportFlightItem(MathHelpers.ConvertDateTimeToLoalTime(MathHelpers.ConvertEntryToDate(entry).Add(flightTime), tz), entry.Airliner.Airliner.Airline, entry.Destination.Airport == entry.TimeTable.Route.Destination1 ? entry.TimeTable.Route.Destination2 : entry.TimeTable.Route.Destination1, entry.Destination.FlightCode));
                }
                else
                {
                    lbFlights.Items.Add(new AirportFlightItem(MathHelpers.ConvertDateTimeToLoalTime(MathHelpers.ConvertEntryToDate(entry), tz), entry.Airliner.Airliner.Airline, entry.Destination.Airport, entry.Destination.FlightCode));
                }
            }
        }
Пример #4
0
        //returns the time zone for the airport
        private GameTimeZone getTimeZone()
        {
            GameTimeZone zone = TimeZones.GetTimeZones().Find(delegate(GameTimeZone gtz) { return(gtz.UTCOffset == this.OffsetDST); });

            return(zone);
        }
Пример #5
0
        //creates a new game
        private void createNewGame()
        {
            if (txtName.Text.Trim().Length > 2)
            {
                object    o         = null;
                int       startYear = (int)cbStartYear.SelectedItem;
                int       opponents = (int)cbOpponents.SelectedItem;
                Airline   airline   = (Airline)cbAirline.SelectedItem;
                Continent continent = (Continent)cbContinent.SelectedItem;
                Region    region    = (Region)cbRegion.SelectedItem;


                if (this.OpponentType == OpponentSelect.User)
                {
                    if (cbSameRegion.IsChecked.Value)
                    {
                        o = PopUpSelectOpponents.ShowPopUp(airline, opponents, startYear, airline.Profile.Country.Region);
                    }
                    else
                    {
                        o = PopUpSelectOpponents.ShowPopUp(airline, opponents, startYear, region, continent);
                    }
                }



                // popUpSplash.IsOpen = true;

                DoEvents();

                GameTimeZone gtz = (GameTimeZone)cbTimeZone.SelectedItem;
                GameObject.GetInstance().DayRoundEnabled = cbDayTurnEnabled.IsChecked.Value;
                GameObject.GetInstance().TimeZone        = gtz;
                GameObject.GetInstance().Difficulty      = (DifficultyLevel)cbDifficulty.SelectedItem;
                GameObject.GetInstance().GameTime        = new DateTime(startYear, 1, 1);
                GameObject.GetInstance().StartDate       = GameObject.GetInstance().GameTime;
                //sets the fuel price
                GameObject.GetInstance().FuelPrice = Inflations.GetInflation(GameObject.GetInstance().GameTime.Year).FuelPrice;

                airline.Profile.Country = (Country)cbCountry.SelectedItem;
                airline.Profile.CEO     = txtName.Text.Trim();

                GameObject.GetInstance().setHumanAirline(airline);
                GameObject.GetInstance().MainAirline = GameObject.GetInstance().HumanAirline;

                if (cbLocalCurrency.IsChecked.Value)
                {
                    GameObject.GetInstance().CurrencyCountry = airline.Profile.Country;
                }
                // AppSettings.GetInstance().resetCurrencyFormat();

                Airport airport = (Airport)cbAirport.SelectedItem;

                AirportHelpers.RentGates(airport, airline, 2);

                AirportFacility checkinFacility = AirportFacilities.GetFacilities(AirportFacility.FacilityType.CheckIn).Find(f => f.TypeLevel == 1);
                AirportFacility facility        = AirportFacilities.GetFacilities(AirportFacility.FacilityType.Service).Find((delegate(AirportFacility f) { return(f.TypeLevel == 1); }));

                airport.addAirportFacility(GameObject.GetInstance().HumanAirline, facility, GameObject.GetInstance().GameTime);
                airport.addAirportFacility(GameObject.GetInstance().HumanAirline, checkinFacility, GameObject.GetInstance().GameTime);

                if (continent.Uid != "100" || region.Uid != "100")
                {
                    var airlines = Airlines.GetAirlines(a => a.Profile.Country.Region == region || (region.Uid == "100" && continent.hasRegion(a.Profile.Country.Region)) && a.Profile.Founded <= startYear && a.Profile.Folded > startYear);
                    var airports = Airports.GetAirports(a => a.Profile.Country.Region == region || (region.Uid == "100" && continent.hasRegion(a.Profile.Country.Region)) && a.Profile.Period.From.Year <= startYear && a.Profile.Period.To.Year > startYear);

                    //Airports.RemoveAirports(a => (a.Profile.Country.Region != region && !continent.hasRegion(a.Profile.Country.Region)) || (a.Profile.Town.State != null && a.Profile.Town.State.IsOverseas));
                    Airports.Clear();
                    foreach (Airport a in airports)
                    {
                        Airports.AddAirport(a);
                    }

                    Airlines.Clear();
                    foreach (Airline a in airlines)
                    {
                        Airlines.AddAirline(a);
                    }
                }

                PassengerHelpers.CreateAirlineDestinationDemand();

                AirlinerHelpers.CreateStartUpAirliners();

                if (this.OpponentType == OpponentSelect.Random || o == null)
                {
                    Setup.SetupMainGame(opponents, cbSameRegion.IsChecked.Value);
                }
                else
                {
                    Setup.SetupMainGame((List <Airline>)o);
                }


                airline.MarketFocus = (Airline.AirlineFocus)cbFocus.SelectedItem;

                GeneralHelpers.CreateHolidays(GameObject.GetInstance().GameTime.Year);

                //PassengerHelpers.CreateDestinationPassengers();

                GameObjectWorker.GetInstance().start();
                // AIWorker.GetInstance().start();

                PageNavigator.NavigateTo(new PageAirline(GameObject.GetInstance().HumanAirline));

                PageNavigator.ClearNavigator();

                //GameObject.GetInstance().HumanAirline.Money = 10000000000000;

                GameObject.GetInstance().NewsBox.addNews(new News(News.NewsType.Standard_News, GameObject.GetInstance().GameTime, Translator.GetInstance().GetString("News", "1001"), string.Format(Translator.GetInstance().GetString("News", "1001", "message"), GameObject.GetInstance().HumanAirline.Profile.CEO, GameObject.GetInstance().HumanAirline.Profile.IATACode)));

                popUpSplash.IsOpen = false;



                Action action = () =>
                {
                    Stopwatch swPax = new Stopwatch();
                    swPax.Start();

                    PassengerHelpers.CreateDestinationDemand();

                    Console.WriteLine("Demand have been created in {0} ms.", swPax.ElapsedMilliseconds);
                    swPax.Stop();
                };

                Task.Factory.StartNew(action);
                //Task.Run(action);
                //Task t2 = Task.Factory.StartNew(action, "passengers");
            }
            else
            {
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2403"), Translator.GetInstance().GetString("MessageBox", "2403"), WPFMessageBoxButtons.Ok);
            }
        }
Пример #6
0
        //creates the quick info panel for the airport
        private ScrollViewer createQuickInfoPanel()
        {
            ScrollViewer scroller = new ScrollViewer();

            scroller.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            scroller.VerticalScrollBarVisibility   = ScrollBarVisibility.Auto;
            scroller.MaxHeight = GraphicsHelpers.GetContentHeight() / 2;

            StackPanel panelInfo = new StackPanel();

            scroller.Content = panelInfo;

            TextBlock txtHeader = new TextBlock();

            txtHeader.Uid = "1006";
            txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush");
            txtHeader.TextAlignment = TextAlignment.Left;
            txtHeader.FontWeight    = FontWeights.Bold;
            txtHeader.Text          = Translator.GetInstance().GetString("PageAirport", txtHeader.Uid);

            panelInfo.Children.Add(txtHeader);

            DockPanel grdQuickInfo = new DockPanel();

            grdQuickInfo.Margin = new Thickness(0, 5, 0, 0);

            panelInfo.Children.Add(grdQuickInfo);

            Image imgAirport = new Image();

            imgAirport.Source = this.Airport.Profile.Logo.Length > 0 ? new BitmapImage(new Uri(this.Airport.Profile.Logo, UriKind.RelativeOrAbsolute)) : new BitmapImage(new Uri(@"/Data/images/airport.png", UriKind.Relative));
            imgAirport.Width  = 110;
            imgAirport.Margin = new Thickness(0, 0, 5, 0);
            imgAirport.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            RenderOptions.SetBitmapScalingMode(imgAirport, BitmapScalingMode.HighQuality);
            grdQuickInfo.Children.Add(imgAirport);

            StackPanel panelQuickInfo = new StackPanel();

            grdQuickInfo.Children.Add(panelQuickInfo);

            ListBox lbQuickInfo = new ListBox();

            lbQuickInfo.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
            lbQuickInfo.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem");

            panelQuickInfo.Children.Add(lbQuickInfo);

            lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1007"), UICreator.CreateTextBlock(this.Airport.Profile.Name)));

            lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1008"), UICreator.CreateTextBlock(new AirportCodeConverter().Convert(this.Airport).ToString())));
            lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1009"), UICreator.CreateTextBlock(new TextUnderscoreConverter().Convert(this.Airport.Profile.Type).ToString())));


            lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1010"), UICreator.CreateTownPanel(this.Airport.Profile.Town)));



            ContentControl lblFlag = new ContentControl();

            lblFlag.SetResourceReference(ContentControl.ContentTemplateProperty, "CountryFlagLongItem");
            lblFlag.Content = new CountryCurrentCountryConverter().Convert(this.Airport.Profile.Country);//this.Airport.Profile.Country is TemporaryCountry ? ((TemporaryCountry)this.Airport.Profile.Country).getCurrentCountry(GameObject.GetInstance().GameTime) : this.Airport.Profile.Country;

            lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1011"), lblFlag));

            lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1022"), UICreator.CreateTextBlock(this.Airport.Profile.Period.From.ToShortDateString())));

            if (GameObject.GetInstance().GameTime.AddDays(14) > this.Airport.Profile.Period.To)
            {
                TextBlock txtClosingDate = UICreator.CreateTextBlock(this.Airport.Profile.Period.To.ToShortDateString());
                txtClosingDate.Foreground = Brushes.DarkRed;

                lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1024"), txtClosingDate));
            }

            GameTimeZone tz = this.Airport.Profile.TimeZone;

            TextBlock txtTimeZone = UICreator.CreateTextBlock(tz.DisplayName);

            lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1012"), txtTimeZone));

            txtLocalTime = UICreator.CreateTextBlock(string.Format("{0} {1}", MathHelpers.ConvertDateTimeToLoalTime(GameObject.GetInstance().GameTime, tz).ToShortTimeString(), tz.ShortName));

            lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1013"), txtLocalTime));
            lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1019"), UICreator.CreateTextBlock(new TextUnderscoreConverter().Convert(this.Airport.Profile.Season).ToString())));

            WrapPanel panelCoordinates = new WrapPanel();

            Image imgMap = new Image();

            imgMap.Source     = new BitmapImage(new Uri(@"/Data/images/map.png", UriKind.RelativeOrAbsolute));
            imgMap.Height     = 16;
            imgMap.MouseDown += new MouseButtonEventHandler(imgMap_MouseDown);
            RenderOptions.SetBitmapScalingMode(imgMap, BitmapScalingMode.HighQuality);

            imgMap.Margin = new Thickness(0, 0, 5, 0);
            panelCoordinates.Children.Add(imgMap);

            TextBlock txtCoordinates = UICreator.CreateLink(this.Airport.Profile.Coordinates.ToString());

            ((Hyperlink)txtCoordinates.Inlines.FirstInline).Click += new RoutedEventHandler(PageAirport_Click);
            txtCoordinates.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
            panelCoordinates.Children.Add(txtCoordinates);

            lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1014"), panelCoordinates));
            //  lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1015"), UICreator.CreateTextBlock(new TextUnderscoreConverter().Convert(this.Airport.Profile.Size).ToString())));
            //   lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1021"), UICreator.CreateTextBlock(new TextUnderscoreConverter().Convert(this.Airport.Profile.Cargo).ToString())));

            WrapPanel panelSize = new WrapPanel();

            Image imgPassenger = new Image();

            imgPassenger.Source = new BitmapImage(new Uri(@"/Data/images/passenger.png", UriKind.RelativeOrAbsolute));
            imgPassenger.Height = 16;
            RenderOptions.SetBitmapScalingMode(imgPassenger, BitmapScalingMode.HighQuality);

            panelSize.Children.Add(imgPassenger);

            TextBlock txtPassengerSize = UICreator.CreateTextBlock(new TextUnderscoreConverter().Convert(this.Airport.Profile.Size).ToString());

            txtPassengerSize.Margin            = new Thickness(2, 0, 0, 0);
            txtPassengerSize.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;

            panelSize.Children.Add(txtPassengerSize);

            Image imgCargo = new Image();

            imgCargo.Margin = new Thickness(10, 0, 0, 0);
            imgCargo.Source = new BitmapImage(new Uri(@"/Data/images/cargo.png", UriKind.RelativeOrAbsolute));
            imgCargo.Height = 16;
            RenderOptions.SetBitmapScalingMode(imgCargo, BitmapScalingMode.HighQuality);

            panelSize.Children.Add(imgCargo);

            TextBlock txtCargoSize = UICreator.CreateTextBlock(new TextUnderscoreConverter().Convert(this.Airport.Profile.Cargo).ToString());

            txtCargoSize.Margin            = new Thickness(2, 0, 0, 0);
            txtCargoSize.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;

            panelSize.Children.Add(txtCargoSize);

            lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1015"), panelSize));

            TextBlock txtAirportIncome = UICreator.CreateTextBlock(new ValueCurrencyConverter().Convert(this.Airport.Income).ToString());

            txtAirportIncome.Foreground = new ValueIsMinusConverter().Convert(this.Airport.Income) as Brush;

            lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1023"), txtAirportIncome));

            WrapPanel panelTerminals = new WrapPanel();

            Image imgMapOverview = new Image();

            imgMapOverview.Source     = new BitmapImage(new Uri(@"/Data/images/info.png", UriKind.RelativeOrAbsolute));
            imgMapOverview.Height     = 16;
            imgMapOverview.MouseDown += new MouseButtonEventHandler(imgMapOverview_MouseDown);
            RenderOptions.SetBitmapScalingMode(imgMapOverview, BitmapScalingMode.HighQuality);

            imgMapOverview.Margin     = new Thickness(5, 0, 0, 0);
            imgMapOverview.Visibility = this.Airport.Profile.Map != null ? Visibility.Visible : System.Windows.Visibility.Collapsed;

            panelTerminals.Children.Add(UICreator.CreateTextBlock(string.Format("{0} ({1} {2})", this.Airport.Terminals.getNumberOfGates(), this.Airport.Terminals.getNumberOfAirportTerminals(), Translator.GetInstance().GetString("PageAirport", "1018"))));

            panelTerminals.Children.Add(imgMapOverview);

            lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1016"), panelTerminals));

            lbQuickInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirport", "1017"), UICreator.CreateTextBlock(this.Airport.Runways.Count.ToString())));

            return(scroller);
        }