當前位置: 首頁>>代碼示例>>C#>>正文


C# Player.getTarget方法代碼示例

本文整理匯總了C#中RS2.Server.player.Player.getTarget方法的典型用法代碼示例。如果您正苦於以下問題:C# Player.getTarget方法的具體用法?C# Player.getTarget怎麽用?C# Player.getTarget使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在RS2.Server.player.Player的用法示例。


在下文中一共展示了Player.getTarget方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: canWalk

 private bool canWalk(Player player, Packet packet, bool following)
 {
     if (player.getTemporaryAttribute("smeltingBar") != null)
     {
         Smelting.setAmountToZero(player);
         return false;
     }
     else if (player.getTemporaryAttribute("teleporting") != null && player.getTemporaryAttribute("homeTeleporting") == null)
     {
         return false;
     }
     else if (player.isFrozen())
     {
         player.getPackets().sendMessage("A magic force prevents you from moving!");
         return false;
     }
     else if (player.getDuel() != null)
     {
         if (player.getDuel().ruleEnabled(DuelSession.RULE.NO_MOVEMENT))
         {
             if (player.getDuel().getStatus() == 5 || player.getDuel().getStatus() == 6)
             {
                 if (player.getTarget() == null)
                     player.getPackets().sendMessage("Movement is disabled for this duel.");
                 return false;
             }
         }
     }
     else if (player.getTemporaryAttribute("unmovable") != null || player.getTemporaryAttribute("cantDoAnything") != null)
     {
         return false;
     }
     else if (player.isDead())
     {
         return false;
     }
     else if (player.getTeleportTo() != null)
     {
         return false;
     }
     return true;
 }
開發者ID:ramatronics,項目名稱:rsps,代碼行數:42,代碼來源:Walk.cs

示例2: newMagicAttack

        public static void newMagicAttack(Player p, Entity target, int id, bool ancients)
        {
            int index = getSpellIndex(p, id, ancients);
            bool autoCasting = p.getTemporaryAttribute("autoCasting") != null;
            bool fakeNPC = target != null && target is Npc && ((Npc)target).getId() == 0;
            Entity lastAutocastEntity = null;
            bool frozen = false;
            if (index == -1)
            {
                return;
            }
            if (p.getTarget() == null)
            {
                if (autoCasting)
                {
                    if (Location.inMultiCombat(p.getLocation()))
                    {
                        lastAutocastEntity = (Entity)p.getTemporaryAttribute("autocastEntity") == null ? null : (Entity)p.getTemporaryAttribute("autocastEntity");
                        if (lastAutocastEntity == null || lastAutocastEntity is Player)
                        {
                            p.removeTemporaryAttribute("autoCasting");
                            Combat.resetCombat(p, 1);
                            return;
                        }
                        if (hitsMulti(p, index))
                        {
                            Location location = (Location)p.getTemporaryAttribute("autocastLocation");
                            Entity newTarget = new Npc(0);
                            newTarget.setLocation(location);
                            p.setTarget(newTarget);
                            newMagicAttack(p, newTarget, id, ancients);
                            return;
                        }
                    }
                    else
                    {
                        p.removeTemporaryAttribute("autoCasting");
                        Combat.resetCombat(p, 1);
                        return;
                    }
                }
                else
                {
                    p.removeTemporaryAttribute("autoCasting");
                    Combat.resetCombat(p, 1);
                    return;
                }
            }
            else
            {
                if (!canCastSpell(p, target, index, fakeNPC))
                {
                    p.removeTemporaryAttribute("autoCasting");
                    Combat.resetCombat(p, 1);
                    return;
                }
            }
            int distance = 8;
            if (target is Player)
            {
                if (((Player)target).getSprites().getPrimarySprite() != -1)
                {
                    distance = 8;
                }
            }
            if (!fakeNPC)
            { // we're actually attacking a real npc/player
                if (!p.getLocation().withinDistance(target.getLocation(), distance))
                {
                    p.getFollow().setFollowing(target);

                    Event attemptMagicAttackEvent = new Event(500);
                    int attemptMagicAttackCounter = 0;
                    attemptMagicAttackEvent.setAction(() =>
                    {
                        if (p.getLocation().withinDistance(target.getLocation(), distance) && p.getTarget() != null)
                        {
                            attemptMagicAttackEvent.stop();
                            newMagicAttack(p, target, id, ancients);
                            return;
                        }
                        attemptMagicAttackCounter++;
                        if (attemptMagicAttackCounter >= 12)
                        {
                            attemptMagicAttackEvent.stop();
                        }
                    });
                    Server.registerEvent(attemptMagicAttackEvent);
                    return;
                }
            }
            int timeSinceLastCast = autoCasting ? 3500 : 2000;
            if (Environment.TickCount - p.getLastMagicAttack() < timeSinceLastCast)
            {
                p.getWalkingQueue().resetWalkingQueue();
                //return;
            }
            int time = p.getLastCombatType().Equals(Combat.CombatType.MAGE) ? 1550 : 600;
            if (Environment.TickCount - p.getLastAttack() < time)
            {
//.........這裏部分代碼省略.........
開發者ID:ramatronics,項目名稱:rsps,代碼行數:101,代碼來源:MagicCombat.cs

示例3: handlePacket

        public void handlePacket(Player player, Packet packet)
        {
            int size = packet.getLength();
            if (packet.getPacketId() == PacketHandlers.PacketId.WALK_2)
            {
                size -= 14;
            }
            player.getWalkingQueue().resetWalkingQueue();
            int steps = (size - 5) / 2;

            if (steps > WalkingQueue.MAX_WALKING_WAYPOINTS)
            {
                Misc.WriteError("Warning: Walk command contains too many steps (" + steps + ") currently set to 50 [maybe need increase?]");
                return;
            }

            player.getWalkingQueue().setIsRunning(packet.readByteA() == 1);
            bool following = false;
            if (!canWalk(player, packet, following))
            {
                player.getPackets().clearMapFlag();
                player.getWalkingQueue().resetWalkingQueue();
                return;
            }

            int firstX = packet.readUShort() - (player.getLocation().getRegionX() - 6) * 8;
            int firstY = packet.readShortA() - (player.getLocation().getRegionY() - 6) * 8;
            player.getWalkingQueue().addToWalkingQueue(firstX, firstY);

            for (int i = 0; i < steps; i++) //all the waypoints.
                player.getWalkingQueue().addToWalkingQueue((packet.readByteA() + firstX), (packet.readByteS() + firstY));

            if (player.getTeleportTo() != null) //is teleporting?
                player.getWalkingQueue().resetWalkingQueue();

            if (player.getTemporaryAttribute("homeTeleporting") != null)
            {
                player.removeTemporaryAttribute("homeTeleporting");
            }
            SkillHandler.resetAllSkills(player);
            if (player.getTrade() != null)
                player.getTrade().decline();
            if (player.getDuel() != null)
            {
                if (player.getDuel().getStatus() < 4)
                    player.getDuel().declineDuel();
                else if (player.getDuel().getStatus() == 8)
                    player.getDuel().recieveWinnings(player);
            }
            if (player.getTarget() != null)
            {
                if (!following && player.getTarget().getAttacker() != null && player.getTarget().getAttacker().Equals(player))
                    player.getTarget().setAttacker(null);
            }

            if (!following)
            {
                player.getFollow().setFollowing(null);
                player.setTarget(null);
                player.removeTemporaryAttribute("autoCasting");
                if (player.getEntityFocus() != 65535)
                    player.setEntityFocus(65535);
            }
            player.getPackets().closeInterfaces();
        }
開發者ID:ramatronics,項目名稱:rsps,代碼行數:65,代碼來源:Walk.cs


注:本文中的RS2.Server.player.Player.getTarget方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。