/// <summary>
        /// Based on a passed tile index, create a Tile by looking up which TileSet it belongs to, assign the proper TilSet texture,
        /// and find the bounds of the rectangle that encompasses the correct tile texture within the total tileset texture.
        /// </summary>
        /// <param name="tileIndex">Index of the tile (GID) within the map file</param>
        /// <param name="tileSets">Enumerable list of tilesets used to find out which tileset a tile belongs to</param>
        /// <param name="tileLayerType"></param>
        /// <returns></returns>
        private Tile CreateTile(int tileIndex, IEnumerable<TileSetContent> tileSets)
        {
            if (tileSets == null) throw new ArgumentNullException("tileSets");

            Tile tile = new Tile();

            // we don't want to look up tiles with ID 0 in tile sets because Tiled Map Editor treats ID 0 as an empty tile
            if (tileIndex > Tile.EmptyTileID)
            {
                Texture tileSetTexture = null;
                Rectangle source = new Rectangle();

                foreach (TileSetContent tileSet in tileSets)
                {
                    if (tileIndex - tileSet.FirstGID < tileSet.Tiles.Count)
                    {
                        tileSetTexture = tileSet.Texture;
                        source = tileSet.Tiles[tileIndex - tileSet.FirstGID].SourceTextureBounds;
                        break;
                    }
                }

                tile = new Tile(tileSetTexture, source, TileWidth, TileHeight);
            }

            return tile;
        }
 /// <summary>
 /// Adds a single tile to the layer's collection of tiles.
 /// </summary>
 /// <param name="tile"></param>
 public void AddTile(Tile tile)
 {
     tiles.Add(tile);
 }