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


C# Unit.IsInvul方法代码示例

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


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

示例1: Orbwalk

 /// <summary>
 ///     Orbwalks on given target if they are in range, while moving to mouse position
 /// </summary>
 /// <param name="target"></param>
 /// <param name="bonusWindupMs"></param>
 /// <param name="bonusRange"></param>
 /// <param name="attackmodifiers"></param>
 public static void Orbwalk(
     Unit target,
     float bonusWindupMs = 0,
     float bonusRange = 0,
     bool attackmodifiers = false)
 {
     if (me == null)
     {
         return;
     }
     var targetHull = 0f;
     if (target != null)
     {
         targetHull = target.HullRadius;
     }
     float distance = 0;
     if (target != null)
     {
         var pos = Prediction.InFront(
             me,
             (float)((Game.Ping / 1000 + me.GetTurnTime(target.Position)) * me.MovementSpeed));
         distance = pos.Distance2D(target) - me.Distance2D(target);
     }
     var isValid = target != null && target.IsValid && target.IsAlive && target.IsVisible
                   && target.Distance2D(me)
                   <= (me.GetAttackRange() + me.HullRadius + 50 + targetHull + bonusRange + distance);
     if (isValid || (target != null && me.IsAttacking() && me.GetTurnTime(target.Position) < 0.1))
     {
         var canAttack = (!AttackOnCooldown(target, bonusWindupMs) || !CanCancelAnimation())
                         && !target.IsAttackImmune() && !target.IsInvul() && me.CanAttack();
         if (canAttack && Utils.SleepCheck("Orbwalk.Attack"))
         {
             Attack(target, attackmodifiers);
             Utils.Sleep(100, "Orbwalk.Attack");
             return;
         }
     }
     var canCancel = (CanCancelAnimation() && AttackOnCooldown(target, bonusWindupMs))
                     || (!isValid && !me.IsAttacking());
     if (!canCancel || !Utils.SleepCheck("Orbwalk.Move"))
     {
         return;
     }
     me.Move(Game.MousePosition);
     Utils.Sleep(100, "Orbwalk.Move");
 }
开发者ID:MarkHC,项目名称:Ensage.Common,代码行数:53,代码来源:Orbwalking.cs

示例2: AttackIfCan

 private static void AttackIfCan(Unit source, Unit target)
 {
     if (target == null) return;
     if (source.CanAttack() && AttackTarget.isActive && !target.IsAttackImmune() && !target.IsInvul()) source.Attack(target);
 }
开发者ID:LimbViolencer,项目名称:EnsageSharp-6,代码行数:5,代码来源:EzUnitControl.cs

示例3: CastStun

        /// <summary>
        ///     Uses given ability in case enemy is not disabled or would be chain stunned.
        /// </summary>
        /// <param name="ability">
        ///     The ability.
        /// </param>
        /// <param name="target">
        ///     The target.
        /// </param>
        /// <param name="sourcePosition">
        ///     The source Position.
        /// </param>
        /// <param name="straightTimeforSkillShot">
        ///     The straight Time for Skill Shot.
        /// </param>
        /// <param name="chainStun">
        ///     The chain Stun.
        /// </param>
        /// <param name="useSleep">
        ///     The use Sleep.
        /// </param>
        /// <param name="abilityName">
        ///     The ability Name.
        /// </param>
        /// <param name="soulRing">
        ///     The soul Ring.
        /// </param>
        /// <param name="otherTargets">
        ///     The other Targets.
        /// </param>
        /// <returns>
        ///     returns true in case of successful cast
        /// </returns>
        public static bool CastStun(
            this Ability ability, 
            Unit target, 
            Vector3 sourcePosition, 
            float straightTimeforSkillShot = 0, 
            bool chainStun = true, 
            bool useSleep = true, 
            string abilityName = null, 
            Ability soulRing = null, 
            List<Unit> otherTargets = null)
        {
            if (!ability.CanBeCasted())
            {
                return false;
            }

            if (target == null || !target.IsValid)
            {
                return false;
            }

            var name = abilityName ?? ability.StoredName();
            var delay = ability.GetHitDelay(target, name) + 0.1f;
            var canUse = Utils.ChainStun(target, delay, null, false, name);
            if (!canUse && chainStun
                && (!target.HasModifier("modifier_pudge_meat_hook")
                    || (ability.StoredName() != "pudge_dismember" && ability.StoredName() != "pudge_rot")))
            {
                return false;
            }

            if (ability.IsAbilityBehavior(AbilityBehavior.UnitTarget, name) && name != "lion_impale"
                && !target.IsInvul())
            {
                if (!ability.CanHit(target, sourcePosition))
                {
                    return false;
                }

                if (ability.ManaCost > 0 && soulRing.CanBeCasted())
                {
                    soulRing.UseAbility();
                }

                ability.UseAbility(target);
            }
            else if (ability.IsAbilityBehavior(AbilityBehavior.AreaOfEffect, name)
                     || ability.IsAbilityBehavior(AbilityBehavior.Point, name) || name == "lion_impale"
                     || (name == "earthshaker_enchant_totem" && (ability.Owner as Hero).AghanimState())
                     || ability.IsSkillShot())
            {
                var stunned = target.IsStunned() || target.IsInvul() || target.IsRooted() || target.IsHexed();
                if ((!(Prediction.StraightTime(target) > straightTimeforSkillShot * 1000) && !stunned)
                    || !ability.CastSkillShot(target, name, soulRing, otherTargets))
                {
                    return false;
                }

                if (useSleep)
                {
                    Utils.Sleep(Math.Max(delay, 0.2) * 1000 + 250, "CHAINSTUN_SLEEP");
                }

                return true;
            }
            else if (ability.IsAbilityBehavior(AbilityBehavior.NoTarget, name))
            {
//.........这里部分代码省略.........
开发者ID:EnsageSharp,项目名称:Ensage.Common,代码行数:101,代码来源:AbilityExtensions.cs

示例4: Orbwalk

 private static void Orbwalk(Hero me,Unit target,float bonusWindupMs = 100,float bonusRange = 0)
 {
     if (me == null)
     {
         return;
     }
     var targetHull = 0f;
     if (target != null)
     {
         targetHull = target.HullRadius;
     }
     float distance = 0;
     if (target != null)
     {
         var pos = Prediction.InFront(
             me,
             (float)((Game.Ping / 1000 + me.GetTurnTime(target.Position)) * me.MovementSpeed));
         distance = pos.Distance2D(target) - me.Distance2D(target);
     }
     var isValid = target != null && target.IsValid && target.IsAlive && target.IsVisible && !target.IsInvul()
                   && !target.Modifiers.Any(
                       x => x.Name == "modifier_ghost_state" || x.Name == "modifier_item_ethereal_blade_slow")
                   && target.Distance2D(me)
                   <= (me.GetAttackRange() + me.HullRadius + 50 + targetHull + bonusRange + Math.Max(distance, 0));
     if (isValid || (target != null && me.IsAttacking() && me.GetTurnTime(target.Position) < 0.1))
     {
         var canAttack = !AttackOnCooldown(me,target, bonusWindupMs)
                         && !target.IsAttackImmune() && !target.IsInvul() && me.CanAttack();
         if (canAttack && Utils.SleepCheck("!Orbwalk.Attack"))
         {
             me.Attack(target);
             Utils.Sleep(
                 UnitDatabase.GetAttackPoint(me) * 1000 + me.GetTurnTime(target) * 1000,
                 "!Orbwalk.Attack");
             return;
         }
     }
     var canCancel = (CanCancelAnimation(me) && AttackOnCooldown(me,target, bonusWindupMs))
                     || (!isValid && !me.IsAttacking() && CanCancelAnimation(me));
     if (!canCancel || !Utils.SleepCheck("!Orbwalk.Move") || !Utils.SleepCheck("!Orbwalk.Attack"))
     {
         return;
     }
     if (target != null) me.Move(target.Position);
     Utils.Sleep(100, "!Orbwalk.Move");
 }
开发者ID:DevGdos,项目名称:EnsageSharp,代码行数:46,代码来源:Program.cs

示例5: CanHit

        /// <summary>
        ///     Checks if you could hit hero with given ability
        /// </summary>
        /// <param name="ability">
        ///     The ability.
        /// </param>
        /// <param name="target">
        ///     The target.
        /// </param>
        /// <param name="sourcePosition">
        ///     The source Position.
        /// </param>
        /// <param name="abilityName">
        ///     The ability Name.
        /// </param>
        /// <returns>
        ///     The <see cref="bool" />.
        /// </returns>
        public static bool CanHit(this Ability ability, Unit target, Vector3 sourcePosition, string abilityName = null)
        {
            if (ability == null || !ability.IsValid)
            {
                return false;
            }

            if (target == null || !target.IsValid)
            {
                return false;
            }

            var name = abilityName ?? ability.StoredName();
            if (ability.Owner.Equals(target))
            {
                return true;
            }

            var id = ability.Handle + target.Handle;
            if (sleeper.Sleeping(id))
            {
                return canHitDictionary[id];
            }

            var position = sourcePosition;
            if (ability.IsAbilityBehavior(AbilityBehavior.Point, name) || name == "lion_impale"
                || (name == "earthshaker_enchant_totem" && (ability.Owner as Hero).AghanimState()))
            {
                var pred = ability.GetPrediction(target, abilityName: name);
                var lion = name == "lion_impale" ? ability.GetAbilityData("length_buffer") : 0;
                return position.Distance2D(pred)
                       <= ability.TravelDistance() + ability.GetRadius(name) + lion + target.HullRadius;
            }

            if (ability.IsAbilityBehavior(AbilityBehavior.NoTarget, name))
            {
                var pred = ability.GetPrediction(target, abilityName: name);
                var distanceXyz = position.Distance2D(pred);
                var radius = ability.GetRadius(name);
                var range = ability.GetCastRange(name);
                if (name.StartsWith("nevermore_shadowraze"))
                {
                    range += radius / 2;
                }

                if (distanceXyz <= range && position.Distance2D(target.Position) <= range)
                {
                    canHitDictionary[id] = true;
                    sleeper.Sleep(50, id);
                    return true;
                }

                canHitDictionary[id] = name == "pudge_rot" && target.HasModifier("modifier_pudge_meat_hook")
                                       && position.Distance2D(target) < 1500;
                sleeper.Sleep(50, id);
                return canHitDictionary[id];
            }

            if (!ability.IsAbilityBehavior(AbilityBehavior.UnitTarget, name))
            {
                canHitDictionary[id] = false;
                sleeper.Sleep(50, id);
                return false;
            }

            if (target.IsInvul())
            {
                canHitDictionary[id] = false;
                sleeper.Sleep(50, id);
                return false;
            }

            if (position.Distance2D(target.Position) <= ability.GetCastRange(name) + 100)
            {
                canHitDictionary[id] = true;
                sleeper.Sleep(50, id);
                return true;
            }

            canHitDictionary[id] = name == "pudge_dismember" && target.HasModifier("modifier_pudge_meat_hook")
                                   && position.Distance2D(target) < 600;
            sleeper.Sleep(50, id);
//.........这里部分代码省略.........
开发者ID:EnsageSharp,项目名称:Ensage.Common,代码行数:101,代码来源:AbilityExtensions.cs

示例6: CastSkillShot

        /// <summary>
        ///     Uses prediction to cast given skill shot ability
        /// </summary>
        /// <param name="ability">
        ///     The ability.
        /// </param>
        /// <param name="target">
        ///     The target.
        /// </param>
        /// <param name="sourcePosition">
        ///     The source Position.
        /// </param>
        /// <param name="abilityName">
        ///     The ability Name.
        /// </param>
        /// <param name="soulRing">
        ///     The soul Ring.
        /// </param>
        /// <param name="otherTargets">
        ///     Targets which are supposed to be hit by AOE Skill Shot
        /// </param>
        /// <returns>
        ///     returns true in case of successful cast
        /// </returns>
        public static bool CastSkillShot(
            this Ability ability, 
            Unit target, 
            Vector3 sourcePosition, 
            string abilityName = null, 
            Ability soulRing = null, 
            List<Unit> otherTargets = null)
        {
            if (ability == null || !ability.IsValid)
            {
                return false;
            }

            if (target == null || !target.IsValid)
            {
                return false;
            }

            if (!Utils.SleepCheck("CastSkillshot" + ability.Handle))
            {
                return false;
            }

            var name = abilityName ?? ability.StoredName();
            var owner = ability.Owner as Unit;
            var position = sourcePosition;
            var delay = ability.GetHitDelay(target, name);
            var data = ability.CommonProperties();

            // delay += data.AdditionalDelay;
            if (target.IsInvul() && !Utils.ChainStun(target, delay, null, false))
            {
                return false;
            }

            var xyz = ability.GetPrediction(target, abilityName: name);
            if (otherTargets != null)
            {
                var avPosX = otherTargets.Average(x => ability.GetPrediction(x, abilityName: name).X);
                var avPosY = otherTargets.Average(x => ability.GetPrediction(x, abilityName: name).Y);
                xyz = (xyz + new Vector3(avPosX, avPosY, 0)) / 2;
            }

            var radius = ability.GetRadius(name);
            var range = ability.TravelDistance();

            if (data.AllyBlock)
            {
                if (
                    Creeps.All.Any(
                        x =>
                        x.IsValid && x.IsAlive && x.Team == owner.Team && x.Distance2D(xyz) <= range
                        && x.Distance2D(owner) < owner.Distance2D(target)
                        && x.Position.ToVector2().DistanceToLineSegment(sourcePosition.ToVector2(), xyz.ToVector2())
                        <= radius + x.HullRadius))
                {
                    return false;
                }

                if (
                    Heroes.GetByTeam(owner.Team)
                        .Any(
                            hero =>
                            hero.IsAlive && !hero.Equals(owner) && !hero.Equals(target) && hero.Distance2D(xyz) <= range
                            && hero.Distance2D(owner) < owner.Distance2D(target)
                            && hero.Position.ToVector2()
                                   .DistanceToLineSegment(sourcePosition.ToVector2(), xyz.ToVector2())
                            <= radius + hero.HullRadius))
                {
                    return false;
                }
            }

            if (data.EnemyBlock)
            {
                if (
//.........这里部分代码省略.........
开发者ID:EnsageSharp,项目名称:Ensage.Common,代码行数:101,代码来源:AbilityExtensions.cs

示例7: Orbwalk

        /// <summary>
        ///     Orbwalks on given target if they are in range, while moving to mouse position
        /// </summary>
        /// <param name="target"></param>
        /// <param name="bonusWindupMs"></param>
        /// <param name="bonusRange"></param>
        /// <param name="attackmodifiers"></param>
        public static void Orbwalk(
            Unit target, 
            float bonusWindupMs = 0, 
            float bonusRange = 0, 
            bool attackmodifiers = false)
        {
            if (me == null)
            {
                return;
            }

            // if (!Utils.SleepCheck("GlobalCasting"))
            // {
            // return;
            // }
            var targetHull = 0f;
            if (target != null)
            {
                targetHull = target.HullRadius;
            }

            float distance = 0;
            if (target != null)
            {
                var pos = Prediction.InFront(
                    me, 
                    (float)((Game.Ping / 1000 + me.GetTurnTime(target.Position)) * me.MovementSpeed));
                distance = pos.Distance2D(target) - me.Distance2D(target);
            }

            var isValid = target != null && target.IsValid && target.IsAlive && target.IsVisible && !target.IsInvul()
                          && !target.HasModifiers(
                              new[] { "modifier_ghost_state", "modifier_item_ethereal_blade_slow" }, 
                              false)
                          && target.Distance2D(me)
                          <= me.GetAttackRange() + me.HullRadius + 50 + targetHull + bonusRange + Math.Max(distance, 0);
            if (isValid || (target != null && me.IsAttacking() && me.GetTurnTime(target.Position) < 0.1))
            {
                var canAttack = !AttackOnCooldown(target, bonusWindupMs) && !target.IsAttackImmune()
                                && !target.IsInvul() && me.CanAttack();
                if (canAttack && Utils.SleepCheck("Orbwalk.Attack"))
                {
                    Attack(target, attackmodifiers);
                    Utils.Sleep(
                        UnitDatabase.GetAttackPoint(me) * 1000 + me.GetTurnTime(target) * 1000, 
                        "Orbwalk.Attack");
                    return;
                }
            }

            var canCancel = (CanCancelAnimation() && AttackOnCooldown(target, bonusWindupMs))
                            || (!isValid && !me.IsAttacking() && CanCancelAnimation());
            if (!canCancel || !Utils.SleepCheck("Orbwalk.Move") || !Utils.SleepCheck("Orbwalk.Attack"))
            {
                return;
            }

            me.Move(Game.MousePosition);
            Utils.Sleep(100, "Orbwalk.Move");
        }
开发者ID:nbIxMaN,项目名称:Ensage.Common,代码行数:67,代码来源:Orbwalking.cs

示例8: CanAttack

        /// <summary>
        ///     The can attack.
        /// </summary>
        /// <param name="target">
        ///     The target.
        /// </param>
        /// <param name="bonusWindupMs">
        ///     The bonus windup milliseconds.
        /// </param>
        /// <returns>
        ///     The <see cref="bool" />.
        /// </returns>
        public bool CanAttack(Unit target = null, float bonusWindupMs = 0)
        {
            if (this.Unit == null || !this.Unit.IsValid)
            {
                return false;
            }

            var targetHull = 0f;
            if (target != null)
            {
                targetHull = target.HullRadius;
            }

            float distance = 0;
            if (target != null)
            {
                var pos = Prediction.InFront(
                    this.Unit, 
                    (float)(Game.Ping / 1000 + this.Unit.GetTurnTime(target.Position) * this.Unit.MovementSpeed));
                distance = pos.Distance2D(target) - this.Unit.Distance2D(target);
            }

            var isValid = (target != null && target.IsValid && target.IsAlive && target.IsVisible && !target.IsInvul()
                           && !target.HasModifiers(
                               new[] { "modifier_ghost_state", "modifier_item_ethereal_blade_slow" }, 
                               false)
                           && target.Distance2D(this.Unit)
                           <= this.Unit.GetAttackRange() + this.Unit.HullRadius + 75 + targetHull
                           + Math.Max(distance, 0))
                          || (target != null && this.Unit.IsAttacking() && this.Unit.GetTurnTime(target.Position) < 0.1);

            return !this.IsAttackOnCoolDown(target, bonusWindupMs) && (target == null || isValid);
        }
开发者ID:EnsageSharp,项目名称:Ensage.Common,代码行数:45,代码来源:AttackAnimationTracker.cs

示例9: CastSkillShot

 /// <summary>
 ///     Uses prediction to cast given skillshot ability
 /// </summary>
 /// <param name="ability"></param>
 /// <param name="target"></param>
 /// <param name="sourcePosition"></param>
 /// <returns>returns true in case of successfull cast</returns>
 public static bool CastSkillShot(this Ability ability, Unit target, Vector3 sourcePosition)
 {
     var owner = ability.Owner as Unit;
     var position = sourcePosition;
     var delay = ability.GetHitDelay(target);
     //AbilityInfo data;
     //if (!AbilityDamage.DataDictionary.TryGetValue(ability, out data))
     //{
     //    data = AbilityDatabase.Find(ability.Name);
     //    AbilityDamage.DataDictionary.Add(ability, data);
     //}
     //delay += data.AdditionalDelay;
     if (target.IsInvul() && !Utils.ChainStun(target, delay, null, false))
     {
         return false;
     }
     var xyz = ability.GetPrediction(target);
     var radius = ability.GetRadius();
     var speed = ability.GetProjectileSpeed();
     if (!(position.Distance2D(xyz) <= (ability.GetCastRange() + radius)))
     {
         return false;
     }
     if (position.Distance2D(xyz) > ability.GetCastRange())
     {
         xyz = (position - xyz) * ability.GetCastRange() / position.Distance2D(xyz) + xyz;
     }
     // Console.WriteLine(ability.GetCastRange() + " " + radius);
     if (ability.Name.Substring(0, Math.Min("nevermore_shadowraze".Length, ability.Name.Length))
         == "nevermore_shadowraze")
     {
         xyz = Prediction.SkillShotXYZ(
             owner,
             target,
             (float)((delay + (float)owner.GetTurnTime(xyz)) * 1000),
             speed,
             radius);
         if (position.Distance2D(xyz) < (ability.GetCastRange() + radius / 2)
             && position.Distance2D(xyz) > (ability.GetCastRange() - radius / 2))
         {
             owner.Move((position - xyz) * 10 / position.Distance2D(xyz) + xyz);
             owner.Stop();
             ability.UseAbility();
             return true;
         }
         return false;
     }
     ability.UseAbility(xyz);
     return true;
 }
开发者ID:MikeTeok,项目名称:Ensage.Common,代码行数:57,代码来源:AbilityExtensions.cs

示例10: CastStun

        /// <summary>
        ///     Uses given ability in case enemy is not disabled or would be chain stunned.
        /// </summary>
        /// <param name="ability"></param>
        /// <param name="target"></param>
        /// <param name="sourcePosition"></param>
        /// <param name="straightTimeforSkillShot"></param>
        /// <param name="chainStun"></param>
        /// <param name="useSleep"></param>
        /// <param name="abilityName"></param>
        /// <param name="soulRing"></param>
        /// <param name="otherTargets"></param>
        /// <returns>returns true in case of successfull cast</returns>
        public static bool CastStun(
            this Ability ability, 
            Unit target, 
            Vector3 sourcePosition, 
            float straightTimeforSkillShot = 0, 
            bool chainStun = true, 
            bool useSleep = true, 
            string abilityName = null, 
            Ability soulRing = null, 
            List<Unit> otherTargets = null)
        {
            if (!ability.CanBeCasted())
            {
                return false;
            }

            var name = abilityName ?? ability.StoredName();
            var delay = ability.GetHitDelay(target, name);
            var canUse = Utils.ChainStun(target, delay, null, false, name);
            if (!canUse && chainStun)
            {
                return false;
            }

            if (ability.IsAbilityBehavior(AbilityBehavior.UnitTarget, name) && name != "lion_impale"
                && !target.IsInvul())
            {
                if (ability.ManaCost > 0 && soulRing.CanBeCasted())
                {
                    soulRing.UseAbility();
                }

                ability.UseAbility(target);
            }
            else if (ability.IsAbilityBehavior(AbilityBehavior.AreaOfEffect, name)
                     || ability.IsAbilityBehavior(AbilityBehavior.Point, name) || name == "lion_impale")
            {
                if (Prediction.StraightTime(target) > straightTimeforSkillShot * 1000
                    && ability.CastSkillShot(target, name, soulRing, otherTargets))
                {
                    if (useSleep)
                    {
                        Utils.Sleep(Math.Max(delay, 0.2) * 1000 + 250, "CHAINSTUN_SLEEP");
                    }

                    return true;
                }

                return false;
            }
            else if (ability.IsAbilityBehavior(AbilityBehavior.NoTarget, name))
            {
                if (name == "invoker_ice_wall")
                {
                    ability.CastSkillShot(target, name);
                }
                else
                {
                    if (ability.ManaCost > 0 && soulRing.CanBeCasted())
                    {
                        soulRing.UseAbility();
                    }

                    ability.UseAbility();
                }
            }

            if (useSleep)
            {
                Utils.Sleep(Math.Max(delay, 0.2) * 1000 + 250, "CHAINSTUN_SLEEP");
            }

            return true;
        }
开发者ID:nbIxMaN,项目名称:Ensage.Common,代码行数:87,代码来源:AbilityExtensions.cs

示例11: IsIdle

 /// <summary>
 ///     Checks if enemy is not moving
 /// </summary>
 /// <param name="unit"></param>
 /// <returns></returns>
 public static bool IsIdle(Unit unit)
 {
     // var modifiers = unit.Modifiers;
     return unit.IsInvul() || unit.IsStunned()
            || (unit.NetworkActivity == NetworkActivity.Idle
                && (!SpeedDictionary.ContainsKey(unit.Handle) || SpeedDictionary[unit.Handle] == Vector3.Zero))
            || unit.IsAttacking();
 }
开发者ID:nbIxMaN,项目名称:Ensage.Common,代码行数:13,代码来源:Prediction.cs

示例12: OrbwalkOn

        /// <summary>
        ///     The orbwalk.
        /// </summary>
        /// <param name="target">
        ///     The target.
        /// </param>
        /// <param name="movePosition">
        ///     The move Position.
        /// </param>
        /// <param name="bonusWindupMs">
        ///     The bonus windup ms.
        /// </param>
        /// <param name="bonusRange">
        ///     The bonus range.
        /// </param>
        /// <param name="attackmodifiers">
        ///     The attackmodifiers.
        /// </param>
        /// <param name="followTarget">
        ///     The follow target.
        /// </param>
        public void OrbwalkOn(
            Unit target, 
            Vector3 movePosition, 
            float bonusWindupMs = 0, 
            float bonusRange = 0, 
            bool attackmodifiers = true, 
            bool followTarget = false)
        {
            if (this.Unit == null || !this.Unit.IsValid)
            {
                return;
            }

            var targetHull = 0f;
            if (target != null)
            {
                targetHull = target.HullRadius;
            }

            float distance = 0;
            if (target != null)
            {
                var pos = Prediction.InFront(
                    this.Unit, 
                    (float)(Game.Ping / 1000 + this.Unit.GetTurnTime(target.Position) * this.Unit.MovementSpeed));
                distance = pos.Distance2D(target) - this.Unit.Distance2D(target);
            }

            var isValid = target != null && target.IsValid && target.IsAlive && target.IsVisible;
            var isAttackable = target != null && target.IsValid && !target.IsInvul() && !target.IsAttackImmune()
                               && !target.HasModifiers(
                                   new[] { "modifier_ghost_state", "modifier_item_ethereal_blade_slow" }, 
                                   false)
                               && target.Distance2D(this.Unit)
                               <= this.Unit.GetAttackRange() + this.Unit.HullRadius + 50 + targetHull + bonusRange
                               + Math.Max(distance, 0);
            if ((isValid && isAttackable)
                || (!isAttackable && target != null && target.IsValid && this.Unit.IsAttacking()
                    && this.Unit.GetTurnTime(target.Position) < 0.1))
            {
                var canAttack = !this.IsAttackOnCoolDown(target, bonusWindupMs) && this.Unit.CanAttack();
                if (canAttack && !this.attackSleeper.Sleeping && (!this.hero || Utils.SleepCheck("Orbwalk.Attack")))
                {
                    this.attacker.Attack(target, attackmodifiers);
                    this.AttackOrder();
                    this.attackSleeper.Sleep(
                        (float)
                        (UnitDatabase.GetAttackPoint(this.Unit) * 1000 + this.Unit.GetTurnTime(target) * 1000
                         + Game.Ping + 100));
                    this.moveSleeper.Sleep(
                        (float)
                        (UnitDatabase.GetAttackPoint(this.Unit) * 1000 + this.Unit.GetTurnTime(target) * 1000 + 50));
                    if (!this.hero)
                    {
                        return;
                    }

                    Utils.Sleep(
                        UnitDatabase.GetAttackPoint(this.Unit) * 1000 + this.Unit.GetTurnTime(target) * 1000 + Game.Ping
                        + 100, 
                        "Orbwalk.Attack");
                    Utils.Sleep(
                        UnitDatabase.GetAttackPoint(this.Unit) * 1000 + this.Unit.GetTurnTime(target) * 1000 + 50, 
                        "Orbwalk.Move");
                    return;
                }

                if (canAttack && !this.attackSleeper2.Sleeping)
                {
                    this.attacker.Attack(target, attackmodifiers);
                    this.AttackOrder();
                    this.attackSleeper2.Sleep(100);
                    return;
                }
            }

            var userdelay = this.setUserDelayManually ? this.UserDelay : Orbwalking.UserDelay;
            var canCancel = (this.CanCancelAttack(userdelay) && this.IsAttackOnCoolDown(target, bonusWindupMs))
                            || ((!isValid || !isAttackable)
//.........这里部分代码省略.........
开发者ID:EnsageSharp,项目名称:Ensage.Common,代码行数:101,代码来源:Orbwalker.cs

示例13: CheckEnemy

 protected virtual bool CheckEnemy(Unit unit)
 {
     return !unit.IsInvul()
            && (CanBeUsedOnAlly || unit.Equals(Hero)
                || ((PiercesMagicImmunity || !unit.IsMagicImmune())
                    && (IgnoresLinkensSphere || !unit.IsLinkensProtected())));
 }
开发者ID:IdcNoob,项目名称:Ensage,代码行数:7,代码来源:UsableAbility.cs


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