private List <int> GetGameShapeRowIndexes(GameShape gameShape) { List <int> rowIndexes = new List <int>(); //for each block of the GameShape-- store row index foreach (Block block in gameShape.GetBlocks()) { if (!rowIndexes.Contains(block.GetY())) { rowIndexes.Add(block.GetY()); } } return(rowIndexes); }
// Author: DeAngelo public void PlaceShape(GameShape toPlace) { //TODO:: prevent duplicate placing //for each block of the GameShape-- place onto grid + add to list foreach (Block block in toPlace.GetBlocks()) { if (grid[block.GetX()][block.GetY()] != null) { throw new DuplicateNameException("PlaceShape:: block cannot be placed, position (" + block.GetX() + ", " + block.GetY() + ") already occupied"); } Block blockCopy = block.Copy(); grid[block.GetX()][block.GetY()] = blockCopy; blocks.Add(blockCopy); } toPlace.GameShapePlaced(); }