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


C# BitPack.WriteStringLength方法代碼示例

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


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

示例1: SendMessage

        public static void SendMessage(ref WorldClass session, ChatMessageValues chatMessage, WorldClass pSession = null)
        {
            byte[] GuidMask = { 4, 1, 3, 6, 2, 5, 0, 7 };
            byte[] GuidMask3 = { 6, 1, 3, 5, 4, 2, 7, 0 };
            byte[] GuidBytes = { 7, 4, 0, 6, 3, 2, 5, 1 };
            byte[] GuidBytes3 = { 7, 4, 1, 3, 0, 6, 5, 2 };

            var pChar = session.Character;
            var guid = pChar.Guid;

            if (pSession != null)
                guid = pSession.Character.Guid;

            PacketWriter chat = new PacketWriter(ServerMessage.Chat);
            BitPack BitPack = new BitPack(chat, guid);

            BitPack.Write(!chatMessage.HasLanguage);
            BitPack.Write(1);
            BitPack.Write(1);
            BitPack.Write(0, 8);
            BitPack.Write(1);
            BitPack.Write(0);
            BitPack.Write(1);
            BitPack.Write(1);
            BitPack.Write(1);
            BitPack.Write(0, 8);
            BitPack.Write(0);

            BitPack.WriteGuidMask(GuidMask3);

            BitPack.Write(1);
            BitPack.Write(0);
            BitPack.Write(1);
            BitPack.Write(!chatMessage.HasRealmId);
            BitPack.Write(0);
            BitPack.WriteStringLength(chatMessage.Message, 12);
            BitPack.Write(0);

            BitPack.WriteGuidMask(GuidMask);

            BitPack.Write(0);
            BitPack.Write(8, 9);

            BitPack.Flush();

            BitPack.WriteGuidBytes(GuidBytes3);

            if (chatMessage.HasLanguage)
                chat.WriteUInt8(chatMessage.Language);

            BitPack.WriteGuidBytes(GuidBytes);

            chat.WriteString(chatMessage.Message, false);
            chat.WriteUInt8((byte)chatMessage.ChatType);

            chat.WriteInt32(0);

            if (chatMessage.HasRealmId)
                chat.WriteInt32(chatMessage.RealmId);

            switch (chatMessage.ChatType)
            {
                case MessageType.ChatMessageSay:
                    WorldMgr.SendByDist(pChar, chat, 625);
                    break;
                case MessageType.ChatMessageYell:
                    WorldMgr.SendByDist(pChar, chat, 90000);
                    break;
                default:
                    session.Send(ref chat);
                    break;
            }
        }
開發者ID:rodrigoalv,項目名稱:Arctium-WoW,代碼行數:73,代碼來源:ChatHandler.cs


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