当前位置: 首页>>代码示例>>C#>>正文


C# BinaryWriter.WriteByteString方法代码示例

本文整理汇总了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]);
            }
        }
开发者ID:brett19,项目名称:RoseTwoPointOh,代码行数:84,代码来源:ZoneFile.cs

示例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);
        }
开发者ID:Jiwan,项目名称:Revise,代码行数:30,代码来源:MapMonsterSpawn.cs

示例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);
//.........这里部分代码省略.........
开发者ID:Jiwan,项目名称:Revise,代码行数:101,代码来源:ModelListFile.cs

示例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);
 }
开发者ID:osROSE,项目名称:UnityRose,代码行数:17,代码来源:MapBlock.cs

示例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);
        }
开发者ID:brett19,项目名称:RoseTwoPointOh,代码行数:10,代码来源:MapEffect.cs

示例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);
        }
开发者ID:Jiwan,项目名称:Revise,代码行数:11,代码来源:MapNPC.cs


注:本文中的System.IO.BinaryWriter.WriteByteString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。