Exemple #1
0
        public void LoadStatics(TileMatrixData tileData, Map map)
        {
            // get data from the tile Matrix
            byte[] groundData = tileData.GetLandChunk(ChunkX, ChunkY);
            int staticLength;
            byte[] staticsData = tileData.GetStaticChunk(ChunkX, ChunkY, out staticLength);

            // load the ground data into the tiles.
            int groundDataIndex = 0;
            for (int i = 0; i < 64; i++)
            {
                int tileID = groundData[groundDataIndex++] + (groundData[groundDataIndex++] << 8);
                int tileZ = (sbyte)groundData[groundDataIndex++];

                Ground ground = new Ground(tileID, map);
                ground.Position.Set((int)ChunkX * 8 + i % 8, (int)ChunkY * 8 + (i / 8), tileZ);
            }

            // load the statics data into the tiles
            int countStatics = staticLength / 7;
            int staticDataIndex = 0;
            for (int i = 0; i < countStatics; i++)
            {
                int iTileID = staticsData[staticDataIndex++] + (staticsData[staticDataIndex++] << 8);
                int iX = staticsData[staticDataIndex++];
                int iY = staticsData[staticDataIndex++];
                int iTileZ = (sbyte)staticsData[staticDataIndex++];
                int hue = staticsData[staticDataIndex++] + (staticsData[staticDataIndex++] * 256);

                StaticItem item = new StaticItem(iTileID, hue, i, map);
                item.Position.Set((int)ChunkX * 8 + iX, (int)ChunkY * 8 + iY, iTileZ);
            }
        }
Exemple #2
0
        private static sbyte[] m_Zs = new sbyte[64]; // shared between all instances of MiniMapChunk.

        public MiniMapChunk(uint x, uint y, TileMatrixData tileData)
        {
            X = x;
            Y = y;
            Colors = new uint[64];

            // get data from the tile Matrix
            byte[] groundData = tileData.GetLandChunk(x, y);
            int staticLength;
            byte[] staticsData = tileData.GetStaticChunk(x, y, out staticLength);

            // get the ground colors
            int groundDataIndex = 0;
            for (int i = 0; i < 64; i++)
            {
                Colors[i] = RadarColorData.Colors[groundData[groundDataIndex++] + (groundData[groundDataIndex++] << 8)];
                m_Zs[i]= (sbyte)groundData[groundDataIndex++];
            }

            // get the static colors
            int countStatics = staticLength / 7;
            int staticDataIndex = 0;
            for (int i = 0; i < countStatics; i++)
            {
                int itemID = staticsData[staticDataIndex++] + (staticsData[staticDataIndex++] << 8);
                int tile = staticsData[staticDataIndex++] + staticsData[staticDataIndex++] * 8;
                sbyte z = (sbyte)staticsData[staticDataIndex++];
                int hue = staticsData[staticDataIndex++] + (staticsData[staticDataIndex++] * 256); // is this used?

                ItemData data = TileData.ItemData[itemID];
                int iz = z + data.Height + (data.IsRoof || data.IsSurface ? 1 : 0);

                if ((x * 8 + (tile % 8) == 1480) && (y * 8 + (tile / 8) == 1608))
                {
                    if (iz > m_Zs[tile])
                    {
                        Colors[tile] = RadarColorData.Colors[itemID + 0x4000];
                        m_Zs[tile] = (sbyte)iz;
                    }
                }

                if (iz > m_Zs[tile])
                {
                    Colors[tile] = RadarColorData.Colors[itemID + 0x4000];
                    m_Zs[tile] = (sbyte)iz;
                }
            }
        }
Exemple #3
0
        private void ParseMapBlock(TileMatrixData tileData, uint x, uint y)
        {
            byte[] groundData = tileData.GetLandChunk(x, y);
            int staticLength;
            byte[] staticsData = tileData.GetStaticChunk(x, y, out staticLength);

            // load the statics data
            int countStatics = staticLength / 7;
            int staticDataIndex = 0;
            for (int i = 0; i < countStatics; i++)
            {
                int iTileID = staticsData[staticDataIndex++] + (staticsData[staticDataIndex++] << 8);
                int iX = staticsData[staticDataIndex++];
                int iY = staticsData[staticDataIndex++];
                int iTileZ = (sbyte)staticsData[staticDataIndex++];
                int hue = staticsData[staticDataIndex++] + (staticsData[staticDataIndex++] * 256);

                if (m_StaticCounts.ContainsKey(iTileID))
                    m_StaticCounts[iTileID]++;
                else
                    m_StaticCounts.Add(iTileID, 1);
            }
        }