private void cellButton_Click(object sender, RoutedEventArgs e) { Player currentPlayer = Player.GetPlayerFromTurn(turn, player1, player2); if (currentPlayer.Mode == Player.Modes.Human) { int senderIndex = BoardUniformGrid.Children.IndexOf(sender as UIElement); Tuple <int, int> move = Game.ToIndex2D(senderIndex); HandleNextMove(move); } }
void RenderBoard(byte[,] board) { if (animationPaused) { animationPending = true; return; } bool changesOccurred = false; for (int index = 0; index < 64; index++) { Tuple <int, int> index2D = Game.ToIndex2D(index); int x = index2D.Item1; int y = index2D.Item2; byte value = board[x, y]; if (value == Game.White || value == Game.Black || value == Game.Empty) { Button cellButton = BoardUniformGrid.Children[index] as Button; cellButton.Tag = Game.ValueAsString(value); changesOccurred = true; } } if (changesOccurred) { animationPaused = true; animationTimer.Start(); } Player currentPlayer = Player.GetPlayerFromTurn(turn, player1, player2); if (currentPlayer == player1) { Player1Display.IsEnabled = true; Player2Display.IsEnabled = false; } else { Player1Display.IsEnabled = false; Player2Display.IsEnabled = true; } Player1Score.Text = Game.GetScore(board, Game.White).ToString(); Player2Score.Text = Game.GetScore(board, Game.Black).ToString(); //Trace.WriteLine(Game.GenerateString(board)); }