本文整理汇总了C#中System.IO.BinaryWriter.WriteByteString方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryWriter.WriteByteString方法的具体用法?C# BinaryWriter.WriteByteString怎么用?C# BinaryWriter.WriteByteString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.BinaryWriter
的用法示例。
在下文中一共展示了BinaryWriter.WriteByteString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Save
/// <summary>
/// Saves the file to the specified stream.
/// </summary>
/// <param name="stream">The stream to save to.</param>
public override void Save(Stream stream)
{
BinaryWriter writer = new BinaryWriter(stream, Encoding.GetEncoding("EUC-KR"));
writer.Write(BLOCK_COUNT);
long[] offsets = new long[BLOCK_COUNT];
for (int i = 0; i < BLOCK_COUNT; i++) {
writer.Write(i);
writer.Write(0);
}
offsets[0] = stream.Position;
writer.Write((int)Type);
writer.Write(Width);
writer.Write(Height);
writer.Write(GridCount);
writer.Write(GridSize);
writer.Write(StartPosition.X);
writer.Write(StartPosition.Y);
for (int x = 0; x < Width; x++) {
for (int y = 0; y < Height; y++) {
writer.Write(Positions[x, y].IsUsed);
writer.Write(Positions[x, y].Position);
}
}
offsets[1] = stream.Position;
writer.Write(SpawnPoints.Count);
SpawnPoints.ForEach(spawnPoint => {
writer.Write(spawnPoint.Position);
writer.WriteByteString(spawnPoint.Name);
});
offsets[2] = stream.Position;
writer.Write(Textures.Count);
Textures.ForEach(texture => {
writer.WriteByteString(texture);
});
offsets[3] = stream.Position;
writer.Write(Tiles.Count);
Tiles.ForEach(tile => {
writer.Write(tile.Layer1);
writer.Write(tile.Layer2);
writer.Write(tile.Offset1);
writer.Write(tile.Offset2);
writer.Write(tile.BlendingEnabled ? 1 : 0);
writer.Write((int)tile.Rotation);
writer.Write(tile.TileType);
});
offsets[4] = stream.Position;
writer.WriteByteString(Name);
writer.Write(IsUnderground ? 1 : 0);
writer.WriteByteString(BackgroundMusicFilePath);
writer.WriteByteString(SkyFilePath);
writer.Write(EconomyCheckRate);
writer.Write(PopulationBase);
writer.Write(PopulationGrowthRate);
writer.Write(MetalConsumption);
writer.Write(StoneConsumption);
writer.Write(WoodConsumption);
writer.Write(LeatherConsumption);
writer.Write(ClothConsumption);
writer.Write(AlchemyConsumption);
writer.Write(ChemicalConsumption);
writer.Write(IndustrialConsumption);
writer.Write(MedicineConsumption);
writer.Write(FoodConsumption);
for (int i = 0; i < BLOCK_COUNT; i++) {
stream.Seek(sizeof(int) + i * sizeof(int) * 2 + sizeof(int), SeekOrigin.Begin);
writer.Write((int)offsets[i]);
}
}
示例2: Write
/// <summary>
/// Writes the block data to the underlying stream.
/// </summary>
/// <param name="writer">The writer.</param>
public override void Write(BinaryWriter writer)
{
base.Write(writer);
writer.WriteByteString(SpawnName);
writer.Write(NormalSpawnPoints.Count);
NormalSpawnPoints.ForEach(spawn => {
writer.WriteByteString(spawn.Name);
writer.Write(spawn.Monster);
writer.Write(spawn.Count);
});
writer.Write(TacticalSpawnPoints.Count);
TacticalSpawnPoints.ForEach(spawn => {
writer.WriteByteString(spawn.Name);
writer.Write(spawn.Monster);
writer.Write(spawn.Count);
});
writer.Write(Interval);
writer.Write(Limit);
writer.Write(Range);
writer.Write(TacticalVariable);
}
示例3: Save
/// <summary>
/// Saves the file to the specified stream.
/// </summary>
/// <param name="stream">The stream to save to.</param>
public override void Save(Stream stream)
{
BinaryWriter writer = new BinaryWriter(stream, Encoding.GetEncoding("EUC-KR"));
writer.Write((short)ModelFiles.Count);
ModelFiles.ForEach(modelFile => {
writer.WriteString(modelFile);
writer.Write((byte)0);
});
writer.Write((short)TextureFiles.Count);
TextureFiles.ForEach(texture => {
writer.WriteString(texture.FilePath);
writer.Write((byte)0);
writer.Write((short)(texture.UseSkinShader ? 1 : 0));
writer.Write((short)(texture.AlphaEnabled ? 1 : 0));
writer.Write((short)(texture.TwoSided ? 1 : 0));
writer.Write((short)(texture.AlphaTestEnabled ? 1 : 0));
writer.Write(texture.AlphaReference);
writer.Write((short)(texture.DepthTestEnabled ? 1 : 0));
writer.Write((short)(texture.DepthWriteEnabled ? 1 : 0));
writer.Write((short)texture.BlendType);
writer.Write((short)(texture.UseSpecularShader ? 1 : 0));
writer.Write(texture.Alpha);
writer.Write((short)texture.GlowType);
writer.Write(texture.GlowColour.ToVector3());
});
writer.Write((short)EffectFiles.Count);
EffectFiles.ForEach(effectFile => {
writer.WriteString(effectFile);
writer.Write((byte)0);
});
writer.Write((short)Objects.Count);
Objects.ForEach(@object => {
writer.Write((int)@object.BoundingCylinder.Radius);
writer.Write((int)@object.BoundingCylinder.Center.X);
writer.Write((int)@object.BoundingCylinder.Center.Y);
writer.Write((short)@object.Parts.Count);
if (@object.Parts.Count > 0) {
@object.Parts.ForEach(part => {
writer.Write(part.Model);
writer.Write(part.Texture);
if (part.Position != Vector3.Zero) {
writer.Write((byte)ModelListPropertyType.Position);
writer.Write((byte)(sizeof(float) * 3));
writer.Write(part.Position);
}
if (part.Rotation != Quaternion.Zero) {
writer.Write((byte)ModelListPropertyType.Rotation);
writer.Write((byte)(sizeof(float) * 4));
writer.Write(part.Rotation, true);
}
if (part.Scale != Vector3.Zero) {
writer.Write((byte)ModelListPropertyType.Scale);
writer.Write((byte)(sizeof(float) * 3));
writer.Write(part.Scale);
}
if (part.AxisRotation != Quaternion.Zero) {
writer.Write((byte)ModelListPropertyType.AxisRotation);
writer.Write((byte)(sizeof(float) * 4));
writer.Write(part.AxisRotation, true);
}
if (part.Parent != 0) {
writer.Write((byte)ModelListPropertyType.Parent);
writer.Write((byte)sizeof(short));
writer.Write(part.Parent);
}
if (part.Collision != 0) {
writer.Write((byte)ModelListPropertyType.Collision);
writer.Write((byte)sizeof(short));
writer.Write((short)part.Collision);
}
if (string.Compare(part.AnimationFilePath, string.Empty) != 0) {
writer.Write((byte)ModelListPropertyType.ConstantAnimation);
writer.WriteByteString(part.AnimationFilePath);
}
if (part.VisibleRangeSet != 0) {
writer.Write((byte)ModelListPropertyType.VisibleRangeSet);
writer.Write((byte)sizeof(short));
writer.Write(part.VisibleRangeSet);
//.........这里部分代码省略.........
示例4: Write
/// <summary>
/// Writes the block data to the underlying stream.
/// </summary>
/// <param name="writer">The writer.</param>
public virtual void Write(BinaryWriter writer)
{
writer.WriteByteString(Name);
writer.Write(WarpID);
writer.Write(EventID);
writer.Write(ObjectType);
writer.Write(ObjectID);
writer.Write(MapPosition.X);
writer.Write(MapPosition.Y);
writer.Write(Rotation);
writer.Write(Position);
writer.Write(Scale);
}
示例5: Write
/// <summary>
/// Writes the block data to the underlying stream.
/// </summary>
/// <param name="writer">The writer.</param>
public override void Write(BinaryWriter writer)
{
base.Write(writer);
writer.WriteByteString(FilePath);
}
示例6: Write
/// <summary>
/// Writes the block data to the underlying stream.
/// </summary>
/// <param name="writer">The writer.</param>
public override void Write(BinaryWriter writer)
{
base.Write(writer);
writer.Write(AI);
writer.WriteByteString(ConversationFile);
}