本文整理汇总了C#中Packet.ReadShort方法的典型用法代码示例。如果您正苦于以下问题:C# Packet.ReadShort方法的具体用法?C# Packet.ReadShort怎么用?C# Packet.ReadShort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Packet
的用法示例。
在下文中一共展示了Packet.ReadShort方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleValidate
public static void HandleValidate(Client pClient, Packet pPacket)
{
byte Locale = pPacket.ReadByte();
short Major = pPacket.ReadShort();
short Minor = pPacket.ReadShort();
Console.WriteLine("Handshake received, Locale: {0}, Major: {1}, Minor: {2}.", Locale, Major, Minor);
//if (Locale != 8 || Major != 141 || Minor != 2)
//{
// pClient.Disconnect();
//}
}
示例2: ReqSceneMove
public ReqSceneMove(Packet packet)
{
this._scene_rot_pos = new MsgSceneRotPos(packet);
this._forward = new MsgSceneVector3(packet);
this._ani_name = packet.ReadString();
this._x_axis = packet.ReadShort();
}
示例3: ParseMovement
public static List<LifeMovementFragment> ParseMovement(Packet pPacket, int pKind)
{
List<LifeMovementFragment> Res = new List<LifeMovementFragment>();
byte CommandCount = pPacket.ReadByte();
for (byte i = 0; i < CommandCount; i++)
{
byte Command = pPacket.ReadByte();
switch (Command)
{
case 0:
case 7:
case 14:
case 16:
case 44:
case 45:
case 46:
{
short X = pPacket.ReadShort();
short Y = pPacket.ReadShort();
short XWobble = pPacket.ReadShort();
short YWobble = pPacket.ReadShort();
short Unknown = pPacket.ReadShort();
short Foothold = 0, XOffset = 0, YOffset = 0;
if (Command == 14)
Foothold = pPacket.ReadShort();
if (Command != 44)
{
XOffset = pPacket.ReadShort();
YOffset = pPacket.ReadShort();
}
byte NewState = pPacket.ReadByte();
short Duration = pPacket.ReadShort();
AbsoluteLifeMovement ALM = new AbsoluteLifeMovement(Command, new Pos(X, Y), Duration, NewState);
//ALM.Unknown = Unknown;
//ALM.Foothold = Foothold;
//ALM.PixelsPerSecond = new Pos(XWobble, YWobble);
//ALM.Offset = new Pos(XOffset, YOffset);
Res.Add(ALM);
break;
}
}
}
return Res;
}
示例4: HandlePacket
public void HandlePacket(Packet p, NetworkPlayer player)
{
byte num = p.ReadByte();
switch (num)
{
case 0:
string name = p.ReadString();
player.PlayerName = name;
Packet255SCConnectionFirmed packet2 = new Packet255SCConnectionFirmed(player.PlayerID);
SendPacket(packet2, player.NetConnection);
foreach (NetworkPlayer pl in GameServer.NetworkPlayers)
{
var packet = new Packet0SCPlayerConnect(pl.PlayerName, pl.PlayerID, pl.EntityPosition);
SendPacket(packet, player.NetConnection);
if (pl == player) continue;
packet = new Packet0SCPlayerConnect(player.PlayerName,
player.PlayerID, player.EntityPosition);
SendPacket(packet, pl.NetConnection);
}
ServerConsole.Log("New player \"" + name + "\" connected.");
break;
//A game event, JC!
case 1:
byte eventID = p.ReadByte();
GameServer.HandleGameEvent(eventID, p, player);
break;
case 2:
int pX = p.ReadInt();
int pY = p.ReadInt();
GameServer.SetBlock(pX, pY, 0, true, 0);
break;
case 4:
byte flags = p.ReadByte();
if (player.MovementFlags != flags)
{
player.UpdateMask |= (int)PlayerUpdateFlags.Player_Update;
player.UpdateMask |= (int)PlayerUpdateFlags.Player_Movement_Flags;
}
player.MovementFlags = flags;
break;
case 5:
flags = p.ReadByte();
float angle = p.ReadShort().DToR();
if (player.MovementFlags != flags || angle != player.PlayerAimAngle)
{
player.UpdateMask |= (int)PlayerUpdateFlags.Player_Update;
player.UpdateMask |= (int)PlayerUpdateFlags.Player_Movement_Flags;
}
player.MovementFlags = flags;
player.PlayerAimAngle = angle;
break;
}
}
示例5: MsgSceneRotPos
public MsgSceneRotPos(Packet packet)
{
this._rot_x = packet.ReadShort();
this._rot_y = packet.ReadShort();
this._rot_z = packet.ReadShort();
this._pos_x = packet.ReadShort();
this._pos_y = packet.ReadShort();
this._pos_z = packet.ReadShort();
}
示例6: MsgSceneVector3
public MsgSceneVector3(Packet packet)
{
this._x = packet.ReadShort();
this._y = packet.ReadShort();
this._z = packet.ReadShort();
}
示例7: HandleCreateCharacter
public static void HandleCreateCharacter(Client pClient, Packet pPacket)
{
if (pClient.Account.LoggedIn != 1) { return; }
List<Equip> equips = new List<Equip>();
string name = pPacket.ReadMapleString();
pPacket.ReadInt();
int startMap = 0;
int jobType = pPacket.ReadInt();
short jobSubtype = pPacket.ReadShort();
byte gender = pPacket.ReadByte();
byte skin = pPacket.ReadByte();
pPacket.ReadByte();
int face = pPacket.ReadInt();
int hair = pPacket.ReadInt();
int hairColor = -1, faceMark = -1, topId, bottomId = -1, capeId = -1, shoesId, weaponId, shieldId = -1;
if (Constants.CharacterCreation.hasHairColor(jobType))
hairColor = pPacket.ReadInt();
if (Constants.CharacterCreation.hasSkinColor(jobType))
pPacket.ReadInt();
if (Constants.CharacterCreation.hasFaceMark(jobType))
faceMark = pPacket.ReadInt();
if (Constants.CharacterCreation.hasHat(jobType))
{
int capId = pPacket.ReadInt();
Equip cap = new Equip();
cap.ItemID = capId;
cap.GiveStats(false);
cap.InventorySlot = -1;
equips.Add(cap);
}
topId = pPacket.ReadInt();
Equip top = new Equip();
top.ItemID = topId;
top.GiveStats(false);
top.InventorySlot = -5;
equips.Add(top);
if (Constants.CharacterCreation.hasBottom(jobType))
{
bottomId = pPacket.ReadInt();
Equip bottom = new Equip();
bottom.ItemID = bottomId;
bottom.GiveStats(false);
bottom.InventorySlot = -6;
equips.Add(bottom);
}
if (Constants.CharacterCreation.hasCape(jobType))
{
capeId = pPacket.ReadInt();
Equip cape = new Equip();
cape.ItemID = capeId;
cape.GiveStats(false);
cape.InventorySlot = -9;
equips.Add(cape);
}
shoesId = pPacket.ReadInt();
Equip shoes = new Equip();
shoes.ItemID = shoesId;
shoes.GiveStats(false);
shoes.InventorySlot = -7;
equips.Add(shoes);
weaponId = pPacket.ReadInt();
Equip weapon = new Equip();
weapon.ItemID = weaponId;
weapon.GiveStats(false);
weapon.InventorySlot = -11;
equips.Add(weapon);
if (jobType == (int)Constants.CharacterCreation.CreateTypes.Demon)
{
shieldId = pPacket.ReadInt();
Equip shield = new Equip();
shield.ItemID = shieldId;
shield.GiveStats(false);
shield.InventorySlot = -10;
equips.Add(shield);
}
Character newChr = new Character();
newChr.Client = pClient;
newChr.AccountId = pClient.Account.Id;
newChr.WorldId = pClient.World;
newChr.Name = name;
newChr.MapId = Constants.CharacterCreation.GetMapByType(jobType);
if (hairColor < 0) hairColor = 0;
if (jobType != (short)Constants.CharacterCreation.CreateTypes.Mihile)
{
hair += hairColor;
//.........这里部分代码省略.........
示例8: HandleGameEvent
public static void HandleGameEvent(byte eventID, Packet p)
{
switch ((GameServer.GameEvents)eventID)
{
case GameServer.GameEvents.Block_Set:
SetBlock(p.ReadShort(), p.ReadShort(), p.ReadShort(), true, p.ReadByte());
break;
case GameServer.GameEvents.Block_Set_ID:
SetBlock(p.ReadShort(), p.ReadShort(), p.ReadShort());
break;
case GameServer.GameEvents.Block_Set_MD:
short X = p.ReadShort();
short Y = p.ReadShort();
SetBlockMetaData(X, Y, p.ReadByte());
break;
case GameServer.GameEvents.Block_Set_Line:
short startX = p.ReadShort();
short startY = p.ReadShort();
long maskID = p.ReadLong();
long maskMD = p.ReadLong();
bool[] IDUpdate = maskID.BitMaskToBools();
bool[] MDUpdate = maskMD.BitMaskToBools();
for (int i = 0; i < 64; i++)
{
if (IDUpdate[i])
{
SetBlock(startX, startY + i, p.ReadShort());
}
if (MDUpdate[i])
{
SetBlockMetaData(startX, startY + i, p.ReadByte());
}
}
break;
case GameServer.GameEvents.Player_Chat:
byte playerID = p.ReadByte();
bool teamChat = p.ReadBool();
string chatText = p.ReadString();
if (playerID == ThePlayer.PlayerEntity.PlayerID)
{
ChatInterface.AddChat(new ChatEntry(ThePlayer.PlayerEntity.PlayerName, chatText, Color.White, teamChat));
}
else if (playerID != 0)
{
foreach (PlayerEntity pe in OtherPlayers)
{
if (pe.PlayerID == playerID)
{
ChatInterface.AddChat(new ChatEntry(pe.PlayerName, chatText, Color.White, teamChat));
}
}
}
else
{
ChatInterface.AddChat(new ChatEntry("Server", chatText, Color.Blue, false));
}
break;
case GameServer.GameEvents.Player_Position:
playerID = p.ReadByte();
int x = p.ReadInt();
int y = p.ReadInt();
if (playerID == ThePlayer.PlayerEntity.PlayerID)
{
ThePlayer.PlayerEntity.EntityPosition = new Vector2(x, y);
}
else
{
foreach (PlayerEntity pe in OtherPlayers)
{
if (pe.PlayerID == playerID)
{
pe.EntityPosition = new Vector2(x, y);
}
}
}
break;
case GameServer.GameEvents.Player_Aim_And_Position:
playerID = p.ReadByte();
x = p.ReadShort();
y = p.ReadShort();
if (playerID == ThePlayer.PlayerEntity.PlayerID)
{
ThePlayer.PlayerEntity.EntityPosition = new Vector2(x, y);
}
else
{
foreach (PlayerEntity pe in OtherPlayers)
{
if (pe.PlayerID == playerID)
{
pe.EntityPosition = new Vector2(x, y);
}
}
//.........这里部分代码省略.........
示例9: PlayerUpdating
public static void PlayerUpdating(Packet p)
{
int numToUpdate = p.ReadByte();
List<byte> playersUpdated = new List<byte>();
List<byte> allPlayers = GameWorld.OtherPlayers.Select(pl => pl.PlayerID).ToList();
for (int i = 0; i < numToUpdate; i++)
{
int playerID = p.ReadByte();
playersUpdated.Add((byte)playerID);
PlayerEntity player;
if (playerID == GameWorld.ThePlayer.PlayerEntity.PlayerID)
player = GameWorld.ThePlayer.PlayerEntity;
else
{
player = GameWorld.OtherPlayers.Where(pl => pl.PlayerID == playerID).FirstOrDefault();
}
if (player == null) player = new PlayerEntity(Vector2.Zero, (byte)playerID);
byte updateMask = p.ReadByte();
if ((updateMask & (int)PlayerUpdateFlags.Player_Position) != 0)
{
short x = p.ReadShort();
short y = p.ReadShort();
player.EntityPosition.X = x;
player.EntityPosition.Y = y;
}
if ((updateMask & (int)PlayerUpdateFlags.Player_Movement_Flags) != 0)
{
byte flags = p.ReadByte();
player.OtherPlayerNetworkFlags = flags;
bool leftPress = (flags & (int)PlayerMovementFlag.Left_Pressed) != 0;
bool rightPress = (flags & (int)PlayerMovementFlag.Right_Pressed) != 0;
bool idle = (flags & (int)PlayerMovementFlag.Idle) != 0;
if (leftPress || rightPress)
{
player.FacingLeft = leftPress && !rightPress;
if (!(leftPress && rightPress))
{
player.TorsoAnimateable.StartLooping("player_run_start", "player_run_end");
player.LegsAnimateable.StartLooping("player_run_start", "player_run_end");
}
else
{
player.TorsoAnimateable.StartLooping("player_idle", "player_idle");
player.LegsAnimateable.StartLooping("player_idle", "player_idle");
}
}
if (idle)
{
player.TorsoAnimateable.StartLooping("player_idle", "player_idle");
player.LegsAnimateable.StartLooping("player_idle", "player_idle");
}
}
if ((updateMask & (int)PlayerUpdateFlags.Player_Class_Update) != 0)
{
player.PClass.ReadState(p);
}
}
}
示例10: HandlePacket
public static void HandlePacket(byte packetID, Packet p)
{
switch (packetID)
{
case 0:
string pName = p.ReadString();
byte id = p.ReadByte();
int posX = p.ReadInt();
int posY = p.ReadInt();
if (OtherPlayers.Where(pl => pl.PlayerID == id).Count() > 0) return;
if (ThePlayer.PlayerEntity.PlayerID != id)
{
ConsoleManager.Log("New player: " + pName + " id: " + id + " x: " + posX + " y: " + posY);
OtherPlayers.Add(new PlayerEntity(new Vector2(posX, posY), id, pName));
}
else
{
ThePlayer.PlayerEntity.EntityPosition = new Vector2(posX, posY);
}
break;
case 1:
HandleGameEvent(p.ReadByte(), p);
break;
case 2:
byte type = p.ReadByte();
byte ID = p.ReadByte();
short X = p.ReadShort();
short Y = p.ReadShort();
short angle = p.ReadShort();
byte strength = p.ReadByte();
byte owner = p.ReadByte();
GameProjectiles.Add(new ProjectileArrow(new Vector2(X, Y), angle, owner, strength) { ProjectileID = ID });
break;
case 3:
byte toRemove = p.ReadByte();
EntityProjectile proj = null;
foreach (EntityProjectile projectile in GameProjectiles)
{
if (projectile.ProjectileID == toRemove)
{
proj = projectile;
break;
}
}
if (proj != null) GameProjectiles.Remove(proj);
break;
case 6:
byte playerID = p.ReadByte();
PlayerEntity player = PlayerOfID(playerID);
if (player == null) break;
player.OnAttack();
break;
case 7:
playerID = p.ReadByte();
byte itemID = p.ReadByte();
player = PlayerOfID(playerID);
if (player == null) break;
player.EquippedItem = Item.GetItem(itemID);
break;
case 8:
Vector2 pos = p.ReadVectorS();
Vector2 velocity = p.ReadVectorS();
short droppedID = p.ReadShort();
itemID = p.ReadByte();
EntityDroppedItem item = DroppedItemOfID(droppedID);
if (item != null)
break;
item = new EntityDroppedItem(pos, velocity, itemID, droppedID);
DroppedItems.Add(item);
break;
case 9:
droppedID = p.ReadShort();
byte pickerUpper = p.ReadByte();
player = PlayerOfID(pickerUpper);
item = DroppedItemOfID(droppedID);
if (item == null || player == null) break;
item.MovingTowards = player;
item.DroppedItemID = -1;
item.Incomplete = false;
break;
case 10:
droppedID = p.ReadShort();
item = DroppedItemOfID(droppedID);
if (item != null)
DroppedItems.Remove(item);
break;
case 12:
droppedID = p.ReadShort();
pickerUpper = p.ReadByte();
//.........这里部分代码省略.........
示例11: WorldSummary
/// <summary>
/// Initializes new instance of <see cref="WorldSummary"/> struct.
/// </summary>
/// <param name="p"><see cref="Packet"/> to read self data from.</param>
public WorldSummary( ref Packet p )
{
ID = p.ReadByte();
Address = p.ReadBytesArray(4);
Port = p.ReadInt();
AgeLimit = p.ReadByte();
IsPvP = p.InternalReadBool();
UsersMax = p.ReadShort();
UsersOnline = p.ReadShort();
ShowBrackets = p.InternalReadBool();
IsTestServer = p.InternalReadBool();
ShowClock = p.InternalReadBool();
IsOnline = p.InternalReadBool();
AccessLevel = p.ReadByte();
}
示例12: ParseMovementData
public static bool ParseMovementData(MovableLife pLife, Packet pPacket)
{
byte amount = pPacket.ReadByte();
byte type, Stance = pLife.Stance;
short Foothold = pLife.Foothold, X = pLife.Position.X, Y = pLife.Position.Y;
short startX = pLife.Position.X;
short startY = pLife.Position.Y;
bool toRet = true;
bool needCheck = true;
for (byte i = 0; i < amount; i++)
{
type = pPacket.ReadByte();
switch (type)
{
case 0x00: //normal move
case 0x05:
{
pLife.Position.X = pPacket.ReadShort();
pLife.Position.Y = pPacket.ReadShort();
pLife.Wobble.X = pPacket.ReadShort();
pLife.Wobble.Y = pPacket.ReadShort();
pLife.Foothold = pPacket.ReadShort();
pLife.Stance = pPacket.ReadByte();
if (Stance < 5)
pLife.Jumps = 0;
if (pLife.GetType() == typeof(Character) && Stance < 14 && Stance != 6 && Stance != 7)
{
float Speed = 100 / 100.0f;
toRet = CheatInspector.CheckSpeed(pLife.Wobble, (Speed));
}
else if (pLife.GetType() == typeof(Mob) && pLife.Wobble.Y != 0)
{
if (Stance == 7 || Stance == 6)
needCheck = false;
toRet = CheatInspector.CheckSpeed(pLife.Wobble, ((Mob)pLife).AllowedSpeed);
}
pPacket.Skip(2);
break;
}
case 0x01: //jump, here we check for jumpingshit
{
if (pLife.Jumps > 5) toRet = false;
X = pPacket.ReadShort();
Y = pPacket.ReadShort();
Stance = pPacket.ReadByte();
Foothold = pPacket.ReadShort();
pLife.Jumps++;
break;
}
case 0x02:
case 0x06:
{
X = pPacket.ReadShort();
Y = pPacket.ReadShort();
Stance = pPacket.ReadByte();
Foothold = pPacket.ReadShort();
break;
}
case 0x03:
case 0x04: //tele
case 0x07: //assaulter
{
X = pPacket.ReadShort();
Y = pPacket.ReadShort();
pLife.Wobble.X = pPacket.ReadShort();
pLife.Wobble.Y = pPacket.ReadShort();
Stance = pPacket.ReadByte();
if (type == 0x03 && pLife.GetType() == typeof(Character) && Stance != 7 && Stance != 6)
{
float Speed = 100 / 100.0f;
toRet = CheatInspector.CheckSpeed(pLife.Wobble, Speed);
}
break;
}
case 0x08:
{
pPacket.Skip(1);
break;
}
default:
{
Stance = pPacket.ReadByte();
//packet.Skip(2);
Foothold = pPacket.ReadShort();
break;
}
}
}
/*
if (!toRet) {
//.........这里部分代码省略.........
示例13: HandleGameEvent
public static void HandleGameEvent(byte eventID, Packet p, NetworkPlayer player)
{
switch ((GameEvents)eventID)
{
case GameEvents.Player_Drop_Item:
ServerItem inHand = player.Inventory.GetPlayerItemInHand();
if (inHand == null)
break;
player.DropItem();
break;
case GameEvents.Player_Use_Item:
short x = p.ReadShort();
short y = p.ReadShort();
ServerItem itemInHand = player.Inventory.GetPlayerItemInHand();
if (itemInHand == null) break;
itemInHand.OnItemUsed(x, y, player);
break;
case GameEvents.Player_Use_Block:
x = p.ReadShort();
y = p.ReadShort();
Block b = GetBlockAt(x, y).Block;
b.OnBlockUsed(x, y, player);
break;
case GameEvents.Player_Pickup_Block:
x = p.ReadShort();
y = p.ReadShort();
if (player.PClass is PlayerClassDestroyer) {
if (Math.Abs(player.EntityPosition.X / BlockSize - (float)(x)) < 2 && Math.Abs(player.EntityPosition.Y / BlockSize - (float)(y)) < 2)
((PlayerClassDestroyer)player.PClass).PickupBlock(new Vector2(x, y));
}
break;
case GameEvents.Player_Place_Block:
if (player.PClass is PlayerClassDestroyer)
{
((PlayerClassDestroyer)player.PClass).PlaceBlock();
}
break;
case GameEvents.Player_Inventory_Selection_Change:
player.SetPlayerEquippedSlot(p.ReadByte());
player.SendEquippedItemUpdate();
break;
case GameEvents.Player_Chat:
bool teamChat = p.ReadBool();
string chatText = p.ReadString();
ServerConsole.Log(player.PlayerName + ": " + chatText);
Packet1SCGameEvent pack = new Packet1SCGameEvent(GameEvents.Player_Chat, (byte)player.PlayerID, (bool)teamChat, chatText);
ServerNetworkManager.SendPacket(pack);
break;
case GameEvents.Player_Change_Name:
string newName = p.ReadString();
if (newName.Length > 0)
{
player.PlayerName = newName;
pack = new Packet1SCGameEvent(GameEvents.Player_Change_Name, (byte)player.PlayerID, newName);
ServerNetworkManager.SendPacket(pack);
}
break;
case GameEvents.Player_Choose_Team:
int team = p.ReadByte();
if (team != 0 && team != 1) return;
if (team == player.PlayerTeam) return;
player.PlayerTeam = team;
GameMode.OnPlayerChooseTeam(player, team);
player.HurtPlayer(10000);
Packet newP = new Packet1SCGameEvent(GameEvents.Player_Choose_Team, (byte)player.PlayerID, (byte)team);
ServerNetworkManager.SendPacket(newP);
break;
}
}
示例14: Pos
public Pos(Packet pPacket)
{
X = pPacket.ReadShort();
Y = pPacket.ReadShort();
}