本文整理汇总了C#中Packet.WriteUShort方法的典型用法代码示例。如果您正苦于以下问题:C# Packet.WriteUShort方法的具体用法?C# Packet.WriteUShort怎么用?C# Packet.WriteUShort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Packet
的用法示例。
在下文中一共展示了Packet.WriteUShort方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChangeChannel
public static Packet ChangeChannel(Client pClient, ushort pPort)
{
Packet p = new Packet();
p.WriteShort((short)SendOpcodes.Channel_Change);
p.WriteByte(1);
p.WriteBytes(new byte[] { 8, 31, 99, 141 });
p.WriteUShort(pPort);
p.WriteByte(0);
return p;
}
示例2: BeginMove
public static void BeginMove(Packet packet, Player player)
{
int GameCoord = packet.ReadInt( );
Point Pos = Data.GetReallyCoord(player.CharData.Map, GameCoord);
NPC NPCData = NPCs.IsNPC(player, Pos);
if (NPCData != null)
{
#region Response (NPC)
Packet Response = new Packet(0x0252);
Response.WriteByte(1);
Response.WriteUShort(NPCData.Type);
player.Sock.Send(Response);
#endregion
}
else
{
#region Response (Move)
Packet Response = new Packet(0x0122);
Response.WriteInt(GameCoord); // Coord
Response.WriteUShort(player.CharData.MovingSpeed); // Speed
Response.WriteByte(1); // Flag
player.Sock.Send(Response);
#endregion
#region Others
Packet Others = new Packet(0x0123);
Others.WriteULong(player.ID);
Others.WriteInt(GameCoord);
Others.WriteUShort(1); // Speed
int MapIndex = Maps.MapsData.Find(player.CharData.Map);
if (MapIndex != -1)
{
foreach (Player x in Maps.MapsData[MapIndex].Players)
{
if (x.ID != player.ID)
x.Sock.Send(Others);
}
}
#endregion
}
}
示例3: Migrate
public static Packet Migrate(byte[] pIP, ushort pPort, int pCharacterId)
{
Packet p = new Packet();
p.WriteShort((short)SendOpcodes.Migrate);
p.WriteShort(0);
p.WriteBytes(pIP);
p.WriteUShort(pPort);
p.WriteInt(pCharacterId);
p.WriteInt(0);
p.WriteShort(0);
p.WriteBytes(new byte[] { 0x61, 0x31, 0x20, 0x6D, 0x73, 0x5D, 0x20, 0x5B, 0x47 });
return p;
}
示例4: SpawnNPC
public static Packet SpawnNPC(Life pNPC)
{
Packet p = new Packet();
p.WriteShort((short)SendOpcodes.NPC_Spawn);
p.WriteUInt(pNPC.SpawnID);
p.WriteInt(pNPC.ID);
p.WriteShort(pNPC.X);
p.WriteShort(pNPC.Cy);
p.WriteByte((byte)(pNPC.FacesLeft ? 0 : 1));
p.WriteUShort(pNPC.Foothold);
p.WriteShort(pNPC.Rx0);
p.WriteShort(pNPC.Rx1);
p.WriteByte((byte)(pNPC.Hide == 0 ? 1 : 0));
return p;
}
示例5: Equip
public static void Equip(Packet packet, Player player)
{
uint ItemID = packet.ReadUInt( );
byte Slot = packet.ReadByte( );
byte Error = 1;
#region Parse
CharItem Item = player.CharData.GeneralItems.FindID(ItemID);
CharItem ClothesItem = player.CharData.ClothesItems.FindSlot(Slot);
if (ClothesItem.Slot == -1)
{
if (Item.Slot != -1)
{
player.CharData.GeneralItems.Remove(Item);
Item.Slot = Slot;
player.CharData.ClothesItems.Add(Item);
}
else
{
Item = player.CharData.RidingItems.FindID(ItemID);
if (Item.Slot != -1)
{
player.CharData.RidingItems.Remove(Item);
Item.Slot = Slot;
player.CharData.ClothesItems.Add(Item);
}
else
{
Error = 2;
}
}
}
else
{
if (Item.Slot != -1)
{
player.CharData.GeneralItems.Remove(Item);
player.CharData.GeneralItems.Add(ClothesItem);
player.CharData.GeneralItems.Last( ).Slot = Item.Slot;
player.CharData.ClothesItems.Remove(ClothesItem);
player.CharData.ClothesItems.Add(Item);
player.CharData.ClothesItems.Last( ).Slot = Slot;
}
else
{
Item = player.CharData.RidingItems.FindID(ItemID);
if (Item.Slot != -1)
{
player.CharData.RidingItems.Remove(Item);
player.CharData.RidingItems.Add(ClothesItem);
player.CharData.RidingItems.Last( ).Slot = Item.Slot;
player.CharData.ClothesItems.Remove(ClothesItem);
player.CharData.ClothesItems.Add(Item);
player.CharData.ClothesItems.Last( ).Slot = Slot;
}
else
{
Error = 2;
}
}
}
#endregion
if (ClothesItem.Slot == -1)
{
#region Response (Equip)
Packet Response = new Packet(0x0412);
Response.WriteUInt(ItemID);
Response.WriteByte(Slot);
Response.WriteByte(Error);
Response.WriteUInt(10);
Response.WriteUShort(20);
Response.WriteUShort(player.CharData.PhysicalDef); // Pyshical Defense
Response.WriteUShort(player.CharData.MagicalDef); // Magical Defense
Response.WriteByte(30);
Response.WriteUShort(player.CharData.AbbillityMin); // AbbillityMin
Response.WriteUShort(player.CharData.AbbillityMax); // AbbillityMax
Response.WriteByte(40);
Response.WriteByte(50);
Response.WriteUShort(player.CharData.Vitality); // Vitality
Response.WriteUShort(player.CharData.Sympathy); // Sympathy
Response.WriteUShort(player.CharData.Intelligence); // Intelligence
Response.WriteUShort(60);
Response.WriteUShort(player.CharData.Dexterity); // Dexterity
Response.WriteUInt(player.CharData.MaxHP); // Max HP
Response.WriteUInt(70);
Response.WriteUInt(player.CharData.MaxMP); // Max MP
Response.WriteByte(80);
player.Sock.Send(Response);
#endregion
}
else
{
#region Response (Change Equip)
Packet Response = new Packet(0x0413);
Response.WriteUInt(ClothesItem.ID);
//.........这里部分代码省略.........
示例6: Open
public static void Open(Packet packet, Player player)
{
if (packet.ReadByte() == 1)
{
player.CharData.isInPVP = true;
AddPlayer(player);
int MapIndex = Maps.MapsData.Find(player.CharData.Map);
if (MapIndex != -1)
Maps.RemovePlayer(player, Maps.MapsData[MapIndex]);
#region Packet
Packet PVPInfo = new Packet(0x0804);
PVPInfo.WriteUShort((ushort)Rooms.Count);
PVPInfo.WriteUShort((ushort)Players.Count);
foreach (PVPRoom x in Rooms)
{
ushort Info = (ushort)((x.Password == "" ? 0 : 1) +
((int)x.Mode << 1) +
(x.Players.Count << 7) +
(x.MaxParticipant << 11) +
((x.isInGame ? 1 : 0) << 15));
PVPInfo.WriteUInt(x.ID);
PVPInfo.WriteString(x.Name, 40);
PVPInfo.WriteUShort(Info);
PVPInfo.WriteByte(1);
}
foreach (Player x in Players)
PVPInfo.WriteString(x.CharName, 17);
player.Sock.Send(PVPInfo);
#endregion
}
}
示例7: ExitRoom
public static void ExitRoom(Packet packet, Player player)
{
uint ID = packet.ReadUInt();
player.CharData.PVPRoom.RemovePlayer(player);
player.CharData.PVPRoom = null;
PVP.AddPlayer(player);
#region Packet
Packet PVPInfo = new Packet(0x0804);
PVPInfo.WriteUShort((ushort)Rooms.Count);
PVPInfo.WriteUShort((ushort)Players.Count);
foreach (PVPRoom x in Rooms)
{
ushort Info = (ushort)((x.Password == "" ? 0 : 1) +
((int)x.Mode << 1) +
(x.Players.Count << 7) +
(x.MaxParticipant << 11) +
((x.isInGame ? 1 : 0) << 15));
PVPInfo.WriteUInt(x.ID);
PVPInfo.WriteString(x.Name, 40);
PVPInfo.WriteUShort(Info);
PVPInfo.WriteByte(1);
}
foreach (Player x in Players)
PVPInfo.WriteString(x.CharName, 17);
player.Sock.Send(PVPInfo);
#endregion
}
示例8: CreateRoom
public static void CreateRoom(Packet packet, Player player)
{
PVPRoom newRoom = new PVPRoom();
newRoom.Name = packet.ReadString(40);
newRoom.Password = packet.ReadString(10);
ushort Info = packet.ReadUShort();
newRoom.Map = packet.ReadUShort();
newRoom.Observer = packet.ReadByte() != 0;
// HasPassword is [((Info >> 0) & 0x01) != 0]
newRoom.Mode = (RoomMode)((Info >> 1) & 0x1F);
newRoom.MaxParticipant = (byte)((Info >> 6) & 0x0F);
newRoom.Time = (byte)((Info >> 10) & 0x1F);
newRoom.Item = ((Info >> 15) & 0x01) != 0;
newRoom.ID = NextID;
newRoom.AddPlayer(player);
player.CharData.PVPRoom = newRoom;
PVP.RemovePlayer(player);
AddRoom(newRoom);
#region Response
Packet Response = new Packet(0x0809);
Response.WriteByte(1);
Response.WriteUShort((ushort)newRoom.ID);
player.Sock.Send(Response);
#endregion
}
示例9: Close
public static void Close(Packet packet, Player player)
{
player.CharData.isInPVP = false;
RemovePlayer(player);
#region Packet
Packet Teleporting = new Packet(0x0132);
Teleporting.WriteInt(Data.GetGameCoord(player.CharData.Map, player.CharData.Coord));
Teleporting.WriteUShort(player.CharData.Map);
Teleporting.WriteByte(1);
player.Sock.Send(Teleporting);
#endregion
}
示例10: AddRoom
public static void AddRoom(PVPRoom room)
{
Rooms.Add(room);
#region Packet
foreach (Player x in Players)
{
ushort OthersInfo = (ushort)((room.Password == "" ? 0 : 1) +
((int)room.Mode << 1) +
(room.Players.Count << 7) +
(room.MaxParticipant << 11) +
((room.isInGame ? 1 : 0) << 15));
Packet Others = new Packet(0x0810);
Others.WriteUInt(room.ID);
Others.WriteString(room.Name, 40);
Others.WriteUShort(OthersInfo);
x.Sock.Send(Others);
}
#endregion
}
示例11: SendHandshake
public void SendHandshake(ushort pVersion, string pPatchLocation, byte pLocale)
{
_encryptIV = new byte[4];
rnd.NextBytes(_encryptIV);
_decryptIV = new byte[4];
rnd.NextBytes(_decryptIV);
Packet packet = new Packet();
packet.WriteUShort(pVersion);
packet.WriteString(pPatchLocation);
packet.WriteBytes(_decryptIV);
packet.WriteBytes(_encryptIV);
packet.WriteByte(pLocale);
SendPacket(packet);
_mapleVersion = pVersion;
_maplePatchLocation = pPatchLocation;
_mapleLocale = pLocale;
//SwitchAESByVersion(pVersion);
}