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


C# Packet.ReadSByte方法代码示例

本文整理汇总了C#中Packet.ReadSByte方法的典型用法代码示例。如果您正苦于以下问题:C# Packet.ReadSByte方法的具体用法?C# Packet.ReadSByte怎么用?C# Packet.ReadSByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Packet的用法示例。


在下文中一共展示了Packet.ReadSByte方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteReadByteDataTest

        public void WriteReadByteDataTest()
        {
            Packet writePacket = new Packet(packetOpcode);
            writePacket.Write(uint32Value);
            writePacket.Write(uint16Value);
            writePacket.Write(byteValue);

            writePacket.Write(int32Value);
            writePacket.Write(int16Value);
            writePacket.Write(sbyteValue);

            writePacket.Write(stringValue);
            writePacket.Write(byteArrayValue);

            Packet readPacket = new Packet(writePacket.Data);

            Assert.AreEqual(writePacket.OpcodeNumber, readPacket.OpcodeNumber);
            Assert.AreEqual(uint32Value, readPacket.ReadUInt32());
            Assert.AreEqual(uint16Value, readPacket.ReadUInt16());
            Assert.AreEqual(byteValue, readPacket.ReadByte());
            Assert.AreEqual(int32Value, readPacket.ReadInt32());
            Assert.AreEqual(int16Value, readPacket.ReadInt16());
            Assert.AreEqual(sbyteValue, readPacket.ReadSByte());
            Assert.AreEqual(stringValue, readPacket.ReadString());
            var packetBytes = readPacket.ReadBytes();
            for (int i = 0; i < byteArrayValue.Length; i++)
                Assert.AreEqual(byteArrayValue[i], packetBytes[i]);

            readPacket.Dispose();
            writePacket.Dispose();
        }
开发者ID:Arcidev,项目名称:Arci.Networking,代码行数:31,代码来源:PacketTests.cs

示例2: EquipmentUpdate

        private static void EquipmentUpdate( Packet p, PacketHandlerEventArgs args )
        {
            Serial serial = p.ReadUInt32();

            Item i = World.FindItem( serial );
            bool isNew = false;
            if ( i == null )
            {
                World.AddItem( i=new Item( serial ) );
                isNew = true;
                Item.UpdateContainers();
            }
            else
            {
                i.CancelRemove();
            }

            if ( !DragDropManager.EndHolding( serial ) )
                return;

            ushort iid = p.ReadUInt16();
            i.ItemID = (ushort)(iid + p.ReadSByte()); // signed, itemID offset
            i.Layer = (Layer)p.ReadByte();
            Serial ser = p.ReadUInt32();// cont must be set after hue (for counters)
            i.Hue = p.ReadUInt16();

            i.Container = ser;

            int ltHue = Config.GetInt( "LTHilight" );
            if ( ltHue != 0 && Targeting.IsLastTarget( i.Container as Mobile ) )
            {
                p.Seek( -2, SeekOrigin.Current );
                p.Write( (ushort)(ltHue&0x3FFF) );
            }

            if ( i.Layer == Layer.Backpack && isNew && Config.GetBool( "AutoSearch" ) && ser == World.Player.Serial )
            {
                m_IgnoreGumps.Add( i );
                PlayerData.DoubleClick( i );
            }
        }
开发者ID:herculesjr,项目名称:razor,代码行数:41,代码来源:Handlers.cs

示例3: HandleRPVContainerContent

        public static byte[] HandleRPVContainerContent( Packet p )
        {
            bool isPostKR = false, decided = false;;
            int count = p.ReadUInt16();

            ArrayList list = new ArrayList();

            for (int i=0;i<count;i++)
            {
                Serial serial = p.ReadUInt32();
                // serial is purposely not checked to be valid, sometimes buy lists dont have "valid" item serials (and we are okay with that).
                Item item = World.FindItem( serial );
                if ( item == null )
                {
                    World.AddItem( item = new Item( serial ) );
                    item.IsNew = true;
                    item.AutoStack = false;
                }
                else
                {
                    item.CancelRemove();
                }

                //if ( !DragDropManager.EndHolding( serial ) )
                //	continue;

                item.ItemID = p.ReadUInt16();
                item.ItemID = (ushort)(item.ItemID + p.ReadSByte());// signed, itemID offset
                item.Amount = p.ReadUInt16();
                if ( item.Amount == 0 )
                    item.Amount = 1;
                item.Position = new Point3D( p.ReadUInt16(), p.ReadUInt16(), 0 );

                if ( !decided )
                {
                    byte nextByte = p.ReadByte();

                    isPostKR = ( (nextByte & 0x40) == 0 );
                    decided = true;

                    if ( isPostKR == Engine.UsePostKRPackets )
                        return p.Compile(); // not need to change anything

                    p.Seek( -1, SeekOrigin.Current );
                }

                if ( isPostKR )
                    item.GridNum = p.ReadByte();

                Serial cont = p.ReadUInt32();
                item.Hue = p.ReadUInt16();
                if ( SearchExemptionAgent.Contains( item ) )
                {
                    p.Seek( -2, System.IO.SeekOrigin.Current );
                    p.Write( (short)Config.GetInt( "ExemptColor" ) );
                }

                item.Container = cont; // must be done after hue is set (for counters)
                if ( !SearchExemptionAgent.IsExempt( item ) && ( item.IsChildOf( World.Player.Backpack ) || item.IsChildOf( World.Player.Quiver ) ) )
                    Counter.Count( item );

                list.Add( item );
            }
            Item.UpdateContainers();

            return new ContainerContent( list, Engine.UsePostKRPackets ).Compile();
        }
开发者ID:herculesjr,项目名称:razor,代码行数:67,代码来源:Handlers.cs

示例4: ContainerContentUpdate

        private static void ContainerContentUpdate( Packet p, PacketHandlerEventArgs args )
        {
            // This function will ignore the item if the container item has not been sent to the client yet.
            // We can do this because we can't really count on getting all of the container info anyway.
            // (So we'd need to request the container be updated, so why bother with the extra stuff required to find the container once its been sent?)
            Serial serial = p.ReadUInt32();
            ushort itemid = p.ReadUInt16();
            itemid = (ushort)(itemid + p.ReadSByte()); // signed, itemID offset
            ushort amount = p.ReadUInt16();
            if ( amount == 0 )
                amount = 1;
            Point3D pos = new Point3D( p.ReadUInt16(), p.ReadUInt16(), 0 );
            byte gridPos = 0;
            if ( Engine.UsePostKRPackets )
                gridPos = p.ReadByte();
            Serial cser = p.ReadUInt32();
            ushort hue = p.ReadUInt16();

            Item i = World.FindItem( serial );
            if ( i == null  )
            {
                if ( !serial.IsItem )
                    return;

                World.AddItem( i = new Item( serial ) );
                i.IsNew = i.AutoStack = true;
            }
            else
            {
                i.CancelRemove();
            }

            if ( serial != DragDropManager.Pending )
            {
                if ( !DragDropManager.EndHolding( serial ) )
                    return;
            }

            i.ItemID = itemid;
            i.Amount = amount;
            i.Position = pos;
            i.GridNum = gridPos;
            i.Hue = hue;

            if ( SearchExemptionAgent.Contains( i ) )
            {
                p.Seek( -2, System.IO.SeekOrigin.Current );
                p.Write( (short)Config.GetInt( "ExemptColor" ) );
            }

            i.Container = cser;
            if ( i.IsNew )
                Item.UpdateContainers();
            if ( !SearchExemptionAgent.IsExempt( i ) && ( i.IsChildOf( World.Player.Backpack ) || i.IsChildOf( World.Player.Quiver ) ) )
                Counter.Count( i );
        }
开发者ID:herculesjr,项目名称:razor,代码行数:56,代码来源:Handlers.cs

示例5: ContainerContent

        private static void ContainerContent( Packet p, PacketHandlerEventArgs args )
        {
            int count = p.ReadUInt16();

            for (int i=0;i<count;i++)
            {
                Serial serial = p.ReadUInt32();
                // serial is purposely not checked to be valid, sometimes buy lists dont have "valid" item serials (and we are okay with that).
                Item item = World.FindItem( serial );
                if ( item == null )
                {
                    World.AddItem( item = new Item( serial ) );
                    item.IsNew = true;
                    item.AutoStack = false;
                }
                else
                {
                    item.CancelRemove();
                }

                if ( !DragDropManager.EndHolding( serial ) )
                    continue;

                item.ItemID = p.ReadUInt16();
                item.ItemID = (ushort)(item.ItemID + p.ReadSByte());// signed, itemID offset
                item.Amount = p.ReadUInt16();
                if ( item.Amount == 0 )
                    item.Amount = 1;
                item.Position = new Point3D( p.ReadUInt16(), p.ReadUInt16(), 0 );
                if ( Engine.UsePostKRPackets )
                    item.GridNum = p.ReadByte();
                Serial cont = p.ReadUInt32();
                item.Hue = p.ReadUInt16();
                if ( SearchExemptionAgent.Contains( item ) )
                {
                    p.Seek( -2, System.IO.SeekOrigin.Current );
                    p.Write( (short)Config.GetInt( "ExemptColor" ) );
                }

                item.Container = cont; // must be done after hue is set (for counters)
                if ( !SearchExemptionAgent.IsExempt( item ) && ( item.IsChildOf( World.Player.Backpack ) || item.IsChildOf( World.Player.Quiver ) ) )
                    Counter.Count( item );
            }
            Item.UpdateContainers();
        }
开发者ID:herculesjr,项目名称:razor,代码行数:45,代码来源:Handlers.cs

示例6: MobileUpdate

        private static void MobileUpdate( Packet p, PacketHandlerEventArgs args )
        {
            if ( World.Player == null )
                return;

            Serial serial = p.ReadUInt32();
            Mobile m = World.FindMobile( serial );
            if ( m == null )
                World.AddMobile( m = new Mobile( serial ) );

            bool wasHidden = !m.Visible;

            m.Body = (ushort)(p.ReadUInt16() + p.ReadSByte());
            m.Hue = p.ReadUInt16();
            int ltHue = Config.GetInt( "LTHilight" );
            if ( ltHue != 0 && Targeting.IsLastTarget( m ) )
            {
                p.Seek( -2, SeekOrigin.Current );
                p.Write( (ushort)(ltHue|0x8000) );
            }

            bool wasPoisoned = m.Poisoned;
            m.ProcessPacketFlags( p.ReadByte() );

            if ( m == World.Player )
            {
                ClientCommunication.BeginCalibratePosition();

                World.Player.Resync();

                if ( !wasHidden && !m.Visible )
                {
                    if ( Config.GetBool( "AlwaysStealth" ) )
                        StealthSteps.Hide();
                }
                else if ( wasHidden && m.Visible )
                {
                    StealthSteps.Unhide();
                }

                if ( wasPoisoned != m.Poisoned )
                    ClientCommunication.RequestTitlebarUpdate();
            }

            ushort x = p.ReadUInt16();
            ushort y = p.ReadUInt16();
            p.ReadUInt16(); //always 0?
            m.Direction = (Direction)p.ReadByte();
            m.Position = new Point3D( x, y, p.ReadSByte() );

            Item.UpdateContainers();
        }
开发者ID:herculesjr,项目名称:razor,代码行数:52,代码来源:Handlers.cs

示例7: MobileMoving

        private static void MobileMoving( Packet p, PacketHandlerEventArgs args )
        {
            Mobile m = World.FindMobile( p.ReadUInt32() );

            if ( m != null )
            {
                m.Body = p.ReadUInt16();
                m.Position = new Point3D( p.ReadUInt16(), p.ReadUInt16(), p.ReadSByte() );

                if ( World.Player != null && !Utility.InRange( World.Player.Position, m.Position, World.Player.VisRange ) )
                {
                    m.Remove();
                    return;
                }

                Targeting.CheckLastTargetRange( m );

                m.Direction = (Direction)p.ReadByte();
                m.Hue = p.ReadUInt16();
                int ltHue = Config.GetInt( "LTHilight" );
                if ( ltHue != 0 && Targeting.IsLastTarget( m ) )
                {
                    p.Seek( -2, SeekOrigin.Current );
                    p.Write( (short)(ltHue|0x8000) );
                }

                bool wasPoisoned = m.Poisoned;
                m.ProcessPacketFlags( p.ReadByte() );
                byte oldNoto = m.Notoriety;
                m.Notoriety = p.ReadByte();

                if ( m == World.Player )
                {
                    ClientCommunication.BeginCalibratePosition();

                    if ( wasPoisoned != m.Poisoned || ( oldNoto != m.Notoriety && Config.GetBool( "ShowNotoHue" ) ) )
                        ClientCommunication.RequestTitlebarUpdate();
                }
            }
        }
开发者ID:herculesjr,项目名称:razor,代码行数:40,代码来源:Handlers.cs

示例8: HandleRPVContainerContentUpdate

        public static byte[] HandleRPVContainerContentUpdate( Packet p )
        {
            // This function will ignore the item if the container item has not been sent to the client yet.
            // We can do this because we can't really count on getting all of the container info anyway.
            // (So we'd need to request the container be updated, so why bother with the extra stuff required to find the container once its been sent?)
            bool isPostKR = false, decided = false;

            Serial serial = p.ReadUInt32();
            ushort itemid = p.ReadUInt16();
            itemid = (ushort)(itemid + p.ReadSByte()); // signed, itemID offset
            ushort amount = p.ReadUInt16();
            if ( amount == 0 )
                amount = 1;
            Point3D pos = new Point3D( p.ReadUInt16(), p.ReadUInt16(), 0 );
            byte gridPos = 0;
            if ( !decided )
            {
                byte nextByte = p.ReadByte();

                isPostKR = ( (nextByte & 0x40) == 0 );
                decided = true;

                if ( isPostKR == Engine.UsePostKRPackets )
                    return p.Compile(); // not need to change anything

                p.Seek( -1, SeekOrigin.Current );
            }

            if ( isPostKR )
                gridPos = p.ReadByte();

            Serial cser = p.ReadUInt32();
            ushort hue = p.ReadUInt16();

            Item i = World.FindItem( serial );
            if ( i == null  )
            {
                if ( !serial.IsItem )
                    return p.Compile();

                World.AddItem( i = new Item( serial ) );
                i.IsNew = i.AutoStack = true;
            }

            i.ItemID = itemid;
            i.Amount = amount;
            i.Position = pos;
            i.GridNum = gridPos;
            i.Hue = hue;
            i.Container = cser;

            if ( i.IsNew )
                Item.UpdateContainers();
            if ( !SearchExemptionAgent.IsExempt( i ) && ( i.IsChildOf( World.Player.Backpack ) || i.IsChildOf( World.Player.Quiver ) ) )
                Counter.Count( i );

            return new ContainerItem( i, Engine.UsePostKRPackets ).Compile();
        }
开发者ID:herculesjr,项目名称:razor,代码行数:58,代码来源:Handlers.cs

示例9: MobileIncoming

        private static void MobileIncoming( Packet p, PacketHandlerEventArgs args )
        {
            if ( World.Player == null )
                return;

            Serial serial = p.ReadUInt32();
            ushort body =  p.ReadUInt16();
            Point3D position = new Point3D( p.ReadUInt16(), p.ReadUInt16(), p.ReadSByte() );

            if ( World.Player.Position != Point3D.Zero && !Utility.InRange( World.Player.Position, position, World.Player.VisRange ) )
                return;

            Mobile m = World.FindMobile( serial );
            if ( m == null )
                World.AddMobile( m = new Mobile( serial ) );

            bool wasHidden = !m.Visible;

            if ( m != World.Player && Config.GetBool( "ShowMobNames" ) )
                ClientCommunication.SendToServer( new SingleClick( m ) );
            if ( Config.GetBool( "LastTargTextFlags" ) )
                Targeting.CheckTextFlags( m );

            int ltHue = Config.GetInt( "LTHilight" );
            bool isLT;
            if ( ltHue != 0 )
                isLT = Targeting.IsLastTarget( m );
            else
                isLT = false;

            m.Body = body;
            if ( m != World.Player || World.Player.OutstandingMoveReqs == 0 )
                m.Position = position;
            m.Direction = (Direction)p.ReadByte();
            m.Hue = p.ReadUInt16();
            if ( isLT )
            {
                p.Seek( -2, SeekOrigin.Current );
                p.Write( (short)(ltHue|0x8000) );
            }

            bool wasPoisoned = m.Poisoned;
            m.ProcessPacketFlags( p.ReadByte() );
            byte oldNoto = m.Notoriety;
            m.Notoriety = p.ReadByte();

            if ( m == World.Player )
            {
                ClientCommunication.BeginCalibratePosition();

                if ( !wasHidden && !m.Visible )
                {
                    if ( Config.GetBool( "AlwaysStealth" ) )
                        StealthSteps.Hide();
                }
                else if ( wasHidden && m.Visible )
                {
                    StealthSteps.Unhide();
                }

                if ( wasPoisoned != m.Poisoned || ( oldNoto != m.Notoriety && Config.GetBool( "ShowNotoHue" ) ) )
                    ClientCommunication.RequestTitlebarUpdate();
            }

            while ( true )
            {
                serial = p.ReadUInt32();
                if ( !serial.IsItem )
                    break;

                Item item = World.FindItem( serial );
                bool isNew = false;
                if ( item == null )
                {
                    isNew = true;
                    World.AddItem( item = new Item( serial ) );
                }

                if ( !DragDropManager.EndHolding( serial ) )
                    continue;

                item.Container = m;

                ushort id = p.ReadUInt16();

                if (Engine.UseNewMobileIncoming)
                    item.ItemID = (ushort)(id & 0xFFFF);
                else if (Engine.UsePostSAChanges)
                    item.ItemID = (ushort)(id & 0x7FFF);
                else
                    item.ItemID = (ushort)(id & 0x3FFF);

                item.Layer = (Layer)p.ReadByte();

                if (Engine.UseNewMobileIncoming)
                {
                    item.Hue = p.ReadUInt16();
                    if (isLT)
                    {
                        p.Seek(-2, SeekOrigin.Current);
//.........这里部分代码省略.........
开发者ID:herculesjr,项目名称:razor,代码行数:101,代码来源:Handlers.cs

示例10: HandlePlayerDamage

        public static void HandlePlayerDamage(Client pClient, Packet pPacket)
        {
            pPacket.Skip(4);
            pPacket.ReadInt(); // Tick.
            sbyte Type = pPacket.ReadSByte();
            pPacket.Skip(1);
            int Damage = pPacket.ReadInt();
            pPacket.Skip(2);
               int MobId = 0;

               if (Type != -2 && Type != -3 && Type != -4)
               MobId = pPacket.ReadInt();

               pClient.Character.ModifyHP((short)-Damage);
        }
开发者ID:DragonNeos,项目名称:serenity-maple,代码行数:15,代码来源:GameHandler.cs


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