本文整理汇总了C#中PacketIn.ReadByte方法的典型用法代码示例。如果您正苦于以下问题:C# PacketIn.ReadByte方法的具体用法?C# PacketIn.ReadByte怎么用?C# PacketIn.ReadByte使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketIn
的用法示例。
在下文中一共展示了PacketIn.ReadByte方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuyNpcItem
public static void BuyNpcItem(Client client, PacketIn packet)
{
int npcWorldId = (int)packet.ReadUInt32();
byte v1 = packet.ReadByte();
byte amount = packet.ReadByte();
int totalPrice = 0;
ushort[] items = new ushort[amount];
ushort[] amounts = new ushort[amount];
for(int i=0;i<amount;i++)
{
items[i] = packet.ReadUShort();
amounts[i] = packet.ReadUShort();
// TODO, calculate correct price
totalPrice += 100 * amounts[i];
}
// TODO, add geon amount check
for(int i=0;i<amount;i++)
{
// should be items, not player items
PlayerItem item = PlayerItem.Get((int)items[i]);
client.Character.Player.Inventory.Items.Add(item);
// update AddToInventory with generic item-object
client.Send(new Packets.AddToInventory((int)items[i],(int)amounts[i]),"Buy Item");
// update amout of geons !
}
}
示例2: SkillExecute
public static void SkillExecute(Client client, PacketIn packet)
{
byte skillId = packet.ReadByte();
byte skillLvl = packet.ReadByte();
client.SkillHandler.Execute(skillId,skillLvl);
if(packet.PacketSize < 9) {
client.Send(new Packets.SkillExecute(client.Character,skillId,skillLvl));
return;
}
}
示例3: LearnSkill
public static void LearnSkill(Client client, PacketIn packet)
{
byte skillId = packet.ReadByte();
if(client.Character.Player.SkillPoints >= 1)
{
if(!client.Character.Skills.ContainsKey(skillId))
{
using(ISession session = Server.Factory.OpenSession())
{
PlayerSkill skill = new PlayerSkill();
skill.Level = 1;
skill.PlayerId = client.Character.Player.PlayerId;
skill.SkillIndex = (int)skillId;
client.Character.Skills[skillId] = skill;
client.Send(new Packets.SkillSet(skillId,(byte)1));
using(ITransaction transaction = session.BeginTransaction())
{
session.Save(skill);
transaction.Commit();
}
}
client.Character.Player.SkillPoints--;
client.Send(new Packets.ValueChange(0x18,(byte)client.Character.Player.SkillPoints));
}
}
}
示例4: SkillRequest
public static void SkillRequest(Client client,PacketIn packet)
{
byte skillId = packet.ReadByte();
uint playerId = packet.ReadUInt32();
client.SkillHandler.Request(skillId,playerId);
client.Send(new Packets.SkillExecute(client.Character,skillId,1));
}
示例5: PlayerChange
public static void PlayerChange(Client client, PacketIn packet)
{
byte b = packet.ReadByte();
if(b == 1) {
client.Send(new Packets.AcceptChange());
client.UnspawnPlayer();
client.SendPlayerList();
return;
}
}
示例6: UpgradeSkill
public static void UpgradeSkill(Client client, PacketIn packet)
{
byte skillId = packet.ReadByte();
if(client.Character.Player.SkillPoints >= 1)
{
if(client.Character.Skills.ContainsKey(skillId))
{
client.Character.Skills[skillId].Level += 1;
client.Send(new Packets.SkillSet(skillId,(byte)client.Character.Skills[skillId].Level));
using(ISession session = Server.Factory.OpenSession())
using(ITransaction transaction = session.BeginTransaction())
{
session.SaveOrUpdate(client.Character.Skills[skillId]);
transaction.Commit();
}
client.Character.Player.SkillPoints--;
client.Send(new Packets.ValueChange(0x18,(byte)client.Character.Player.SkillPoints));
}
}
}
示例7: CreatePlayer
public static void CreatePlayer(Client client, PacketIn packet)
{
string name = packet.ReadString();
byte type = packet.ReadByte();
byte strength = packet.ReadByte();
byte health = packet.ReadByte();
byte intelligence = packet.ReadByte();
byte wisdom = packet.ReadByte();
byte agility = packet.ReadByte();
byte face = packet.ReadByte();
byte hair = packet.ReadByte();
if((strength + health + intelligence + wisdom + agility) != 5)
{
client.Send(new Packets.CharacterCreationError(Packets.CHARACTER_CREATION_ERROR.SHARING_POINTS_ERROR));
Hackshield.AddOffense(client, OffenseSeverity.IncorrectPacketDetails);
return;
}
//check if name is valid
if (!Utilities.IsAlnum(name))
{
client.Send(new Packets.CharacterError(Packets.CHARACTER_ERROR.INVALID_CHARS));
return;
}
//check if player name is taken
if (Player.GetPlayer(name) != null)
{
client.Send(new Packets.CharacterCreationError(Packets.CHARACTER_CREATION_ERROR.NAME_TAKEN));
return;
}
int playerId = client.CreatePlayer(name, type, strength, health, intelligence, wisdom, agility, face, hair);
client.SendPlayerList();
}
示例8: SessionRequest
public static void SessionRequest(Client client,PacketIn packet)
{
if(packet.ReadByte() == 0) {
client.Send(new Packets.SessionRequest(),"Session Request");
}
}
示例9: SetStats
public static void SetStats(Client client, PacketIn packet)
{
int start;
byte value;
switch(packet.ReadByte())
{
// Strength
case 0:
{
start = (client.Character.Player.ClassId == 0) ? 60 : 50;
value = client.Character.Stats.Strength;
_UpdateStats(client,start,value);
client.Character.Stats.Strength += 1;
client.Send(new Packets.StatPacket.Strength(client.Character.Stats));
break;
}
// Health
case 1:
{
start = 50;
value = client.Character.Stats.Health;
_UpdateStats(client,start,value);
client.Character.Stats.Health += 1;
client.Send(new Packets.StatPacket.Health(client.Character.Stats));
break;
}
// Intelligence
case 2:
{
start = (client.Character.Player.ClassId == 1) ? 60 : 50;
value = client.Character.Stats.Intelligence;
_UpdateStats(client,start,value);
client.Character.Stats.Intelligence += 1;
client.Send(new Packets.StatPacket.Intelligence(client.Character.Stats));
break;
}
// Wisdom
case 3:
{
start = 50;
value = client.Character.Stats.Wisdom;
_UpdateStats(client,start,value);
client.Character.Stats.Wisdom += 1;
client.Send(new Packets.StatPacket.Wisdom(client.Character.Stats));
break;
}
// Agility
case 4:
{
start = (client.Character.Player.ClassId == 2) ? 60 : 50;
value = client.Character.Stats.Agility;
_UpdateStats(client,start,value);
client.Character.Stats.Agility += 1;
client.Send(new Packets.StatPacket.Agility(client.Character.Stats));
break;
}
}
}
示例10: SetStats
public static void SetStats(Client Client, PacketIn packet)
{
int Start;
int Value;
switch(packet.ReadByte())
{
// Strength
case 0:
{
Start = (Client.Character.Player.Class == 0) ? 60 : 50;
Value = Client.Character.Stats.BaseStats.Strength;
_UpdateStats(Client,Start,Value);
Client.Character.Stats.BaseStats.Strength += 1;
Client.Send(new Packets.StatPacket.Strength(Client.Character));
break;
}
// Health
case 1:
{
Start = 50;
Value = Client.Character.Stats.Health;
_UpdateStats(Client,Start,Value);
Client.Character.Stats.BaseStats.Health += 1;
Client.Send(new Packets.StatPacket.Health(Client.Character));
break;
}
// Intelligence
case 2:
{
Start = (Client.Character.Player.Class == 1) ? 60 : 50;
Value = Client.Character.Stats.Intelligence;
_UpdateStats(Client,Start,Value);
Client.Character.Stats.BaseStats.Intelligence += 1;
Client.Send(new Packets.StatPacket.Intelligence(Client.Character));
break;
}
// Wisdom
case 3:
{
Start = 50;
Value = Client.Character.Stats.Wisdom;
_UpdateStats(Client,Start,Value);
Client.Character.Stats.BaseStats.Wisdom += 1;
Client.Send(new Packets.StatPacket.Wisdom(Client.Character));
break;
}
// Agility
case 4:
{
Start = (Client.Character.Player.Class == 2) ? 60 : 50;
Value = Client.Character.Stats.Dexterity;
_UpdateStats(Client,Start,Value);
Client.Character.Stats.BaseStats.Dexterity += 1;
Client.Send(new Packets.StatPacket.Agility(Client.Character));
break;
}
}
}