Ejemplo n.º 1
0
        private void lbl20_Click(object sender, EventArgs e)
        {
            if (grid[2, 0] == 0)
            {
                playModel.userPlay(2, 0, grid, playModel.userMark);
                this.gameDecision(NormalPlay.checkStatus(grid, playModel.userMark), false);
                this.refreshVal();

                playModel.pcPlay(grid, playModel.pcMark);
                this.gameDecision(NormalPlay.checkStatus(grid, playModel.pcMark), true);
                this.refreshVal();
            }
        }
Ejemplo n.º 2
0
 private void labelClick(int X, int Y)
 {
     if (isPlayer1)
     {
         playModel.userPlay(X, Y, grid, playModel.user1Mark);
         this.gameDecision(NormalPlay.checkStatus(grid, playModel.user1Mark), false);
         this.refreshVal();
         isPlayer1          = false;
         lbluser2.ForeColor = Color.White;
         lbluser1.ForeColor = Color.DimGray;
     }
     else
     {
         playModel.userPlay(X, Y, grid, playModel.user2Mark);
         this.gameDecision(NormalPlay.checkStatus(grid, playModel.user2Mark), true);
         this.refreshVal();
         isPlayer1          = true;
         lbluser2.ForeColor = Color.DimGray;
         lbluser1.ForeColor = Color.White;
     }
 }
Ejemplo n.º 3
0
        public void refreshVal()
        {
            if (lbl00.InvokeRequired)
            {
                refreshValCallback d = new refreshValCallback(refreshVal);
                this.Invoke(d);
            }
            else
            {
                if (grid[0, 0] == 0)
                {
                    lbl00.Text = "";
                }
                else if (grid[0, 0] == 1)
                {
                    lbl00.Text = "X";
                }
                else if (grid[0, 0] == -1)
                {
                    lbl00.Text = "O";
                }
                if (grid[0, 1] == 0)
                {
                    lbl01.Text = "";
                }
                else if (grid[0, 1] == 1)
                {
                    lbl01.Text = "X";
                }
                else if (grid[0, 1] == -1)
                {
                    lbl01.Text = "O";
                }
                if (grid[0, 2] == 0)
                {
                    lbl02.Text = "";
                }
                else if (grid[0, 2] == 1)
                {
                    lbl02.Text = "X";
                }
                else if (grid[0, 2] == -1)
                {
                    lbl02.Text = "O";
                }
                if (grid[1, 0] == 0)
                {
                    lbl10.Text = "";
                }
                else if (grid[1, 0] == 1)
                {
                    lbl10.Text = "X";
                }
                else if (grid[1, 0] == -1)
                {
                    lbl10.Text = "O";
                }
                if (grid[1, 1] == 0)
                {
                    lbl11.Text = "";
                }
                else if (grid[1, 1] == 1)
                {
                    lbl11.Text = "X";
                }
                else if (grid[1, 1] == -1)
                {
                    lbl11.Text = "O";
                }
                if (grid[1, 2] == 0)
                {
                    lbl12.Text = "";
                }
                else if (grid[1, 2] == 1)
                {
                    lbl12.Text = "X";
                }
                else if (grid[1, 2] == -1)
                {
                    lbl12.Text = "O";
                }
                if (grid[2, 0] == 0)
                {
                    lbl20.Text = "";
                }
                else if (grid[2, 0] == 1)
                {
                    lbl20.Text = "X";
                }
                else if (grid[2, 0] == -1)
                {
                    lbl20.Text = "O";
                }
                if (grid[2, 1] == 0)
                {
                    lbl21.Text = "";
                }
                else if (grid[2, 1] == 1)
                {
                    lbl21.Text = "X";
                }
                else if (grid[2, 1] == -1)
                {
                    lbl21.Text = "O";
                }
                if (grid[2, 2] == 0)
                {
                    lbl22.Text = "";
                }
                else if (grid[2, 2] == 1)
                {
                    lbl22.Text = "X";
                }
                else if (grid[2, 2] == -1)
                {
                    lbl22.Text = "O";
                }

                if (myTurn)
                {
                    lbluser2.ForeColor = Color.DimGray;
                    lbluser1.ForeColor = Color.White;
                }
                else
                {
                    lbluser2.ForeColor = Color.White;
                    lbluser1.ForeColor = Color.DimGray;
                }

                //check if one of them won
                //user1=false, user2=true
                this.gameDecision(NormalPlay.checkStatus(grid, playModel.user1Mark), false);
                this.gameDecision(NormalPlay.checkStatus(grid, playModel.user2Mark), true);
            }
        }