本文整理汇总了C#中System.IO.BinaryWriter.WriteUInt16Array方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryWriter.WriteUInt16Array方法的具体用法?C# BinaryWriter.WriteUInt16Array怎么用?C# BinaryWriter.WriteUInt16Array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.BinaryWriter
的用法示例。
在下文中一共展示了BinaryWriter.WriteUInt16Array方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Write
public void Write(BinaryWriter bw)
{
for (var i = 0; i < Pixels.Length; i++)
{
bw.WriteUInt16Array(Pixels[i]);
}
}
示例2: 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));
//.........这里部分代码省略.........
示例3: Write
public void Write(BinaryWriter bw)
{
bw.Write(NumGenericStrings);
bw.Write(NumPSXStrings);
bw.Write(NumPCStrings);
bw.Write(GenericStrings.Sum(x => Encoding.ASCII.GetByteCount(x) + 1));
bw.Write(PSXStrings.Sum(x => Encoding.ASCII.GetByteCount(x) + 1));
bw.Write(PCStrings.Sum(x => Encoding.ASCII.GetByteCount(x) + 1));
var stringOTpos = bw.BaseStream.Position;
var stringOffsetTable = new ushort[StringTable.Length];
var stringStart = bw.BaseStream.Position + StringTable.Length * sizeof (ushort);
bw.BaseStream.Position = stringStart;
for (var i = 0; i < StringTable.Length; i++)
{
stringOffsetTable[i] = (ushort) (bw.BaseStream.Position - stringStart);
bw.WriteStringASCII(StringTable[i]);
bw.Write((byte)0x00); // null-terminator
}
bw.BaseStream.Position = stringOTpos;
bw.WriteUInt16Array(stringOffsetTable);
}
示例4: 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);
}