Example #1
0
        private void AddTile(MimTile tile, List <MimTile> layer)
        {
            short x         = tile.Layered.X;
            short y         = tile.Layered.Y;
            short textureId = tile.Layered.TextureID;

            if (x < MinX)
            {
                MinX = x;
            }
            if (x > MaxX)
            {
                MaxX = x;
            }
            if (y < MinY)
            {
                MinY = y;
            }
            if (y > MaxY)
            {
                MaxY = y;
            }
            if (textureId > MaxTextureId)
            {
                MaxTextureId = textureId;
            }

            layer.Add(tile);
        }
Example #2
0
        public byte[] ReadIndices(MimTile tile)
        {
            Exceptions.CheckArgumentNull(tile, "tile");

            byte[] result = new byte[16 * 16];

            _input.Seek(tile.Layered.GetPositionInTexture(), SeekOrigin.Begin);
            Stream input = tile.Layered.IsFullByteIndices ? _input : new HalfByteStream(_input);

            for (int i = 0; i < 16; i++)
            {
                input.Read(result, i * 16, 16);
                _input.Seek(AtlasWidth - 16, SeekOrigin.Current);
            }

            return(result);
        }
Example #3
0
        public override void Open()
        {
            Close();

            List <MimTile>[] layers = new List <MimTile> [8];

            while (!IOStream.IsEndOfStream())
            {
                MimTile tile = IOStream.ReadStruct <MimTile>();
                if (tile.IsEndOfFile())
                {
                    break;
                }

                List <MimTile> layer = layers.GetOrCreate(tile.Layered.LayerId, i => new List <MimTile>(4096));
                AddTile(tile, layer);
            }

            LayredTiles = layers.Where(l => l != null).Select(l => l.OrderByDescending(t => t.Layered.Z).ToArray()).ToArray();
        }