本文整理汇总了C#中Solar.FiestaLib.Networking.Packet.TryReadUShort方法的典型用法代码示例。如果您正苦于以下问题:C# Packet.TryReadUShort方法的具体用法?C# Packet.TryReadUShort怎么用?C# Packet.TryReadUShort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Solar.FiestaLib.Networking.Packet
的用法示例。
在下文中一共展示了Packet.TryReadUShort方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VersionInfo
public static void VersionInfo(LoginClient pClient, Packet pPacket)
{
ushort year;
ushort version;
if (!pPacket.TryReadUShort(out year) ||
!pPacket.TryReadUShort(out version))
{
Log.WriteLine(LogLevel.Warn, "Invalid client version.");
pClient.Disconnect();
return;
}
Log.WriteLine(LogLevel.Debug, "Client version {0}:{1}.", year, version);
using (Packet response = new Packet(SH3Type.VersionAllowed))
{
response.WriteShort(1);
pClient.SendPacket(response);
}
}
示例2: AttackSkillHandler
public static void AttackSkillHandler(ZoneClient client, Packet packet)
{
ushort skill;
if (!packet.TryReadUShort(out skill))
{
Log.WriteLine(LogLevel.Warn, "Could not read skillID from attack entity skill function. {0}", client);
return;
}
if (!client.Character.SkillsActive.ContainsKey(skill))
{
Log.WriteLine(LogLevel.Warn, "User tried to attack with a wrong skill. {0} {1} ", skill, client);
return;
}
client.Character.AttackSkill(skill, null);
}
示例3: BeginInteractionHandler
public static void BeginInteractionHandler(ZoneClient client, Packet packet)
{
ushort entityid;
if (!packet.TryReadUShort(out entityid))
{
Log.WriteLine(LogLevel.Warn, "Error reading interaction attempt.");
return;
}
ZoneCharacter character = client.Character;
MapObject obj;
if (character.Map.Objects.TryGetValue(entityid, out obj))
{
NPC npc = obj as NPC;
if (npc != null)
{
if (npc.Gate != null)
{
MapInfo mi = null;
if (DataProvider.Instance.MapsByName.TryGetValue(npc.Gate.MapServer, out mi))
{
Question q = new Question(string.Format("Do you want to move to {0} field?", mi.FullName), new QuestionCallback(AnswerOnGateQuestion), npc);
q.Add("Yes", "No");
q.Send(character, 500);
character.Question = q;
}
else
{
character.DropMessage("You can't travel to this place.");
}
}
else
{
SendNPCInteraction(client, npc.ID);
}
}
}
else Log.WriteLine(LogLevel.Warn, "{0} selected invalid object.", character.Name);
}
示例4: SelectObjectHandler
public static void SelectObjectHandler(ZoneClient client, Packet packet)
{
ushort id;
if (!packet.TryReadUShort(out id))
{
Log.WriteLine(LogLevel.Warn, "Could not read entity select request.");
return;
}
MapObject mo;
// Try to see if there is a map object with this ID
if (!client.Character.Map.Objects.TryGetValue(id, out mo))
{
return; // Nothing found. Just return lawl
}
mo.SelectedBy.Add(client.Character);
if (mo is ZoneCharacter || mo is Mob)
{
client.Character.SelectedObject = mo;
SendStatsUpdate(mo, client, false);
}
}
示例5: UseSkillWithTargetHandler
public static void UseSkillWithTargetHandler(ZoneClient client, Packet packet)
{
ushort skillid, victimid;
if (!packet.TryReadUShort(out skillid) || !packet.TryReadUShort(out victimid))
{
Log.WriteLine(LogLevel.Warn, "Couldn't read useskill packet {0}", client);
return;
}
Skill skill;
if (!client.Character.SkillsActive.TryGetValue(skillid, out skill))
{
Log.WriteLine(LogLevel.Warn, "User tried to use a wrong skill. {0} {1} ", skillid, client);
return;
}
MapObject victim;
if (!client.Character.MapSector.Objects.TryGetValue(victimid, out victim))
{
Log.WriteLine(LogLevel.Warn, "User tried to do something with an unknown victim. {0} {1} {2}", skillid, victimid, client);
}
var self = client.Character;
if (skill.Info.DemandType == 6)
{
if (!(victim is ZoneCharacter)) return;
var zc = victim as ZoneCharacter;
// Only Heal has this
// Some heal calculation here
uint amount = 12 * (uint)Program.Randomizer.Next(1, 300); //lulz
if (amount > victim.MaxHP - victim.HP)
{
amount = victim.MaxHP - victim.HP;
}
zc.HP += amount;
ushort id = self.UpdateCounter;
SendSkillStartSelf(self, skillid, victimid, id);
SendSkillStartOthers(self, skillid, victimid, id);
SendSkillOK(self);
SendSkillAnimationForPlayer(self, skillid, id);
// Damage as heal val :D
SendSkill(self, id, victimid, amount, zc.HP, zc.UpdateCounter);
}
else
{
if (!(victim is Mob)) return;
uint dmgmin = (uint)self.GetWeaponDamage(true);
uint dmgmax = (uint)(self.GetWeaponDamage(true) + (self.GetWeaponDamage(true) % 3));
uint amount = (uint)Program.Randomizer.Next((int)dmgmin, (int)dmgmax);
if (amount > victim.HP)
{
victim.HP = 0;
}
else {
victim.HP -= amount;
}
ushort id = self.UpdateCounter;
SendSkillStartSelf(self, skillid, victimid, id);
SendSkillStartOthers(self, skillid, victimid, id);
SendSkillOK(self);
SendSkillAnimationForPlayer(self, skillid, id);
SendSkill(self, id, victimid, amount, victim.HP, victim.UpdateCounter, 0x01, 0x01);
if (!victim.IsDead)
{
victim.Attack(self);
}
}
}
示例6: UseSkillWithPositionHandler
public static void UseSkillWithPositionHandler(ZoneClient client, Packet packet)
{
ushort skillid;
uint x, y;
if (!packet.TryReadUShort(out skillid) || !packet.TryReadUInt(out x) || !packet.TryReadUInt(out y))
{
Log.WriteLine(LogLevel.Warn, "Couldn't read UseSkillWithPosition packet. {0} ", client);
return;
}
Skill skill;
if (!client.Character.SkillsActive.TryGetValue(skillid, out skill))
{
Log.WriteLine(LogLevel.Warn, "User tried to use a wrong skill. {0} {1} ", skillid, client);
return;
}
var self = client.Character;
var block = self.Map.Block;
if (x == 0 || y == 0 || x > block.Width || y > block.Height)
{
Log.WriteLine(LogLevel.Warn, "User tried to use skill out of map boundaries. {0} {1} {2} {3}", x, y, skillid, client);
return;
}
var pos = new Vector2((int)x, (int)y);
if (skill.Info.MaxTargets <= 1)
{
// No AoE skill :s
Log.WriteLine(LogLevel.Warn, "User tried to use skill with no MaxTargets or less than 1. {0} {1}", skillid, client);
return;
}
self.AttackSkillAoE(skillid, x, y);
}
示例7: TransferKeyHandler
public static void TransferKeyHandler(ZoneClient client, Packet packet)
{
ushort randomID;
string characterName, checksums; //TODO: check in securityclient
if (!packet.TryReadUShort(out randomID) || !packet.TryReadString(out characterName, 16) ||
!packet.TryReadString(out checksums, 832))
{
Log.WriteLine(LogLevel.Warn, "Invalid game transfer.");
return;
}
ClientTransfer transfer = ClientManager.Instance.GetTransfer(characterName);
if (transfer == null || transfer.HostIP != client.Host || transfer.RandID != randomID)
{
Log.WriteLine(LogLevel.Warn, "{0} tried to login without a valid client transfer.", client.Host);
//Handler3.SendError(client, ServerError.INVALID_CREDENTIALS);
Handler4.SendConnectError(client, ConnectErrors.RequestedCharacterIDNotMatching);
return;
}
try
{
ClientManager.Instance.RemoveTransfer(characterName);
ZoneCharacter character = new ZoneCharacter(characterName);
if (character.AccountID != transfer.AccountID)
{
Log.WriteLine(LogLevel.Warn, "Character is logging in with wrong account ID.");
Handler4.SendConnectError(client, ConnectErrors.RequestedCharacterIDNotMatching);
//Handler3.SendError(client, ServerError.INVALID_CREDENTIALS);
return;
}
client.Authenticated = true;
client.Admin = transfer.Admin;
client.AccountID = transfer.AccountID;
client.Username = transfer.Username;
client.Character = character;
character.Client = client;
if (ClientManager.Instance.AddClient(client))
{
character.SendGetIngameChunk(); //TODO: world server notification over WCF?
Log.WriteLine(LogLevel.Debug, "{0} logged in successfully!", character.Name);
}
}
catch (Exception ex)
{
Log.WriteLine(LogLevel.Exception, "Error loading character {0}: {1} - {2}", characterName, ex.ToString(), ex.StackTrace);
Handler4.SendConnectError(client, ConnectErrors.ErrorInCharacterInfo);
}
}
示例8: LootHandler
public static void LootHandler(ZoneClient client, Packet packet)
{
ushort id;
if (!packet.TryReadUShort(out id))
{
Log.WriteLine(LogLevel.Warn, "Invalid loot request.");
return;
}
client.Character.LootItem(id);
}