Beispiel #1
0
        static void Main(string[] args)
        {
            bool save = false;

            GameBuilder builder = new GameBuilder();

            if (save)
            {
                builder.AddPlayer("Roger", "INFO");
                builder.AddPlayer("Bernard", "EII");
                builder.SetSize("Small");
                builder.UseDefaultFrequencies();
                Game game = builder.Build();
                game.Save("save01.dat");
            }
            else
            {
                Game game = builder.LoadGame("save01.dat");
                //Console.Write(game.Map);
                Console.WriteLine(game.CurrentPlayer);
                Console.WriteLine(game.CurrentPlayer.Cities[0]);
                game.NextTurn();
                Console.WriteLine(game.CurrentPlayer);
                Console.WriteLine(game.CurrentPlayer.Cities[0]);
                game.Save("save01.dat");
            }
        }
 /// <summary>
 /// Adds a player to the game builder if the control is visible, that is, if
 /// there is enough players to make use of this control.
 /// </summary>
 /// <param name="builder"></param>
 /// <param name="player"></param>
 /// <param name="name"></param>
 /// <param name="civilization"></param>
 private void AddPlayerToGameBuilder(GameBuilder builder, StackPanel player, TextBox name, ComboBox civilization)
 {
     if (player.Visibility == Visibility.Visible)
     {
         builder.AddPlayer(name.Text, civilization.Text);
     }
 }
        /// <summary>
        /// Adds players to the game builder and navigate to the next page.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NextButtonClick(object sender, RoutedEventArgs e)
        {
            var builder = new GameBuilder();
            AddPlayerToGameBuilder(builder, _playerOne, _playerOneName, _playerOneCivilization);
            AddPlayerToGameBuilder(builder, _playerTwo, _playerTwoName, _playerTwoCivilization);
            AddPlayerToGameBuilder(builder, _playerThree, _playerThreeName, _playerThreeCivilization);
            AddPlayerToGameBuilder(builder, _playerFour, _playerFourName, _playerFourCivilization);

            NavigationService.Navigate(new ChooseMapSizePage(builder));
        }
        public ChooseMapSizePage(GameBuilder builder)
        {
            _builder = builder;

            InitializeComponent();
        }