/// <summary> /// on construction, create the new matrix and initialize memebers /// </summary> /// <param name="i_columns"></param> /// <param name="i_rows"></param> public Board(int i_columns, int i_rows, BoardViewForm i_BoardView) { r_numOfRows = i_rows; r_numOfColumns = i_columns; m_slotsMatrix = new eSlotState[i_columns, i_rows]; m_BoardView = i_BoardView; EmptyBoard(); m_BoardView.UpdateBoard(m_slotsMatrix); }
// add piece to column , // return false if column is full public bool AddPieceToColumn(int i_column, eSlotState i_pieceType) { bool success = true; if (IsColumnFree(i_column)) { int targetRow = r_numOfRows - 1; while (m_slotsMatrix[i_column, targetRow] != eSlotState.Empty) { targetRow--; } m_slotsMatrix[i_column, targetRow] = i_pieceType; m_BoardView.UpdateBoard(m_slotsMatrix); } else { success = false; } return(success); }