コード例 #1
0
        private void roundButton_Click(object sender, EventArgs e)
        {
            RoundButton roundButton = sender as RoundButton;

            Cell cell = board.GetLowestCell(roundButton);

            if (!cell.IsPlaced)
            {
                if (PlayerTurn == 1)
                {
                    cell.PlaceRed(PlayerTurn);
                    //PlayerTurn = 2;
                }
                else if (PlayerTurn == 2)
                {
                    cell.PlaceYellow(PlayerTurn);
                    //PlayerTurn = 1;
                }
                // Would you guys rather have the PlayerTurn assignments in the if or in a ternary like this?
                PlayerTurn = PlayerTurn == 1 ? 2 : 1;
                piecesPlaced++;
                CheckForWin(cell);
                if (!GameWon && !GameDraw)
                {
                    roundButton_MouseEnter(sender, e);
                }
            }
        }
コード例 #2
0
ファイル: Cell.cs プロジェクト: jsadowyj0/Final_ConnectFour
 public Cell(int x, int y, RoundButton button, bool isPlaced, int playerNumber)
 {
     this.X            = x;
     this.Y            = y;
     this.Button       = button;
     this.IsPlaced     = isPlaced;
     this.PlayerNumber = playerNumber;
 }
コード例 #3
0
        private void roundButton_MouseLeave(object sender, EventArgs e)
        {
            RoundButton roundButton = sender as RoundButton;

            Cell cell = board.GetLowestCell(roundButton);

            if (!cell.IsPlaced)
            {
                cell.Button.ChangeHoverColor("Default");
            }
        }
コード例 #4
0
        private void roundButton_MouseEnter(object sender, EventArgs e)
        {
            RoundButton roundButton = sender as RoundButton;

            Cell cell = board.GetLowestCell(roundButton);

            if (!cell.IsPlaced)
            {
                cell.Button.ChangeHoverColor(PlayerTurn == 1 ? "Red" : "Yellow");
            }
        }
コード例 #5
0
        public Cell GetLowestCell(RoundButton roundButton)
        {
            Cell cell       = roundButton.GetCell(this);
            int  coordinate = rows - 1;

            while (coordinate >= 0)
            {
                if (!this.GetCell(coordinate, cell.Y).IsPlaced)
                {
                    return(this.GetCell(coordinate, cell.Y));
                }
                coordinate--;
            }

            return(cell);
        }
コード例 #6
0
ファイル: Cell.cs プロジェクト: jsadowyj0/Final_ConnectFour
 public Cell(int x, int y, RoundButton button)
 {
     this.X      = x;
     this.Y      = y;
     this.Button = button;
 }