Ejemplo n.º 1
0
 public MainWindow()
 {
     mainBox = new MainBox();
     WindowStartupLocation = WindowStartupLocation.CenterScreen;
     if (mainBox.CustomShow() == System.Windows.Forms.DialogResult.Yes)
     {
         Console.WriteLine(mainBox.GetPlayerName(1));
         InitializeComponent();
         InitializeGame();
         InitializeBoard(false);
     }
     else
     {
         Close();
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Function called when a new game begins
        /// A new game can begin when a player click on "New Game" button
        /// or when a player loads a XML file that contains data from another game
        /// </summary>
        /// <param name="g">g = default if "new game" button is clicked</param>
        public void ProperlyNewGame(GameParameter g = default(GameParameter))
        {
            for (int i = 0; i < NB_ROW; i++)
            {
                for (int j = 0; j < NB_COL; j++)
                {
                    // TODO HERE CHANGE LBL BACKGROUND COLOR + RESET a ZERO LES CASES ET REMETTRES LES 4 TOKENS DU DEBUT
                    Label lbl = rules.GetLabel(tokenGrid, i, j);
                    tokenGrid.Children.Remove(lbl);
                }
            }

            btnUndo.IsEnabled = false;
            timerP1.Stop();
            timerP2.Stop();
            board = null;

            //New game = default GameParameter struct (no data loaded)
            if (g.Equals(default(GameParameter)))
            {
                mainBox = new MainBox();
                mainBox.ResetPlayerTokenPath();
                if (mainBox.CustomShow() == System.Windows.Forms.DialogResult.Yes)
                {
                    Console.WriteLine(mainBox.GetPlayerName(1));
                    InitializeComponent();
                    InitializeGame();
                    InitializeBoard(false);
                }
                else
                {
                    Close();
                }
            }
            else
            //data loaded from XML file
            {
                MessageBox.Show("Game loaded : \nPlayer1 : " + g.p1Name + ", Score : " + g.p1Score + "\nPlayer2 : " + g.p2Name + ", Score : " + g.p2Score);
                InitializeGame(g);
                InitializeBoard(true);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// CustomShow method. Show the form
 /// </summary>
 /// <returns>Return dialogResult (Play or not)</returns>
 public DialogResult CustomShow()
 {
     mainBox = new MainBox();
     mainBox.ShowDialog();
     return(result);
 }