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


C# Player.setLastCombatType方法代码示例

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


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

示例1: 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) {
                int delay = p.getLastCombatType().Equals(Combat.CombatType.MAGE) ? 1350 : 800;
                Event attemptMagicAttackEvent = new Event(500);
                attemptMagicAttackEvent.setAction(() => {
                    if (Environment.TickCount - p.getLastAttack() > delay) {
                        attemptMagicAttackEvent.stop();
                        newMagicAttack(p, target, id, ancients);
                    }
                });
                Server.registerEvent(attemptMagicAttackEvent);

                p.getWalkingQueue().resetWalkingQueue();
                p.getPackets().clearMapFlag();
                p.setLastCombatType(Combat.CombatType.MAGE);
                return;
            }
            if (fakeNPC && !monsterInArea(p, target)) {
                p.removeTemporaryAttribute("autoCasting");
                Combat.resetCombat(p, 1);
                return;
            }
            int endGfx = END_GFX[index];
//.........这里部分代码省略.........
开发者ID:Krill156,项目名称:SharpEMU,代码行数:101,代码来源:MagicCombat.cs


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