private void BoardSquareSelected(object sender, MouseButtonEventArgs e)
        {
            System.Windows.Controls.Image item = (System.Windows.Controls.Image)sender;
            ItemPlacedEventArgs           args = new ItemPlacedEventArgs();

            string[] itemName    = item.Name.Split('_');
            string   coordinates = itemName[itemName.Length - 1];
            int      x           = Convert.ToInt32(coordinates[0].ToString());
            int      y           = Convert.ToInt32(coordinates[1].ToString());

            if (board.board[x, y] == null)
            {
                args.x = x;
                args.y = y;
                ItemPlaced(this, args);
            }
        }
Beispiel #2
0
 void ItemPlaced(object sender, ItemPlacedEventArgs e)
 {
     if (AI1.active && !pieceSelected)
     {
         mainBoard.SetPiece(AI1.selectedPiece, e.x, e.y);
         AI1.selectedPiece = null;
         player1Slot.RemovePiece();
         if (mainBoard.board.CheckWin())
         {
             MessageBox.Show("player 1 wins");
         }
     }
     else if (AI2.active && !pieceSelected)
     {
         mainBoard.SetPiece(AI2.selectedPiece, e.x, e.y);
         AI2.selectedPiece = null;
         player2Slot.RemovePiece();
         if (mainBoard.board.CheckWin())
         {
             MessageBox.Show("player 2 wins");
         }
     }
 }