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); } } }
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; }
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"); } }
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"); } }
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); }
public Cell(int x, int y, RoundButton button) { this.X = x; this.Y = y; this.Button = button; }