コード例 #1
0
        private void ChooseAction(Button b)
        {
            Random rand = new Random();
            int    num  = rand.Next(1, 4);

            switch (playTurn)
            {
            case PlayTurn.player1:
                b.Content             = FindResource("Round" + num);
                playTurn              = PlayTurn.player2;
                textBlock_winner.Text = ("Player 2's turn");
                break;

            case PlayTurn.player2:
                b.Content             = FindResource("Cross" + num);
                playTurn              = PlayTurn.player1;
                textBlock_winner.Text = ("Player 1's turn");
                break;

            default:
                break;
            }
        }
コード例 #2
0
        private void button_reset_Click(object sender, RoutedEventArgs e)
        {
            for (int a = 0; a < 3; a++)
            {
                for (int b = 0; b < 3; b++)
                {
                    playfield1[a, b] = false;
                    playfield2[a, b] = false;
                }
            }

            playTurn = PlayTurn.player1;

            textBlock_winner.Text       = ("Player 1's turn");
            textBlock_winner.Foreground = Brushes.Black;

            innerGrid.IsEnabled = true;

            button_1_1.IsEnabled = true;
            button_1_1.Content   = null;
            button_1_2.IsEnabled = true;
            button_1_2.Content   = null;
            button_1_3.IsEnabled = true;
            button_1_3.Content   = null;
            button_2_1.IsEnabled = true;
            button_2_1.Content   = null;
            button_2_2.IsEnabled = true;
            button_2_2.Content   = null;
            button_2_3.IsEnabled = true;
            button_2_3.Content   = null;
            button_3_1.IsEnabled = true;
            button_3_1.Content   = null;
            button_3_2.IsEnabled = true;
            button_3_2.Content   = null;
            button_3_3.IsEnabled = true;
            button_3_3.Content   = null;
        }