當前位置: 首頁>>代碼示例>>C#>>正文


C# BinaryWriter.WritePackedUInt64方法代碼示例

本文整理匯總了C#中System.IO.BinaryWriter.WritePackedUInt64方法的典型用法代碼示例。如果您正苦於以下問題:C# BinaryWriter.WritePackedUInt64方法的具體用法?C# BinaryWriter.WritePackedUInt64怎麽用?C# BinaryWriter.WritePackedUInt64使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.IO.BinaryWriter的用法示例。


在下文中一共展示了BinaryWriter.WritePackedUInt64方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: BuildCreatePacket

        protected override byte[] BuildCreatePacket()
        {
            foreach (var creationUpdateFieldEntry in entity.Info.CreationUpdateFieldEntries)
            {
                UpdateQueue.Enqueue(creationUpdateFieldEntry);
            }

            SetInfoFields(entity.Info);

            var writer = new BinaryWriter(new MemoryStream());

            writer.Write((byte)ObjectUpdateType.UPDATETYPE_CREATE_OBJECT);
            writer.WritePackedUInt64(this.entity.ObjectGUID.RawGUID);
            writer.Write((byte)TypeID.TYPEID_GAMEOBJECT);

            ObjectUpdateFlag updateFlags = ObjectUpdateFlag.UPDATEFLAG_TRANSPORT | ObjectUpdateFlag.UPDATEFLAG_ALL
                                           | ObjectUpdateFlag.UPDATEFLAG_HAS_POSITION;

            writer.Write((byte)updateFlags);

            // Position
            writer.Write(entity.Location.X);
            writer.Write(entity.Location.Y);
            writer.Write(entity.Location.Z);

            writer.Write(entity.Location.Orientation); // R

            writer.Write((uint)0x1); // Unkown... time?
            writer.Write((uint)0); // Unkown... time?

            WriteUpdateFields(writer);

            return (writer.BaseStream as MemoryStream).ToArray();
        }
開發者ID:Refuge89,項目名稱:Vanilla,代碼行數:34,代碼來源:GameObjectPacketBuilder.cs

示例2: BuildUpdatePacket

 protected override byte[] BuildUpdatePacket()
 {
     this.SetInfoFields(entity.Info);
     var writer = new BinaryWriter(new MemoryStream());
     writer.Write((byte)ObjectUpdateType.UPDATETYPE_VALUES);
     writer.WritePackedUInt64(entity.ObjectGUID.RawGUID);
     this.WriteUpdateFields(writer);
     return (writer.BaseStream as MemoryStream).ToArray();
 }
開發者ID:Refuge89,項目名稱:Vanilla,代碼行數:9,代碼來源:GameObjectPacketBuilder.cs

示例3: BuildCreatePacket

        protected override byte[] BuildCreatePacket()
        {
            //Add all info field entries to the queue
            foreach (var creationUpdateFieldEntry in entity.Info.CreationUpdateFieldEntries)
            {
                UpdateQueue.Enqueue(creationUpdateFieldEntry);
            }

            SetInfoFields(entity.Info);

            var writer = new BinaryWriter(new MemoryStream());

            //TODO Work out why "adder" unit crashes client. Maybe a pet or dynamic object?
            writer.Write((byte)ObjectUpdateType.UPDATETYPE_CREATE_OBJECT);

            writer.WritePackedUInt64(entity.ObjectGUID.RawGUID);

            writer.Write((byte)TypeID.TYPEID_UNIT);

            ObjectUpdateFlag updateFlags = ObjectUpdateFlag.UPDATEFLAG_ALL | ObjectUpdateFlag.UPDATEFLAG_LIVING
                                           | ObjectUpdateFlag.UPDATEFLAG_HAS_POSITION;

            writer.Write((byte)updateFlags);
            writer.Write((uint)MovementFlags.MOVEFLAG_NONE); // MovementFlags

            writer.Write((uint)Environment.TickCount); // Time

            // 3 bytes ahead?

            // Position
            writer.Write(entity.Location.X);
            writer.Write(entity.Location.Y);
            writer.Write(entity.Location.Z);
            writer.Write(entity.Location.Orientation); // R

            // Movement speeds
            writer.Write((float)0); // ????

            writer.Write(entity.Info.WalkSpeed); // MOVE_WALK
            writer.Write((float)7); // MOVE_RUN
            writer.Write(4.5f); // MOVE_RUN_BACK
            writer.Write(4.72f); // MOVE_SWIM
            writer.Write(2.5f); // MOVE_SWIM_BACK
            writer.Write(3.14f); // MOVE_TURN_RATE

            writer.Write(0x1); // Unkown...

            // entity.GUID = 1141440694;
            this.WriteUpdateFields(writer);

            return (writer.BaseStream as MemoryStream).ToArray();
        }
開發者ID:Refuge89,項目名稱:Vanilla,代碼行數:52,代碼來源:CreaturePacketBuilder.cs

示例4: BuildOwnCharacterPacket

        public PSUpdateObject BuildOwnCharacterPacket()
        {
            foreach (var creationUpdateFieldEntry in entity.Info.CreationUpdateFieldEntries)
            {
                UpdateQueue.Enqueue(creationUpdateFieldEntry);
            }

            SetInfoFields(entity.Info);

            BinaryWriter writer = new BinaryWriter(new MemoryStream());

            writer.Write((byte)ObjectUpdateType.UPDATETYPE_CREATE_OBJECT2);
            writer.WritePackedUInt64(this.entity.ObjectGUID.RawGUID);
            writer.Write((byte)TypeID.TYPEID_PLAYER);

            ObjectUpdateFlag updateFlags = ObjectUpdateFlag.UPDATEFLAG_ALL |
                                        ObjectUpdateFlag.UPDATEFLAG_SELF |
                                      ObjectUpdateFlag.UPDATEFLAG_HAS_POSITION |
                                      ObjectUpdateFlag.UPDATEFLAG_LIVING;

            writer.Write((byte)updateFlags);

            writer.Write((UInt32)MovementFlags.MOVEFLAG_NONE);
            writer.Write((UInt32)Environment.TickCount); // Time?

            // Position
            writer.Write((float)entity.Location.X);
            writer.Write((float)entity.Location.Y);
            writer.Write((float)entity.Location.Z);
            writer.Write((float)entity.Location.Orientation); // R

            // Movement speeds
            writer.Write((float)0);     // ????

            writer.Write((float)entity.Info.WalkSpeed);  // MOVE_WALK
            writer.Write((float)20f);     // MOVE_RUN
            writer.Write((float)4.5f);  // MOVE_RUN_BACK
            writer.Write((float)4.72f); // MOVE_SWIM
            writer.Write((float)2.5f);  // MOVE_SWIM_BACK
            writer.Write((float)3.14f); // MOVE_TURN_RATE

            writer.Write(0x1); // Unkown...

            this.WriteUpdateFields(writer);

            return new PSUpdateObject(new List<byte[]>() { (writer.BaseStream as MemoryStream).ToArray() });
        }
開發者ID:Refuge89,項目名稱:Vanilla,代碼行數:47,代碼來源:PlayerPacketBuilder.cs

示例5: RemoveEntitiesBlock

        private byte[] RemoveEntitiesBlock()
        {
            var writer = new BinaryWriter(new MemoryStream());
            writer.Write((byte)ObjectUpdateType.UPDATETYPE_OUT_OF_RANGE_OBJECTS);
            writer.Write((uint)this.removeEntities.Count);

            while(removeEntities.Count != 0)
            {
                var entity = removeEntities.Dequeue();
                writer.WritePackedUInt64(entity.ObjectGUID.RawGUID);
            }

            return (writer.BaseStream as MemoryStream).ToArray();
        }
開發者ID:Refuge89,項目名稱:Vanilla,代碼行數:14,代碼來源:UpdatePacketBuilder.cs

示例6: BuildUpdatePacket

        protected override byte[] BuildUpdatePacket()
        {
            foreach (var creationUpdateFieldEntry in entity.Info.CreationUpdateFieldEntries)
            {
                UpdateQueue.Enqueue(creationUpdateFieldEntry);
            }

            this.SetInfoFields(entity.Info);
            var writer = new BinaryWriter(new MemoryStream());
            writer.Write((byte)ObjectUpdateType.UPDATETYPE_VALUES);
            writer.WritePackedUInt64(entity.ObjectGUID.RawGUID);
            this.WriteUpdateFields(writer);
            return (writer.BaseStream as MemoryStream).ToArray();
        }
開發者ID:Refuge89,項目名稱:Vanilla,代碼行數:14,代碼來源:PlayerPacketBuilder.cs


注:本文中的System.IO.BinaryWriter.WritePackedUInt64方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。