当前位置: 首页>>代码示例>>C#>>正文


C# Player.getAttacker方法代码示例

本文整理汇总了C#中WorldServer.player.Player.getAttacker方法的典型用法代码示例。如果您正苦于以下问题:C# Player.getAttacker方法的具体用法?C# Player.getAttacker怎么用?C# Player.getAttacker使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WorldServer.player.Player的用法示例。


在下文中一共展示了Player.getAttacker方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: canCastSpell

 private static bool canCastSpell(Player p, Entity target, int i, bool fakeNPC)
 {
     // fakeNPC is used to keep location when autocasting.
     if (fakeNPC) {
         return !p.isDead();
     }
     if (target.isDead() || p.isDead() || target.isDestroyed() || p.isDestroyed()) {
         return false;
     }
     if (target is Npc) {
         if (((Npc) target).getHp() <= 0) {
             return false;
         }
         if (i == 47) {
             p.getPackets().sendMessage("You cannot cast Teleblock upon an NPC.");
             return false;
         }
     }
     if ((target is Player) && (p is Player)) {
         if (Location.inFightPits(target.getLocation()) && Location.inFightPits(target.getLocation()))
         {
             if (!Server.getMinigames().getFightPits().hasGameStarted()) {
                 return false;
             }
             return true;
         }
         if (p.getDuel() != null) {
             if (((Player)target).getDuel() != null) {
                 if (p.getDuel().getPlayer2().Equals(((Player) target)) && ((Player) target).getDuel().getPlayer2().Equals(p)) {
                     if (p.getDuel().ruleEnabled(DuelSession.RULE.NO_MAGIC)) {
                         p.getPackets().sendMessage("Magical combat has been disabled in this duel!");
                         return false;
                     }
                     if (p.getDuel().getStatus() == 6 && ((Player) target).getDuel().getStatus() == 6) {
                         return true;
                     }
                 }
             }
             p.getPackets().sendMessage("That isn't your opponent.");
             return false;
         }
         if (i == 47) {
             if (((Player)target).getTemporaryAttribute("teleblocked") != null) {
                 p.getPackets().sendMessage("That player already has a teleportation block upon them.");
                 return false;
             }
         }
         if (!Location.inWilderness(target.getLocation())) {
             p.getPackets().sendMessage("That player isn't in the wilderness.");
             return false;
         }
         if (!Location.inWilderness(p.getLocation()))
         {
             p.getPackets().sendMessage("You aren't in the wilderness.");
             return false;
         }
         int killerWildLevel = p.getLocation().wildernessLevel();
         int targetWildLevel = ((Player)target).getLocation().wildernessLevel();
         int killerCombatLevel = p.getSkills().getCombatLevel();
         int targetCombatLevel = ((Player)target).getSkills().getCombatLevel();
         int highest = killerCombatLevel > targetCombatLevel ? killerCombatLevel : targetCombatLevel;
         int lowest = highest == killerCombatLevel ? targetCombatLevel : killerCombatLevel;
         int difference = (highest - lowest);
         if (difference > killerWildLevel || difference > targetWildLevel) {
             ((Player) p).getPackets().sendMessage("You must move deeper into the wilderness to attack that player.");
             return false;
         }
     }
     if (!Location.inMultiCombat(target.getLocation())) {
         if (p.getAttacker() != null && !p.getAttacker().Equals(target)) {
             p.getPackets().sendMessage("You are already in combat!");
             return false;
         }
         if (target.getAttacker() != null && !target.getAttacker().Equals(p)) {
             string type = target is Player ? "player" : "npc";
             p.getPackets().sendMessage("That " + type + " is already in combat.");
             return false;
         }
     }
     if (p.getSkills().getCurLevel(Skills.SKILL.MAGIC) < SPELL_LEVEL[i]) {
         p.getPackets().sendMessage("You need a Magic level of " + SPELL_LEVEL[i] + " to cast that spell.");
         return false;
     }
     if (!hasRunes(p, RUNES[i], RUNE_AMOUNTS[i])) {
         p.getPackets().sendMessage("You do not have enough runes to cast that spell.");
         return false;
     }
     if (NEEDS_STAFF[i]) {
         if ((i != 38 && p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON) != STAFF[i]) || (i == 38 && p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON) != 8841 && p.getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON) != STAFF[i]))
         {
             p.getPackets().sendMessage("You need to wield " + STAFF_NAME[i] + " to cast this spell.");
             return false;
         }
     }
     if (i == 37) {
         if (p.getEquipment().getItemInSlot(ItemData.EQUIP.CAPE) != 2412)
         {
             p.getPackets().sendMessage("You need to wear the Cape of Saradomin to be able to cast Saradomin Strike.");
             return false;
         }
//.........这里部分代码省略.........
开发者ID:Krill156,项目名称:SharpEMU,代码行数:101,代码来源:MagicCombat.cs


注:本文中的WorldServer.player.Player.getAttacker方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。