Exemple #1
0
 /// <summary>
 /// Redémarre le jeu
 /// </summary>
 private void RestartGame()
 {
     logicBoard.fillBoard();
     loadFromLogicBoard();
     whitePlayer.reset();
     blackPlayer.reset();
     playerTurn = 0;
     mainTimer.Start();
 }
Exemple #2
0
        public MainWindow()
        {
            InitializeComponent();
            lbIABlack.ItemsSource = tournamentPlayers;
            lbIAWhite.ItemsSource = tournamentPlayers;
            mainTimer             = new DispatcherTimer();
            mainTimer.Interval    = new TimeSpan(0, 0, 0, 0, 50); // chaque 100ms
            // Chargement du board
            logicBoard = new LogicBoard();
            logicBoard.fillBoard();
            loadFromLogicBoard();
            DataContext = this;
            mainTimer   = new DispatcherTimer {
                Interval = new TimeSpan(0, 0, 1)
            };

            //Timer principal pour les 2 horloges
            mainTimer.Tick += (sender, args) =>
            {
                whitePlayer.tick();
                blackPlayer.tick();

                NotifyPropertyChanged("WhiteTimeLeft");
                NotifyPropertyChanged("BlackTimeLeft");

                if (IsGameFinished())
                {
                    NotifyPropertyChanged("BlackScore");
                    NotifyPropertyChanged("WhiteScore");
                    NotifyPropertyChanged("CurrentTurn");
                    EndGame();
                }
            };
            mainTimer.Start();
            RestartGame();

            MenuFindIA_Click(null, null);
        }