Пример #1
0
        /// <summary>
        /// Get a region of tiles from a layer
        /// </summary>
        /// <param name="region"> Tile region </param>
        /// <param name="layer"> Layer in context </param>
        /// <returns> A region based from zero extracted from the layer </returns>
        public WorldRegion GetLayerRegion(Rectangle region, int layer)
        {
            WorldLayer  layerIn   = GetLayer(layer);
            WorldRegion regionOut = new WorldRegion(region.Width, region.Height);

            for (int x = region.X, ox = 0; x < region.Right; x++, ox++)
            {
                for (int y = region.Y, oy = 0; y < region.Bottom; y++, oy++)
                {
                    if (!PointInWorld(x, y))
                    {
                        regionOut[ox, oy] = null;
                        continue;
                    }

                    WorldTile i = layerIn[x, y];

                    regionOut[ox, oy] = i == null ? null : i.Clone();
                }
            }

            return(regionOut);
        }