示例#1
0
        public void LoadStatics(TileMatrixData tileData, Map map)
        {
            // get data from the tile Matrix
            var groundData  = tileData.GetLandChunk(ChunkX, ChunkY);
            var staticsData = tileData.GetStaticChunk(ChunkX, ChunkY, out int staticLength);
            // load the ground data into the tiles.
            var groundDataIndex = 0;

            for (var i = 0; i < 64; i++)
            {
                var tileID = groundData[groundDataIndex++] + (groundData[groundDataIndex++] << 8);
                var tileZ  = (sbyte)groundData[groundDataIndex++];
                var 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
            var countStatics    = staticLength / 7;
            var staticDataIndex = 0;

            for (var i = 0; i < countStatics; i++)
            {
                var tileID = staticsData[staticDataIndex++] + (staticsData[staticDataIndex++] << 8);
                var x      = staticsData[staticDataIndex++];
                var y      = staticsData[staticDataIndex++];
                var tileZ  = (sbyte)staticsData[staticDataIndex++];
                var hue    = staticsData[staticDataIndex++] + (staticsData[staticDataIndex++] * 256);
                var item   = new StaticItem(tileID, hue, i, map);
                item.Position.Set((int)ChunkX * 8 + x, (int)ChunkY * 8 + y, tileZ);
            }
        }
示例#2
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);
                }
            }
        }
示例#3
0
 public void Close()
 {
     if (_tileData != null)
     {
         _tileData.Dispose();
         _tileData = null;
     }
 }
示例#4
0
 public CELLRecord(TileMatrixData tileData, LANDRecord land, uint gridX, uint gridY)
 {
     _tileData = tileData;
     _land     = land;
     GridX     = gridX;
     GridY     = gridY;
     //Load();
 }
示例#5
0
 public Map(uint index)
 {
     Index      = index;
     MapData    = new TileMatrixData(Index);
     TileHeight = MapData.ChunkHeight * 8;
     TileWidth  = MapData.ChunkWidth * 8;
     _chunks    = new MapChunk[c_CellsInMemorySpan * c_CellsInMemorySpan];
 }
示例#6
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;
                }
            }
        }
示例#7
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);
            }
        }
示例#8
0
        public void CreateSeasonalTileInfo()
        {
            m_StaticCounts = new Dictionary <int, int>();

            TileMatrixData tileData = new TileMatrixData(0);

            Map map = new Map(0);

            for (uint y = 0; y < tileData.ChunkHeight; y++)
            {
                Tracer.Info("Map Parser: row {0}.", y);
                for (uint x = 0; x < tileData.ChunkWidth; x++)
                {
                    ParseMapBlock(tileData, x, y);
                }
            }

            var items = from pair in m_StaticCounts
                        orderby pair.Value descending
                        select pair;

            using (FileStream file = new FileStream(@"AllTiles.txt", FileMode.Create))
            {
                StreamWriter stream = new StreamWriter(file);
                foreach (KeyValuePair <int, int> pair in items)
                {
                    ItemData itemData = TileData.ItemData[pair.Key];
                    if ((itemData.IsBackground || itemData.IsFoliage) && !itemData.IsWet && !itemData.IsSurface)
                    {
                        stream.WriteLine(string.Format("{0},{1} ; {2}", pair.Key, pair.Value, itemData.Name));
                    }
                }
                stream.Flush();
                file.Flush();
            }
        }
示例#9
0
 public LANDRecord(TileMatrixData tileData, uint gridX, uint gridY)
 {
     _tileData = tileData;
     GridX     = gridX;
     GridY     = gridY;
 }
示例#10
0
 public DataFile(uint map)
 {
     _tileData = new TileMatrixData(map);
     ReadRecords();
     PostProcessRecords();
 }
示例#11
0
 public void Close()
 {
     _tileData?.Dispose();
     _tileData = null;
 }