Esempio n. 1
0
        public static uint FindGlobalIDatPosition(int x, int y, MapChunk chunk, TileLayer layer)
        {
            WrapCordinates(ref x, ref y, layer);

            x /= chunk.Width;
            y /= chunk.Height;

            x /= layer.TileWidth;
            y /= layer.TileHeight;

            return(chunk.Data[y, x]);
        }
Esempio n. 2
0
        public static MapChunk FindChunkAtPosition(int x, int y, TileLayer layer)
        {
            MapChunk chunk = null;

            WrapCordinates(ref x, ref y, layer);

            foreach (var curChunk in layer.MapChunks)
            {
                if (x >= curChunk.WorldPosition.X &&
                    x <= curChunk.WorldPosition.X + curChunk.PixelWidth &&
                    y >= curChunk.WorldPosition.Y &&
                    y <= curChunk.WorldPosition.Y + curChunk.PixelHeight)
                {
                    chunk = curChunk;
                }
            }

            return(chunk);
        }