示例#1
0
        static void ReadMap(PrimitiveReader reader)
        {
            uint separator = reader.ReadUInt32();

            if (separator != 0xFFFFFF9D)
            {
                throw new InvalidDataException();
            }
            if (minorVersion >= 18)
            {
                int cameraY = reader.ReadInt32();
                int cameraX = reader.ReadInt32();
            }
            if (minorVersion >= 21)
            {
                AiMapType mapAi = (AiMapType)reader.ReadInt32();
            }
            uint mapWidth  = reader.ReadUInt32();
            uint mapHeight = reader.ReadUInt32();

            TerrainElement[] mapData = new TerrainElement[(int)mapWidth * (int)mapHeight];
            for (int i = 0; i < mapData.Length; i++)
            {
                TerrainElement element;
                element.TerrainId = reader.ReadUInt8();
                element.Elevation = reader.ReadUInt8();
                element.Unknown   = reader.ReadUInt8();
                mapData[i]        = element;
            }
            //System.Diagnostics.Debugger.Break();
        }
示例#2
0
 public void WriteData(BinaryWriter writer)
 {
     writer.Write(Width);
     writer.Write(Length);
     for (int i = 0; i < mapData.Length; i++)
     {
         TerrainElement element = mapData[i];
         writer.Write(element.TerrainId);
         writer.Write(element.Elevation);
         writer.Write(element.Unknown);
     }
 }
示例#3
0
        public static Map ReadFrom(PrimitiveReader reader)
        {
            Map map = new Map();

            map.Width  = reader.ReadUInt32();
            map.Length = reader.ReadUInt32();
            int size = (int)map.Width * (int)map.Length;

            TerrainElement[] mapData = new TerrainElement[size];
            for (int i = 0; i < mapData.Length; i++)
            {
                TerrainElement element;
                element.TerrainId = reader.ReadUInt8();
                element.Elevation = reader.ReadUInt8();
                element.Unknown   = reader.ReadUInt8();
                mapData[i]        = element;
            }
            map.mapData = mapData;
            return(map);
        }