Example #1
0
        private void GridBC_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (tf == false) //chua ai win
            {
                int   row, col;
                Point a = LayToaDo(sender, e);
                row = Convert.ToInt32(a.Y);
                col = Convert.ToInt32(a.X);
                if (check[row, col] == 0) //o chua danh // X = 1 // O = 2
                {
                    try
                    {
                        if (player2.GetClick() == true)
                        {
                            player2.SetClick(false);
                            player1.SetClick(true);
                        }
                        else
                        {
                            player2.SetClick(true);
                            player1.SetClick(false);
                        }
                        switch (state)
                        {
                        case 1:
                        {
                            playPvP(a, row, col, player1, player2);
                            break;
                        }

                        case 2:
                        {
                            playPvB(a, row, col, player1, player2);
                            break;
                        }
                        }
                    }
                    catch (Exception) { }
                }
                //check here
                tf = isWin(row, col);
            }
        }