本文整理匯總了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
}