private void CreateShapes(LevelData data, Tile[,,] grid) { foreach (double shapesKey in data.shapes.Keys) { Shape newShape = tileFactory.CreateShape(); foreach (AttachableTile tile in data.shapes[shapesKey] .Select(shape => grid[(int)shape.X, (int)shape.Y, (int)data.gridSize.Z - 1 - (int)shape.Z] as AttachableTile) ) { newShape.AddTile(tile); if (tile != null) { tile.Shape = newShape; } } _shapes.Add((int)shapesKey, newShape); } }