Exemplo n.º 1
0
        private void startGame(object sender, RoutedEventArgs e)
        {
            DateTime now  = new DateTime();
            long     date = now.Year + now.Month + now.Day + now.Hour + now.Minute;

            Board board = new Board();

            players spelers = new players()
            {
                player1 = textbox_player_1.Text, player2 = textbox_player_2.Text
            };

            savedGame game = new savedGame
            {
                GameName = date.ToString(),
                Status   = board.Generate(),
                Players  = spelers,
                Score1   = "0",
                Score2   = "0",
                Turn     = spelers.player1
            };

            MainWindow mainWindow = new MainWindow("new", game);

            mainWindow.Show();
            this.Close();
        }
Exemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="action">The action. 'new' for a new game</param>
 /// <param name="game">A game object</param>
 public MainWindow(string action, savedGame game)
 {
     InitializeComponent();
     if (action == "new")
     {
         grid = new MemoryGrid(GameGrid, cols, rows);
         Board board = new Board();
         List <List <List <int> > > values = new List <List <List <int> > >();
         values = board.Generate();
         AddImages(values);
     }
     else
     {
         grid = new MemoryGrid(GameGrid, cols, rows);
         AddImages(game.Status);
     }
     label_player1.Content = game.Players.player1 + " : " + game.Score1;
     label_player2.Content = game.Players.player2 + " : " + game.Score2;
     label_turn.Content    = game.Turn + " is aan de beurt";
 }
Exemplo n.º 3
0
        public void LoadGame(object sender, RoutedEventArgs e)
        {
            List <List <List <int> > > freshBoard = new List <List <List <int> > >()
            {
                new List <List <int> >()
                {
                    new List <int>()
                    {
                        1, 0
                    },
                    new List <int>()
                    {
                        1, 0
                    },
                    new List <int>()
                    {
                        2, 0
                    },
                    new List <int>()
                    {
                        2, 0
                    }
                },

                new List <List <int> >()
                {
                    new List <int>()
                    {
                        3, 0
                    },
                    new List <int>()
                    {
                        3, 0
                    },
                    new List <int>()
                    {
                        4, 0
                    },
                    new List <int>()
                    {
                        4, 0
                    }
                },

                new List <List <int> >()
                {
                    new List <int>()
                    {
                        5, 0
                    },
                    new List <int>()
                    {
                        5, 0
                    },
                    new List <int>()
                    {
                        6, 1
                    },
                    new List <int>()
                    {
                        6, 0
                    }
                },

                new List <List <int> >()
                {
                    new List <int>()
                    {
                        7, 0
                    },
                    new List <int>()
                    {
                        7, 0
                    },
                    new List <int>()
                    {
                        8, 0
                    },
                    new List <int>()
                    {
                        8, 0
                    }
                }
            };

            Board board = new Board();
            List <List <List <int> > > values = new List <List <List <int> > >();

            values = board.Random();

            savedGame test = new savedGame
            {
                GameName = "Testing",
                Status   = values,
                Players  = new players()
                {
                    player1 = "Pieter", player2 = "Joost"
                },
                Score1 = "1000",
                Score2 = "2000",
                Turn   = "Pieter"
            };

            MainWindow laden = new MainWindow("load", test);

            this.Close();
            laden.Show();
        }