|
|
发表于 2026-3-28 22:17:52
|
显示全部楼层
理论上是能转换的 不过有点费脑细胞 你自己分析
盛大2的有12字节,14字节,36字节,主要区别在于 序号和索引的扩展,占用字节更多
下面是常用的14字节map文件
var offset = 0;
Width = BitConverter.ToInt16(_bytes, offset);//宽
offset += 2;
Height = BitConverter.ToInt16(_bytes, offset);//高
MapCells = new CellInfo[Width, Height];
offset = 52;//头文件
for (var x = 0; x < Width; x++)
for (var y = 0; y < Height; y++)
{//14字节
MapCells[x, y] = new CellInfo();//1个坐标
MapCells[x, y].BackImage = BitConverter.ToInt16(_bytes, offset);//tiles序号,2字节,最高位0和1代表是否有路障
offset += 2;
MapCells[x, y].MiddleImage = BitConverter.ToInt16(_bytes, offset);//smtiles序号,2字节(
offset += 2;
MapCells[x, y].FrontImage = BitConverter.ToInt16(_bytes, offset);//objects序号,2字节
offset += 2;
MapCells[x, y].DoorIndex = (byte)(_bytes[offset++] & 0x7F);//门索引,1字节
MapCells[x, y].DoorOffset = _bytes[offset++];//门,1字节(0-127)
MapCells[x, y].FrontAnimationFrame = _bytes[offset++];//动画,1字节
MapCells[x, y].FrontAnimationTick = _bytes[offset++];//动画,1字节
MapCells[x, y].FrontIndex = (short)(_bytes[offset++] );//object索引,1字节
MapCells[x, y].Light = _bytes[offset++];//光照,1字节
MapCells[x, y].BackIndex = (short)(_bytes[offset++] );//tiles索引,1字节
MapCells[x, y].MiddleIndex = (short)(_bytes[offset++] );//smtiles索引,1字节
}
传奇3
byte flag = 0;
var offset = 20;
var Attribute = BitConverter.ToInt16(_bytes, offset);
Width = BitConverter.ToInt16(_bytes, offset += 2);
Height = BitConverter.ToInt16(_bytes, offset += 2);
offset = 28;
MapCells = new CellInfo[Width, Height];
for (var x = 0; x < Width; x++)
for (var y = 0; y < Height; y++)
MapCells[x, y] = new CellInfo();
for (var x = 0; x < Width / 2; x++)
for (var y = 0; y < Height / 2; y++)
{
for (var i = 0; i < 4; i++)
{
MapCells[x * 2 + i % 2, y * 2 + i / 2].BackIndex = (short)(_bytes[offset] != 255 ? _bytes[offset] + 200 : -1);
MapCells[x * 2 + i % 2, y * 2 + i / 2].BackImage = BitConverter.ToUInt16(_bytes, offset + 1) + 1;
}
offset += 3;
}
offset = 28 + 3 * (Width / 2 + Width % 2) * (Height / 2);
for (var x = 0; x < Width; x++)
for (var y = 0; y < Height; y++)
{
flag = _bytes[offset++];
MapCells[x, y].MiddleAnimationFrame = _bytes[offset++];
MapCells[x, y].FrontAnimationFrame = _bytes[offset] == 255 ? (byte)0 : _bytes[offset];
MapCells[x, y].FrontAnimationFrame &= 0x8F;
offset++;
MapCells[x, y].MiddleAnimationTick = 0;
MapCells[x, y].FrontAnimationTick = 0;
MapCells[x, y].FrontIndex = (short)(_bytes[offset] != 255 ? _bytes[offset] + 200 : -1);
offset++;
MapCells[x, y].MiddleIndex = (short)(_bytes[offset] != 255 ? _bytes[offset] + 200 : -1);
offset++;
MapCells[x, y].MiddleImage = (ushort)(BitConverter.ToUInt16(_bytes, offset) + 1);
offset += 2;
MapCells[x, y].FrontImage = (ushort)(BitConverter.ToUInt16(_bytes, offset) + 1);
if (MapCells[x, y].FrontImage == 1 && MapCells[x, y].FrontIndex == 200)
MapCells[x, y].FrontIndex = -1;
offset += 2;
offset += 3;//mir3 maps dont have doors so dont bother reading the info
MapCells[x, y].Light = (byte)(_bytes[offset] & 0x0F);
offset += 2;
if ((flag & 0x01) != 1) MapCells[x, y].BackImage |= 0x20000000;
if ((flag & 0x02) != 2) MapCells[x, y].FrontImage = (ushort)((UInt16)MapCells[x, y].FrontImage | 0x8000);
if (MapCells[x, y].Light >= 100 && MapCells[x, y].Light <= 119)
MapCells[x, y].FishingCell = true;
else
MapCells[x, y].Light *= 2;//expand general mir3 lighting as default range is small. Might break new colour lights.
}
} |
|