예제 #1
0
 /// <summary>
 /// Adds a new grid to the streamed tile map
 /// </summary>
 /// <param name="mapPart"></param>
 public void Add(TileMapPart mapPart)
 {
     if (!maps.Contains(mapPart))
     {
         maps.Add(mapPart);
     }
 }
예제 #2
0
        /// <summary>
        /// Create the StreamedTileMap from the generated grids
        /// </summary>
        /// <param name="maps">Current grid with all it's surrounding grids</param>
        /// <param name="suroundingGrids">Ids of all surrounding grids</param>
        /// <param name="gridsPerRow">Number grids per row</param>
        /// <param name="streamedTileMap">A reference to a streamedTileMap</param>
        private void CreateTileMapParts(Tile[][] maps, List <ObjectTile>[] objectTiles, int[] suroundingGrids, int gridsPerRow, StreamedTileMap streamedTileMap)
        {
            //create TileMapPart
            for (int i = 0; i < maps.Length; i++)
            {
                int gridId = suroundingGrids[i];

                int gridRow;
                int gridColumn;
                TileMathHelper.ToPosition(gridId, gridsPerRow, out gridRow, out gridColumn);

                gridRow    = TileMathHelper.FixTileIndex(gridRow, gridsPerRow);
                gridColumn = TileMathHelper.FixTileIndex(gridColumn, gridsPerRow);

                TileMapPart part = new TileMapPart(gridId, maps[i], null, objectTiles[i].ToArray(), gridColumn, gridRow);
                streamedTileMap.Add(part);
            }
        }