Beispiel #1
0
        public Tiles128x128(Reader strm)
        {
            BlockList = new List <Tile128>();
            byte[]  mappingEntry = new byte[3];
            Tile128 currentBlock = new Tile128();
            int     tileIndex    = 0;

            while (strm.Read(mappingEntry, 0, mappingEntry.Length) > 0)
            {
                if (tileIndex >= currentBlock.Mapping.Length)
                {
                    tileIndex = 0;
                    BlockList.Add(currentBlock);
                    currentBlock = new Tile128();
                }
                mappingEntry[0] = (byte)(mappingEntry[0] - (mappingEntry[0] >> 6 << 6));
                currentBlock.Mapping[tileIndex].VisualPlane = (byte)(mappingEntry[0] >> 4);
                mappingEntry[0] = (byte)(mappingEntry[0] - (mappingEntry[0] >> 4 << 4));
                currentBlock.Mapping[tileIndex].Direction = (byte)(mappingEntry[0] >> 2);
                mappingEntry[0] = (byte)(mappingEntry[0] - (mappingEntry[0] >> 2 << 2));
                currentBlock.Mapping[tileIndex].Tile16x16      = (ushort)((mappingEntry[0] << 8) + mappingEntry[1]);
                currentBlock.Mapping[tileIndex].CollisionFlag0 = (byte)(mappingEntry[2] >> 4);
                currentBlock.Mapping[tileIndex].CollisionFlag1 = (byte)(mappingEntry[2] - (mappingEntry[2] >> 4 << 4));
                tileIndex++;
            }
            if (tileIndex >= currentBlock.Mapping.Length)
            {
                tileIndex = 0;
                BlockList.Add(currentBlock);
                currentBlock = new Tile128();
            }

            strm.Close();
        }
Beispiel #2
0
        public Tile128 Clone(int ChunkID)
        {
            Tile128 Copy = new Tile128();

            for (int i = 0; i < 64; i++)
            {
                Copy.Mapping[i].VisualPlane    = BlockList[ChunkID].Mapping[i].VisualPlane;
                Copy.Mapping[i].Direction      = BlockList[ChunkID].Mapping[i].Direction;
                Copy.Mapping[i].Tile16x16      = BlockList[ChunkID].Mapping[i].Tile16x16;
                Copy.Mapping[i].CollisionFlag0 = BlockList[ChunkID].Mapping[i].CollisionFlag0;
                Copy.Mapping[i].CollisionFlag1 = BlockList[ChunkID].Mapping[i].CollisionFlag1;
            }
            return(Copy);
        }