本文整理汇总了C#中System.IO.BinaryWriter.WriteArray方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryWriter.WriteArray方法的具体用法?C# BinaryWriter.WriteArray怎么用?C# BinaryWriter.WriteArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.BinaryWriter
的用法示例。
在下文中一共展示了BinaryWriter.WriteArray方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Write
public void Write(BinaryWriter bw)
{
bw.Write(AdjoiningRoom);
Normal.Write16(bw);
bw.WriteArray(Vertices, x => x.Write16(bw));
}
示例2: Write_TR5
private void Write_TR5()
{
if (EngineVersion != Engine.TR5)
{
ConvertRoomsToTR5();
}
writer.Write((uint) 0x00345254);
writer.Write((ushort) Textures.Length);
writer.Write((ushort) 0);
writer.Write((ushort) 0);
byte[] buf;
using (var ms = new MemoryStream())
{
using (var bw = new BinaryWriter(ms))
bw.WriteArray(Textures, x => x.Write(bw));
buf = ms.ToArray();
}
writer.Write((uint) buf.Length); // uncompSize
var bufComp = Helper.Encompress(buf);
writer.Write((uint) bufComp.Length); // compSize
writer.Write(bufComp);
using (var ms = new MemoryStream())
{
using (var bw = new BinaryWriter(ms))
bw.WriteArray(Texture16, x => x.Write(bw));
buf = ms.ToArray();
}
writer.Write((uint) buf.Length); // uncompSize
bufComp = Helper.Encompress(buf);
writer.Write((uint) bufComp.Length); // compSize
writer.Write(bufComp);
using (var ms = new MemoryStream())
{
using (var bw = new BinaryWriter(ms))
bw.WriteArray(Textures.Skip(Textures.Length - 3).Take(3), x => x.Write(bw));
buf = ms.ToArray();
}
writer.Write((uint) buf.Length); // uncompSize
bufComp = Helper.Encompress(buf);
writer.Write((uint) bufComp.Length); // compSize
writer.Write(bufComp);
writer.Write((ushort) LaraType);
writer.Write((ushort) WeatherType);
writer.Write(new byte[28]);
var levelStartPos = writer.BaseStream.Position;
writer.Write((uint)0); // uncompSize
writer.Write((uint)0); // compSize
writer.Write((uint) 0); // unused
writer.Write((ushort) Rooms.Length);
writer.WriteArray(Rooms, x => x.Write(writer, Engine.TR5));
writer.Write((uint) FloorData.Length);
writer.WriteUInt16Array(FloorData);
WriteMeshData();
writer.Write((uint) Animations.Length);
writer.WriteArray(Animations, x => x.Write(writer, Engine.TR4));
writer.Write((uint) StateChanges.Length);
writer.WriteArray(StateChanges, x => x.Write(writer));
writer.Write((uint) AnimDispatches.Length);
writer.WriteArray(AnimDispatches, x => x.Write(writer));
writer.Write((uint) AnimCommands.Length);
writer.WriteInt16Array(AnimCommands);
writer.Write((uint) MeshTreeData.Length);
writer.WriteUInt32Array(MeshTreeData);
WriteFrameMoveableData();
writer.Write((uint) StaticMeshes.Length);
writer.WriteArray(StaticMeshes, x => x.Write(writer));
writer.Write((sbyte) 'S');
writer.Write((sbyte) 'P');
writer.Write((sbyte) 'R');
writer.Write((sbyte) '\0');
writer.Write((uint) SpriteTextures.Length);
writer.WriteArray(SpriteTextures, x => x.Write(writer, Engine.TR4));
writer.Write((uint) SpriteSequences.Length);
writer.WriteArray(SpriteSequences, x => x.Write(writer));
writer.Write((uint) Cameras.Length);
//.........这里部分代码省略.........
示例3: Write_TR4
private void Write_TR4()
{
writer.Write((uint)(WriteIsDemoOrUb ? 0x63345254 : 0x00345254));
writer.Write((ushort)Textures.Length);
writer.Write((ushort)0);
writer.Write((ushort)0);
byte[] buf;
using (var ms = new MemoryStream())
{
using (var bw = new BinaryWriter(ms))
bw.WriteArray(Textures, x => x.Write(bw));
buf = ms.ToArray();
}
writer.Write((uint)buf.Length); // uncompSize
var bufComp = Helper.Encompress(buf);
writer.Write((uint)bufComp.Length); // compSize
writer.Write(bufComp);
using (var ms = new MemoryStream())
{
using (var bw = new BinaryWriter(ms))
bw.WriteArray(Texture16, x => x.Write(bw));
buf = ms.ToArray();
}
writer.Write((uint)buf.Length); // uncompSize
bufComp = Helper.Encompress(buf);
writer.Write((uint)bufComp.Length); // compSize
writer.Write(bufComp);
using (var ms = new MemoryStream())
{
using (var bw = new BinaryWriter(ms))
bw.WriteArray(Textures.Skip(Textures.Length - 2).Take(2), x => x.Write(bw));
buf = ms.ToArray();
}
writer.Write((uint)buf.Length); // uncompSize
bufComp = Helper.Encompress(buf);
writer.Write((uint)bufComp.Length); // compSize
writer.Write(bufComp);
// Here be dragons
using (var ms = new MemoryStream())
{
using (var bw = new BinaryWriter(ms))
{
bw.Write((uint)0); // unused
bw.Write((ushort)Rooms.Length);
bw.WriteArray(Rooms, x => x.Write(bw, Engine.TR4));
bw.Write((uint)FloorData.Length);
bw.WriteUInt16Array(FloorData);
var tmpw = writer;
writer = bw;
WriteMeshData();
writer = tmpw;
bw.Write((uint)Animations.Length);
bw.WriteArray(Animations, x => x.Write(bw, Engine.TR4));
bw.Write((uint)StateChanges.Length);
bw.WriteArray(StateChanges, x => x.Write(bw));
bw.Write((uint)AnimDispatches.Length);
bw.WriteArray(AnimDispatches, x => x.Write(bw));
bw.Write((uint)AnimCommands.Length);
bw.WriteInt16Array(AnimCommands);
bw.Write((uint)MeshTreeData.Length);
bw.WriteUInt32Array(MeshTreeData);
tmpw = writer;
writer = bw;
WriteFrameMoveableData();
writer = tmpw;
bw.Write((uint)StaticMeshes.Length);
bw.WriteArray(StaticMeshes, x => x.Write(bw));
bw.Write((sbyte)'S');
bw.Write((sbyte)'P');
bw.Write((sbyte)'R');
bw.Write((uint)SpriteTextures.Length);
bw.WriteArray(SpriteTextures, x => x.Write(bw, Engine.TR4));
bw.Write((uint)SpriteSequences.Length);
bw.WriteArray(SpriteSequences, x => x.Write(bw));
bw.Write((uint)Cameras.Length);
bw.WriteArray(Cameras, x => x.Write(bw));
bw.Write((uint)FlybyCameras.Length);
bw.WriteArray(FlybyCameras, x => x.Write(bw));
//.........这里部分代码省略.........
示例4: saveFileFunc
void saveFileFunc(Stream stream)
{
var gStream = new DeflateStream(stream, CompressionLevel.Optimal);
BinaryWriter writer = new BinaryWriter(gStream);
uint width;
uint height;
uint startDozerBotX;
uint startDozerBotY;
byte[,] bytes = GetBytes(out width, out height, out startDozerBotX, out startDozerBotY);
if (bytes == null)
return;
byte[] resultBytes = new byte[bytes.Length];
Buffer.BlockCopy(bytes, 0, resultBytes, 0, resultBytes.Length);
bytes = null;
writer.Write(SilverBotAndGuy.Version.Current);
writer.Write(width);
writer.Write(height);
writer.WriteArray(solutions.ToArray());
bool silverBot = textBox1.Text.Contains('/');
writer.Write(silverBot);
if (silverBot)
{
string[] split = textBox1.Text.Replace("\r", "").Split('\n');
int posOfSilverBotX = 0;
int posOfSilverBotY = 0;
while (posOfSilverBotY < height)
{
int indexOf = split[posOfSilverBotY].IndexOf('/');
if (indexOf != -1)
{
posOfSilverBotX = indexOf;
break;
}
posOfSilverBotY++;
}
writer.Write(posOfSilverBotX);
writer.Write(posOfSilverBotY);
}
writer.Write(startDozerBotX);
writer.Write(startDozerBotY);
writer.Write(resultBytes, 0, resultBytes.Length);
writer.Flush();
writer.Close();
}
示例5: Write
public void Write(BinaryWriter bw, bool psx = false)
{
bw.Write((uint) GameVersion);
bw.WriteStringASCII(CopyrightInfo, 256);
bw.Write((ushort) 128); // gameflowSize
bw.Write(FirstOption);
bw.Write(TitleReplace);
bw.Write(OnDeathDemoMode);
bw.Write(OnDeathInGame);
bw.Write(DemoTime);
bw.Write(OnDemoInterrupt);
bw.Write(OnDemoEnd);
bw.Write(new byte[36]); // Unknown2
bw.Write(NumLevels);
bw.Write(NumChapterScreens);
bw.Write(NumTitles);
bw.Write(NumFMVs);
bw.Write(NumCutscenes);
bw.Write(NumDemoLevels);
bw.Write(TitleSoundID);
bw.Write(SingleLevel);
bw.Write(new byte[32]); // Unknown3
bw.Write((ushort) Flags);
bw.Write(new byte[6]); // Unknown4
bw.Write(XORbyte);
bw.Write((byte) Language);
bw.Write(SecretSoundID);
bw.Write(new byte[4]); // Unknown5
var xor = Flags.HasFlag(TOMBPCFlags.UseEncryption) ? XORbyte : (byte)0;
bw.WriteStringArray(LevelDisplayNames, xor);
bw.WriteStringArray(ChapterScreens, xor);
bw.WriteStringArray(TitleFileNames, xor);
bw.WriteStringArray(FMVFileNames, xor);
bw.WriteStringArray(LevelFileNames, xor);
bw.WriteStringArray(CutSceneFileNames, xor);
var scrOffsets = new ushort[NumLevels + 1];
ushort totalOffset = 0;
for (var i = 0; i <= NumLevels; i++)
{
scrOffsets[i] = totalOffset;
totalOffset += (ushort)(Script[i].Length * 2);
}
bw.WriteUInt16Array(scrOffsets);
bw.Write((ushort)0);
var nbPos = bw.BaseStream.Position;
foreach (var a in Script.Resize(NumLevels + 1))
bw.WriteUInt16Array(a);
var tp = bw.BaseStream.Position;
bw.BaseStream.Position = nbPos - 2;
bw.Write((ushort)(tp - nbPos));
bw.BaseStream.Position = tp;
bw.WriteUInt16Array(DemoLevelIDs);
if (psx)
{
bw.WriteArray(PSXFMVInfo.Resize(NumFMVs), x => x.Write(bw));
}
bw.Write((ushort) GameStrings1.Length);
bw.WriteStringArray(GameStrings1, xor);
bw.WriteStringArray(GameStrings2, xor);
foreach (var puz in Puzzles.Resize(4))
bw.WriteStringArray(puz.Resize(NumLevels), xor);
foreach (var puz in Pickups.Resize(2))
bw.WriteStringArray(puz.Resize(NumLevels), xor);
foreach (var puz in Keys.Resize(4))
bw.WriteStringArray(puz.Resize(NumLevels), xor);
}
示例6: SaveMccv
private void SaveMccv(BinaryWriter writer, int basePosition, ref Mcnk header)
{
if (HasMccv == false)
{
header.Mccv = 0;
header.Flags &= ~0x40u;
return;
}
header.Flags |= 0x40;
var colors = mShadingFloats.Select(v =>
{
uint b = (byte)Math.Max(Math.Min((v.Z / 2.0f) * 255.0f, 255), 0);
uint g = (byte)Math.Max(Math.Min((v.Y / 2.0f) * 255.0f, 255), 0);
uint r = (byte)Math.Max(Math.Min((v.X / 2.0f) * 255.0f, 255), 0);
return 0x7F000000 | (b << 16) | (g << 8) | r;
}).ToArray();
header.Mccv = (int)writer.BaseStream.Position - basePosition;
writer.Write(0x4D434356);
writer.Write(145 * 4);
writer.WriteArray(colors.ToArray());
}
示例7: SaveLayers
private void SaveLayers(BinaryWriter writer, int basePosition, ref Mcnk header)
{
header.NumLayers = mLayers.Length;
if(header.NumLayers == 0)
{
header.Mcly = 0;
return;
}
header.Mcly = (int) writer.BaseStream.Position - basePosition;
writer.Write(0x4D434C59);
writer.Write(mLayers.Length * SizeCache<Mcly>.Size);
writer.WriteArray(mLayers);
}
示例8: SaveNormals
private void SaveNormals(BinaryWriter writer, int basePosition, ref Mcnk header)
{
header.Mcnr = (int)writer.BaseStream.Position - basePosition;
var normals =
Vertices.SelectMany(v => new[] { (sbyte)(v.Normal.X * -127.0f), (sbyte)(v.Normal.Y * -127.0f), (sbyte)(v.Normal.Z * 127.0f) });
writer.Write(0x4D434E52);
writer.Write(145 * 3);
writer.WriteArray(normals.ToArray());
writer.Write(mNormalExtra);
}
示例9: SaveHeights
private void SaveHeights(BinaryWriter writer, int basePosition, ref Mcnk header)
{
header.Mcvt = (int) writer.BaseStream.Position - basePosition;
var minPos = Vertices.Min(v => v.Position.Z);
header.Position.Z = minPos;
var heights = Vertices.Select(v => v.Position.Z - minPos);
writer.Write(0x4D435654);
writer.Write(145 * 4);
writer.WriteArray(heights.ToArray());
}
示例10: Save
public override void Save()
{
if (mWasChanged == false)
return;
var hasMccv = mChunks.Any(c => c != null && c.HasMccv);
if(hasMccv)
{
var wdt = WorldFrame.Instance.MapManager.CurrentWdt;
if((wdt.Flags & 2) == 0)
{
wdt.Flags |= 2;
wdt.Save(WorldFrame.Instance.MapManager.Continent);
}
}
using (var strm = FileManager.Instance.GetOutputStream(string.Format(@"World\Maps\{0}\{0}_{1}_{2}.adt", Continent, IndexX, IndexY)))
{
var writer = new BinaryWriter(strm);
writer.Write(0x4D564552); // MVER
writer.Write(4);
writer.Write(18);
writer.Write(0x4D484452);
writer.Write(SizeCache<Mhdr>.Size);
var headerStart = writer.BaseStream.Position;
writer.Write(mHeader);
var header = mHeader;
var chunkInfos = mChunkOffsets.ToArray();
writer.Write(0x4D43494E);
writer.Write(256 * SizeCache<Mcin>.Size);
var mcinStart = writer.BaseStream.Position;
writer.WriteArray(chunkInfos);
header.ofsMcin = (int)(mcinStart - 28);
if (mDoodadDefs != null && mDoodadDefs.Length > 0)
{
header.ofsMddf = (int)(writer.BaseStream.Position - 20);
writer.Write(0x4D444446);
writer.Write(mDoodadDefs.Length * SizeCache<Mddf>.Size);
writer.WriteArray(mDoodadDefs);
}
else
header.ofsMddf = 0;
SaveChunk(0x4D544558, writer, out header.ofsMtex);
SaveChunk(0x4D4D4458, writer, out header.ofsMmdx);
SaveChunk(0x4D4D4944, writer, out header.ofsMmid);
SaveChunk(0x4D574D4F, writer, out header.ofsMwmo);
SaveChunk(0x4D574944, writer, out header.ofsMwid);
SaveChunk(0x4D4F4446, writer, out header.ofsModf);
SaveChunk(0x4D48324F, writer, out header.ofsMh2o);
for (var i = 0; i < mChunks.Count; ++i)
{
var startPos = writer.BaseStream.Position;
mChunks[i].SaveChunk(writer);
var endPos = writer.BaseStream.Position;
chunkInfos[i].OfsMcnk = (int)startPos;
chunkInfos[i].SizeMcnk = (int)(endPos - startPos);
//chunkInfos[i].Flags = chunkInfos[i].AsyncId = 0;
}
SaveChunk(0x4D545846, writer, out header.ofsMtxf);
SaveChunk(0x4D46424F, writer, out header.ofsMfbo);
writer.BaseStream.Position = headerStart;
writer.Write(header);
writer.BaseStream.Position = mcinStart;
writer.WriteArray(chunkInfos);
}
}
示例11: DrawWin
public void DrawWin (PlayerAvatar player)
{
if (outS != null)
{
byte[][] array = outS.GetBytes();
BinaryWriter writer = new BinaryWriter(File.OpenWrite(outSolution));
writer.WriteArray(array);
writer.Flush();
writer.Close();
}
if (File.Exists("Levels/" + (currentLevel + 1) +".sbalvl"))
LoadNextLevel();
else
{
won = true;
}
}
示例12: CreateEmptyWdt
private void CreateEmptyWdt(BinaryWriter writer, string continent)
{
writer.Write(0x4D564552); // MVER
writer.Write(4);
writer.Write(18);
writer.Write(0x4D484452);
writer.Write(0x4D504844);
writer.Write(32);
writer.Write(Flags);
writer.Write(0);
writer.WriteArray(new[] {0, 0, 0, 0, 0, 0});
writer.Write(0x4D41494E);
writer.Write(4096 * 8);
for (var i = 0; i < 64; ++i)
{
for(var j = 0; j < 64; ++j)
{
if(FileManager.Instance.Provider.Exists(string.Format(@"World\Maps\{0}\{0}_{1}_{2}.adt", continent, j, i)))
{
writer.Write(1);
writer.Write(0);
}
else
{
writer.Write(0);
writer.Write(0);
}
}
}
}