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


C# PacketReader.ReadBytes方法代碼示例

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


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

示例1: CustomHousePlane

 public CustomHousePlane(PacketReader reader)
 {
     byte[] data = reader.ReadBytes(4);
     Index = data[0];
     int uncompressedsize = data[1] + ((data[3] & 0xF0) << 4);
     int compressedLength = data[2] + ((data[3] & 0xF) << 8);
     ItemData = new byte[uncompressedsize];
     ZlibCompression.Unpack(ItemData, ref uncompressedsize, reader.ReadBytes(compressedLength), compressedLength);
     IsFloor = ((Index & 0x20) == 0x20);
     Index &= 0x1F;
 }
開發者ID:jorsi,項目名稱:UltimaXNA,代碼行數:11,代碼來源:CustomHousePlane.cs

示例2: CompressedGumpPacket

        public CompressedGumpPacket(PacketReader reader)
            : base(0xDD, "Compressed Gump")
        {
            GumpSerial = reader.ReadInt32();
            GumpTypeID = reader.ReadInt32();
            X = reader.ReadInt32();
            Y = reader.ReadInt32();

            int compressedLength = reader.ReadInt32() - 4;
            int decompressedLength = reader.ReadInt32();
            byte[] compressedData = reader.ReadBytes(compressedLength);
            byte[] decompressedData = new byte[decompressedLength];

            if (ZlibCompression.Unpack(decompressedData, ref decompressedLength, compressedData, compressedLength) != ZLibError.Okay)
            {
                // Problem decompressing, go ahead and quit.
                return;
            }
            else
            {
                GumpData = Encoding.ASCII.GetString(decompressedData);

                int numTextLines = reader.ReadInt32();
                int compressedTextLength = reader.ReadInt32() - 4;
                int decompressedTextLength = reader.ReadInt32();
                byte[] decompressedText = new byte[decompressedTextLength];
                if (numTextLines > 0 && decompressedTextLength > 0)
                {
                    byte[] compressedTextData = reader.ReadBytes(compressedTextLength);
                    ZlibCompression.Unpack(decompressedText, ref decompressedTextLength, compressedTextData, compressedTextLength);
                    int index = 0;
                    List<string> lines = new List<string>();
                    for (int i = 0; i < numTextLines; i++)
                    {
                        int length = decompressedText[index] * 256 + decompressedText[index + 1];
                        index += 2;
                        byte[] b = new byte[length * 2];
                        Array.Copy(decompressedText, index, b, 0, length * 2);
                        index += length * 2;
                        lines.Add(Encoding.BigEndianUnicode.GetString(b));
                    }
                    TextLines = lines.ToArray();
                }
                else
                {
                    TextLines = new string[0];
                }
            }
        }
開發者ID:gautamabudha,項目名稱:UltimaXNA,代碼行數:49,代碼來源:CompressedGumpPacket.cs

示例3: TargetCursorMultiPacket

 // This is called when the packet is received.
 public TargetCursorMultiPacket(PacketReader reader)
     : base(0x99, "Target Cursor For Multi")
 {
     reader.ReadByte(); // (0x01 from server, 0x00 from client)
     m_deedSerial = reader.ReadInt32();
     reader.ReadByte(); // flag byte. Harmful = 1, Beneficial = 2. Unused.
     reader.ReadBytes(11); // unknown (all 0)
     m_multiModel = reader.ReadInt16();
     m_offsetX = reader.ReadInt16();
     m_offsetY = reader.ReadInt16();
     m_offsetZ = reader.ReadInt16();
 }
開發者ID:FreeReign,項目名稱:UltimaXNA,代碼行數:13,代碼來源:TargetCursorMulti.cs


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