Пример #1
0
            public ChunkData(TileChunk chunk)
            {
                int chunkSize = chunk.TileMap.ChunkSize;

                TileData = new List <uint> [chunkSize][];
                for (int x = 0; x < chunkSize; x++)
                {
                    TileData[x] = new List <uint> [chunkSize];
                    for (int y = 0; y < chunkSize; y++)
                    {
                        TileData[x][y] = new List <uint>();
                        for (int tile = 0; tile < chunk.TileTemplates[x][y].Tiles.Count; tile++)
                        {
                            uint tileID = chunk.TileTemplates[x][y].Tiles.Array[tile].TileID;
                            TileData[x][y].Add(tileID);
                        }
                    }
                }
            }
Пример #2
0
        public void PlaceTile(Point tilePoint, uint tileID)
        {
            Point chunkPos = Snap(tilePoint, ChunkSize);

            for (int i = 0; i < Chunks.Count; i++)
            {
                TileChunk chunk = Chunks[i];
                if (chunk.Position == chunkPos)
                {
                    Point    chunkTilePos = chunk.ToLocalPoint(tilePoint);
                    TileSpot t            = chunk.TileTemplates[chunkTilePos.X][chunkTilePos.Y];
                    t.AddTile(tileID);
                }
                else
                {
                    NewChunk(chunkPos);
                    PlaceTile(tilePoint, tileID);
                }
            }
        }
Пример #3
0
 public TileSpot(TileChunk chunk, Point position)
 {
     Position = position;
     Chunk    = chunk;
     TileMap  = chunk.TileMap;
 }