当前位置: 首页>>代码示例>>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;未经允许,请勿转载。