コード例 #1
0
        private void Click_Event(object sender, EventArgs e)
        {
            PictureBox x = sender as PictureBox;

            //Will check who's picture is supposed to be placed at the time of the event.
            if (x.Image != null)
            {
                return;
            }

            if (turn == PlayerTurn.None)
            {
                return;
            }

            if (turn == PlayerTurn.TurnP1)
            {
                x.Image = Player_1.Image;
            }
            else
            {
                x.Image = Player_2.Image;
            }

            //Check if winner
            winner = Get_the_Winner();

            if (winner == Winner.None)
            {
                //Chaning the turns.
                turn = (PlayerTurn.TurnP1 == turn) ? PlayerTurn.TurnP2 : PlayerTurn.TurnP1;
            }
            else
            {
                turn = PlayerTurn.None;
            }

            Show_Status();
        }