示例#1
0
 private void NextTurn()
 {
     turn = !turn;
     turnCount++;
     if (TicTac.CheckWin(array, out winner) == true)
     {
         if (winner == "X")
         {
             Win.Play();
             winP1++;
             labelCount1.Text = Convert.ToString(winP1);
         }
         else
         {
             Lose.Play();
             winP2++;
             labelCount2.Text = Convert.ToString(winP2);
         }
         MessageBox.Show("" + winner + " WIN", "Victory", MessageBoxButtons.OK);
         NewGame();
     }
     if (turnCount == 9)
     {
         DrawSound.Play();
         MessageBox.Show("DRAW", "Draw", MessageBoxButtons.OK);
         draw++;
         labelCountD.Text = Convert.ToString(draw);
         NewGame();
     }
 }
示例#2
0
 private void NewGame()
 {
     TicTac.ClearArray(ref array);
     ClearSheet();
     turn      = true;
     turnCount = 0;
 }
示例#3
0
        private void btnTicTac_Click(object sender, EventArgs e)
        {
            TicTac ticTacToe = new TicTac();

            this.Hide();
            ticTacToe.Show();
        }
示例#4
0
 private void ButtonPress(int i, int j)
 {
     if (array[i, j] == 0)
     {
         Write.Play();
         Draw(turn, i, j);
         array[i, j] = TicTac.SetValue(turn);
         NextTurn();
     }
 }
示例#5
0
 private void Normal()
 {
     if (turnCount > 0)
     {
         if (TicTac.CheckAlmost(array, out x, out y) == true)
         {
             Draw(turn, x, y);
             array[x, y] = TicTac.SetValue(turn);
             NextTurn();
         }
         else
         {
             RandomMove();
         }
     }
 }
示例#6
0
 private void RandomMove()
 {
     if (turnCount > 0)
     {
         r      = new Random();
         button = r.Next(1, 9);
         TicTac.ButtonToArray(button, out x, out y);
         while (array[x, y] != 0)
         {
             button = r.Next(1, 9);
             TicTac.ButtonToArray(button, out x, out y);
         }
         Draw(turn, x, y);
         array[x, y] = TicTac.SetValue(turn);
         NextTurn();
     }
 }
示例#7
0
 private void Impossible()
 {
     if (turnCount > 0)
     {
         if (TicTac.CheckAlmost(array, out x, out y) == true)
         {
             ButtonPress(x, y);
         }
         else
         {
             if (TicTac.CheckTrap(array, turnCount, out button) == true)
             {
                 TicTac.ButtonToArray(button, out x, out y);
                 ButtonPress(x, y);
             }
             else
             {
                 if (array[1, 1] == 0)
                 {
                     ButtonPress(1, 1);
                 }
                 else
                 {
                     button = TicTac.RandomCorner(array);
                     if (button != 0)
                     {
                         TicTac.ButtonToArray(button, out x, out y);
                         ButtonPress(x, y);
                     }
                     else
                     {
                         RandomMove();
                     }
                 }
             }
         }
     }
 }
示例#8
0
 private void btnTicTac_Click(object sender, EventArgs e)
 {
     TicTac ticTacToe = new TicTac();
     this.Hide();
     ticTacToe.Show();
 }