Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
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);

            }
        }