private void radioButton1_CheckedChanged(object sender, EventArgs e) { if (radioButton1.Checked == true) { m_BoardSize = eBoardSize.Small; } }
private void radioButton2_CheckedChanged(object sender, EventArgs e) { if (radioButton2.Checked == true) { m_BoardSize = eBoardSize.Medium; } }
private void initializeBoard(eBoardSize i_BoardSize) { byte rowSize = (byte)i_BoardSize; byte RedTeamInitialArea = (byte)(rowSize * ((rowSize - 2) / 2)); // Formula to calculate the range (0 - ...) for initializing Red team area byte BlackTeamInitialArea = (byte)(m_Spaces.Length - RedTeamInitialArea); // Formula to calculate the range (... - spaces.Length) for initializing Black team area byte rowIndex = 0; for (byte i = 0; i < m_Spaces.Length; i++) { m_Spaces[i] = new Space(); rowIndex = (byte)(i / rowSize); if (((i + rowIndex) % 2 == 1) && (i < RedTeamInitialArea)) { initializePieceInSpace(eTeam.Red, i); // Place pieces of Red team in relevant spaces } else if (((i + rowIndex) % 2 == 1) && (i >= BlackTeamInitialArea)) { initializePieceInSpace(eTeam.Black, i); // Place pieces of Black team in relevant spaces } else { m_Spaces[i].ClearSpace(); // Checkers does not use current space } } }
private void radioButton3_CheckedChanged(object sender, EventArgs e) { if (radioButton3.Checked == true) { m_BoardSize = eBoardSize.Large; } }
public void Run() { m_GameSettingForm = new GameSettingsForm(); m_GameSettingForm.ShowDialog(); m_BoardSize = m_GameSettingForm.BoardSize; initialCheckersGameForm(); m_CheckerGameForm.ShowDialog(); }
public GameBoard() { m_eNumOfRows = UserInterface.GetNumOfRows(); m_eNumOfCols = UserInterface.GetNumOfCols(); UserInterface.SetChosenBoardSize(Utils.NumOfRows(m_eNumOfRows), Utils.NumOfCols(m_eNumOfCols)); m_NumOfFreeCellsInCol = new int[(int)m_eNumOfCols]; initBoard(); }
public FormSettings() { m_BoardSize = eBoardSize.FourFour; m_ComputerDifficulty = eDifficulty.Easy; m_BoardRows = k_DefaultBoardRows; m_BoardColumns = k_DefaultBoardColumns; InitializeComponent(); textBoxSecondPlayer.Text = k_ComputerName; }
// converts this current move to a string public string ToString(eBoardSize i_BoardSize) { char UpCaseLetterFrom = (char)('A' + (this.From % (byte)i_BoardSize)), LowCaseLetterFrom = (char)('a' + (this.From / (byte)i_BoardSize)), UpCaseLetterTo = (char)('A' + (this.To % (byte)i_BoardSize)), LowCaseLetterTo = (char)('a' + (this.To / (byte)i_BoardSize)); return(string.Format("{0}{1}>{2}{3}", UpCaseLetterFrom, LowCaseLetterFrom, UpCaseLetterTo, LowCaseLetterTo)); // calculate back the string from the move }
private void boardSizeButton_Click(object i_sender, EventArgs i_e) { m_Choice++; m_Choice = m_Choice % k_NumOfBoardSizes; m_BoardSize = (eBoardSize)m_Choice; switch (m_BoardSize) { case eBoardSize.FourbyFour: m_boardSizeButton.Text = "4x4"; m_BoardCol = 4; m_BoardRow = 4; break; case eBoardSize.FourByFive: m_boardSizeButton.Text = "4x5"; m_BoardCol = 4; m_BoardRow = 5; break; case eBoardSize.FourBySix: m_boardSizeButton.Text = "4x6"; m_BoardCol = 4; m_BoardRow = 6; break; case eBoardSize.FiveByFour: m_boardSizeButton.Text = "5x4"; m_BoardCol = 5; m_BoardRow = 4; break; case eBoardSize.FiveBySix: m_boardSizeButton.Text = "5x6"; m_BoardCol = 5; m_BoardRow = 6; break; case eBoardSize.SixByFour: m_boardSizeButton.Text = "6x4"; m_BoardCol = 6; m_BoardRow = 4; break; case eBoardSize.SixByFive: m_boardSizeButton.Text = "6x5"; m_BoardCol = 6; m_BoardRow = 5; break; case eBoardSize.SixBySix: m_boardSizeButton.Text = "6x6"; m_BoardCol = 6; m_BoardRow = 6; break; } }
private void FormSettings_FormClosing(object i_Sender, FormClosingEventArgs i_EventArgs) { // Setting the default parameters if the exit button was pressed. if (!m_DoneButtonPressed) { m_BoardSize = eBoardSize.Size6; m_PlayerOneName = "Player 1"; m_PlayerTwoName = "Player 2"; m_IsComputer = true; } }
public Board(eBoardSize i_BoardSize) { // create board according to the size that the user chose. m_BoardSize = i_BoardSize; m_Board = new Cell[(int)i_BoardSize, (int)i_BoardSize]; for (int rowIndex = 0; rowIndex < (int)i_BoardSize; rowIndex++) { for (int colIndex = 0; colIndex < (int)i_BoardSize; colIndex++) { m_Board[rowIndex, colIndex] = new Cell(rowIndex, colIndex); } } }
private void radioSize_Changed(object i_Sender, EventArgs i_EventArgs) { if (radioButtonSize6.Checked) { m_BoardSize = eBoardSize.Size6; } else if (radioButtonSize8.Checked) { m_BoardSize = eBoardSize.Size8; } else { m_BoardSize = eBoardSize.Size10; } }
private void formClosing_Click(object sender, FormClosingEventArgs e) { if (m_BoardSize == eBoardSize.NOT_INITIAL) { m_BoardSize = eBoardSize.SIX_ON_SIX; } if (textBoxPlayerOne.Text == string.Empty) { textBoxPlayerOne.Text = k_DefaultPlayerOneName; } if (checkBoxPlayerTwo.Checked == true && textBoxPlayerTwo.Text == string.Empty) { textBoxPlayerTwo.Text = k_DefaultPlayerTwoName; } }
/* * Initializes the board by scanning a size and creating. */ private static void initBoard() { eBoardSize boardSize = getBoardSize(); switch (boardSize) { case eBoardSize.Six: m_Board = new Board(6); break; case eBoardSize.Eight: m_Board = new Board(8); break; } // If valid string, initialize player1 Player player1 = new Player(player1Name, player); while (opponentType != 1 || != 2) { checkInputType(opponentType); } if (opponentType == 1) { Console.WriteLine("Enter Player2 name"); string player2Name = Console.ReadLine(); checkInputType(player2Name); Player player2 = new Player(player2Name, player); } else if (opponentType == 2) { Player computer = new Player(pc, pc); } Console.WriteLine("Please enter board size (min 6 or 8)"); string boardSize = Console.ReadLine(); while (boardSize < 6) { checkInputType(boardSize); } Board board = new Board(boardSize); }
public void IncreaseBoardSize() { if (m_BoardSize == eBoardSize.Six) { m_BoardSize = eBoardSize.Eight; } else if (m_BoardSize == eBoardSize.Eight) { m_BoardSize = eBoardSize.Ten; } else if (m_BoardSize == eBoardSize.Ten) { m_BoardSize = eBoardSize.Twelve; } else if (m_BoardSize == eBoardSize.Twelve) { m_BoardSize = eBoardSize.Six; } }
public void NewGame() { FormSettings formSettings = new FormSettings(); formSettings.ShowDialog(); m_BoardSize = formSettings.BoardSize; m_PlayerOne = new Player(formSettings.PlayerOneName); m_PlayerTwo = new Player(formSettings.PlayerTwoName, formSettings.IsComputer); r_GameHandler.Init(m_PlayerOne, m_PlayerTwo, (byte)m_BoardSize); m_Tiles = new Tile[(byte)m_BoardSize, (byte)m_BoardSize]; if (m_FormGame == null) { m_FormGame = new FormGame(); initBoard(); m_FormGame.ShowDialog(); } }
private void Play_Button_Click(object sender, EventArgs e) { m_Player1Name = Player1Name_TextBox.Text; m_Player2Name = Player2Name_TextBox.Text; if (radioButton_6X6.Checked) { m_BoardSize = eBoardSize.Small; } else if (radioButton_8X8.Checked) { m_BoardSize = eBoardSize.Medium; } else if (radioButton_10X10.Checked) { m_BoardSize = eBoardSize.Large; } FormClosing -= FormTwoPlayers_FormClosing; Close(); }
private void buttonBoardSize_Click(object sender, EventArgs e) { m_BoardSizeClicks++; eBoardSize currentSize = (eBoardSize)(m_BoardSizeClicks % r_MaxBoardSizeOptions); switch (currentSize) { case eBoardSize.FourXFour: buttonBoardSize.Text = "4 x 4"; break; case eBoardSize.FourXFive: buttonBoardSize.Text = "4 x 5"; break; case eBoardSize.FourXSix: buttonBoardSize.Text = "4 x 6"; break; case eBoardSize.FiveXFour: buttonBoardSize.Text = "5 x 4"; break; case eBoardSize.FiveXSix: buttonBoardSize.Text = "5 x 6"; break; case eBoardSize.SixXFour: buttonBoardSize.Text = "6 x 4"; break; case eBoardSize.SixXFive: buttonBoardSize.Text = "6 x 5"; break; case eBoardSize.SixXSix: buttonBoardSize.Text = "6 x 6"; break; } }
private void button_Play_Click(object sender, EventArgs e) { //User input player name: m_Player1Name = Player1Name_TextBox.Text; //User input board size: if (radioButton_6X6.Checked) { m_BoardSize = eBoardSize.Small; } else if (radioButton_8X8.Checked) { m_BoardSize = eBoardSize.Medium; } else if (radioButton_10X10.Checked) { m_BoardSize = eBoardSize.Large; } //User input difficulty if (Easy_RadioButton.Checked) { m_Difficulty = eDifficulty.Easy; } else if (Medium_RadioButton.Checked) { m_Difficulty = eDifficulty.Medium; } else if (Hard_RadioButton.Checked) { m_Difficulty = eDifficulty.Hard; } FormClosing -= FormSinglePlayer_FormClosing; Close(); }
public static int NumOfCols(eBoardSize i_eNumOfCols) { return (int)i_eNumOfCols; }
private void GameSettings_Load(object sender, EventArgs e) { m_BoardSize = eBoardSize.Small; m_GameMode = eGameMode.PlayerVsPC; PlayerTwoName = "[Computer]"; }
public Board(eBoardSize i_BoardSize) { this.m_BoardSize = i_BoardSize; this.m_Spaces = new Space[(byte)Math.Pow((byte)i_BoardSize, 2)]; initializeBoard(i_BoardSize); }
public CheckersGameBoard(eBoardSize i_BoardSize) { r_BoardSize = i_BoardSize; r_BoardMatrix = new GameMatrix((int)r_BoardSize, (int)r_BoardSize); InitializePiecesOnBoard(); }
private void radioButtonSixOnSix_CheckedChanged(object sender, EventArgs e) { m_BoardSize = eBoardSize.SIX_ON_SIX; }
private void radioButtonEightOnEight_CheckedChanged(object sender, EventArgs e) { m_BoardSize = eBoardSize.EIGHT_ON_EIGHT; }
public Game(GameState i_State, eGameMode i_ChosenGameMode, eBoardSize i_ChosenBoardSize) { this.m_State = i_State; this.m_ChosenGameMode = i_ChosenGameMode; this.m_ChosenBoardSize = i_ChosenBoardSize; }
private void radioButton10x10_CheckedChanged(object sender, EventArgs e) { m_BoardSize = eBoardSize.TenOnTen; }
private void radioButtonTenOnTen_CheckedChanged(object sender, EventArgs e) { m_BoardSize = eBoardSize.TEN_ON_TEN; }
private void radioButton8x8_CheckedChanged(object sender, EventArgs e) { m_BoardSize = eBoardSize.EightOnEight; }
private void radioButton6x6_CheckedChanged(object sender, EventArgs e) { m_BoardSize = eBoardSize.SixOnSix; }
private void buttonBoardSize_Click(object sender, EventArgs e) { switch (m_BoardSize) { case eBoardSize.FourFour: buttonBoardSize.Text = "4 x 5"; m_BoardSize = eBoardSize.FourFive; m_BoardRows = 4; m_BoardColumns = 5; break; case eBoardSize.FourFive: buttonBoardSize.Text = "4 x 6"; m_BoardSize = eBoardSize.FourSix; m_BoardRows = 4; m_BoardColumns = 6; break; case eBoardSize.FourSix: buttonBoardSize.Text = "5 x 4"; m_BoardSize = eBoardSize.FiveFour; m_BoardRows = 5; m_BoardColumns = 4; break; case eBoardSize.FiveFour: buttonBoardSize.Text = "5 x 6"; m_BoardSize = eBoardSize.FiveSix; m_BoardRows = 5; m_BoardColumns = 6; break; case eBoardSize.FiveSix: buttonBoardSize.Text = "6 x 4"; m_BoardSize = eBoardSize.SixFour; m_BoardRows = 6; m_BoardColumns = 4; break; case eBoardSize.SixFour: buttonBoardSize.Text = "6 x 5"; m_BoardSize = eBoardSize.SixFive; m_BoardRows = 6; m_BoardColumns = 5; break; case eBoardSize.SixFive: buttonBoardSize.Text = "6 x 6"; m_BoardSize = eBoardSize.SixSix; m_BoardRows = 6; m_BoardColumns = 6; break; case eBoardSize.SixSix: default: buttonBoardSize.Text = "4 x 4"; m_BoardSize = eBoardSize.FourFour; m_BoardRows = 4; m_BoardColumns = 4; break; } }
public static int NumOfRows(eBoardSize i_eNumOfRows) { return (int)i_eNumOfRows; }
public CheckersGameBoard(eBoardSize i_BoardSize) { r_BoardSize = i_BoardSize; r_BoardMatrix = new GameMatrix((int)r_BoardSize, (int)r_BoardSize); InitializePiecesOnBoard(); }