public void PlaceShip(UInt16 startrow, UInt16 startcol, BattleShip ship, Orientation orient) { //check if the object overlaps some other if (startrow < 0 || startrow >= m_rows) { throw new Exception(); } if (startcol < 0 || startcol >= m_cols) { throw new Exception(); } m_scratchPad.Clear(); m_ScratchStartRow = startrow; m_ScratchStartCol = startcol; m_ScratchBSRows = ship.Rows; m_ScratchBSCols = ship.Cols; m_scratchOrientation = orient; GridEnumerator itor = GetEnumerator(); //this loop could throw exception foreach (Cell one in this) { m_scratchPad.Add(one); } foreach (Cell one in m_scratchPad) { one.Val = m_shapes.Count + 1; ship.AddCell(); } m_shapes.Add(ship); }
public GridEnumerator GetEnumerator() { return(GridEnumerator.GetEnumerator(this, m_ScratchStartRow, m_ScratchStartCol, m_ScratchBSRows, m_ScratchBSCols, m_scratchOrientation)); }