本文整理汇总了C#中Server.Network.PacketWriter类的典型用法代码示例。如果您正苦于以下问题:C# PacketWriter类的具体用法?C# PacketWriter怎么用?C# PacketWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PacketWriter类属于Server.Network命名空间,在下文中一共展示了PacketWriter类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SmoothMove
public SmoothMove(BaseGalleon galleon, object[] objectsonboard)
: base(0xF6)
{
short packetlen = 1 + 17;
packetlen += (short)(objectsonboard.Length * 10);
packetlen = (short)(((packetlen & 0xff) << 8) | ((packetlen >> 8) & 0xff));
//to little endian
m_Stream = new PacketWriter( packetlen );
m_Stream.Write((byte)PacketID);
m_Stream.Write((short)packetlen);
m_Stream.Write((int)galleon.Serial);
m_Stream.Write((byte)galleon.Speed);
m_Stream.Write((byte)galleon.Moving);
m_Stream.Write((byte)galleon.Direction);
m_Stream.Write((short)galleon.X);
m_Stream.Write((short)galleon.Y);
m_Stream.Write((byte)0xFF);
m_Stream.Write((sbyte)galleon.Z);
m_Stream.Write((byte)0x0);
m_Stream.Write((byte)objectsonboard.Length);
#region items
foreach (object o in objectsonboard)
{
if (o is Mobile)
{
m_Stream.Write((int)((Mobile)o).Serial);
m_Stream.Write((short)((Mobile)o).X);
m_Stream.Write((short)((Mobile)o).Y);
m_Stream.Write((byte)0xFF);
m_Stream.Write((sbyte)((Mobile)o).Z);
}
if (o is Item)
{
m_Stream.Write((int)((Item)o).Serial);
m_Stream.Write((short)((Item)o).X);
m_Stream.Write((short)((Item)o).Y);
m_Stream.Write((byte)0xFF);
m_Stream.Write((sbyte)((Item)o).Z);
}
}
#endregion
// * BYTE[1] 0xF6
// * BYTE[2] Packet Length ( little endian format )
// * BYTE[4] Serial Multi
// * BYTE[1] Movement Speed
// * BYTE[1] Movement Direction
// * BYTE[1] Multi Direction
// * BYTE[2] X
// * BYTE[2] Y
// * BYTE[1] Fixed 0xFF
// * SBYTE[1] Z
// * BYTE[1] Fixed 0x0
// * BYTE[1] List Length
// * BYTE[List Length * 10] List
//Each List Entry is Composed by:
// * BYTE[4] Item Serial
// * BYTE[2] X
// * BYTE[2] Y
// * BYTE[1] Fixed 0xFF
// * SBYTE[1] Z
}