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


C# Unit.IsValidTarget方法代码示例

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


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

示例1: Cast

 public static void Cast(this Ability ability, Unit unit)
 {
     if (ability.IsReady() && unit.IsValidTarget(ability.CastRange))
     {
         ability.UseAbility(unit);
     }
 }
开发者ID:ehmehe,项目名称:Ensage,代码行数:7,代码来源:iUtility.cs

示例2: CheckTarget

        private static bool CheckTarget(Unit enemy, bool doubleOwnage = false)
        {
            if (enemy.IsIllusion || !enemy.IsValidTarget(dagon.GetCastRange(), true, hero.NetworkPosition))
            {
                return false;
            }

            if (enemy.IsLinkensProtected() || enemy.IsMagicImmune())
            {
                return false;
            }

            if (!enemy.CanDie() || enemy.Modifiers.Any(x => IgnoreModifiers.Any(x.Name.Equals)))
            {
                return false;
            }

            var damage = AbilityDamage.CalculateDamage(dagon, hero, enemy);

            if (doubleOwnage)
            {
                damage *= 2;
            }

            return enemy.Health < damage;
        }
开发者ID:IdcNoob,项目名称:Ensage,代码行数:26,代码来源:Program.cs

示例3: CheckTarget

        private static bool CheckTarget(Unit enemy)
        {
            if (enemy == null || enemy.IsIllusion || !enemy.IsValidTarget(dagon.GetCastRange(), true, me.NetworkPosition) || enemy.IsLinkensProtected() || enemy.IsMagicImmune() || !enemy.CanDie() || enemy.Modifiers.Any(x => IgnoreModifiers.Any(x.Name.Equals)))
                return false;

           return enemy.Health <
                   enemy.SpellDamageTaken(dagon.GetAbilityData("damage"), DamageType.Magical, me, dagon.Name);
        }
开发者ID:Splinter-,项目名称:EnsageSharp,代码行数:8,代码来源:Program.cs

示例4: CanBeCasted

        /// <summary>
        ///     Checks if given ability can be used
        /// </summary>
        /// <param name="ability"></param>
        /// <param name="target"></param>
        /// <returns>returns true in case ability can be used</returns>
        public static bool CanBeCasted(this Ability ability, Unit target)
        {
            if (!target.IsValidTarget())
            {
                return false;
            }

            var canBeCasted = ability.CanBeCasted();
            if (!target.IsMagicImmune())
            {
                return canBeCasted;
            }

            var data = AbilityDatabase.Find(ability.Name);
            return data == null ? canBeCasted : data.MagicImmunityPierce;
        }
开发者ID:MarkHC,项目名称:Ensage.Common,代码行数:22,代码来源:AbilityExtensions.cs

示例5: UseOnTarget

        private static bool UseOnTarget(IEnumerable<string> abilitiesNames, Unit target, double castpoint = 5) {
            if (!Menu.Item("disable").GetValue<bool>())
                return false;

            foreach (
                var ability in
                    abilitiesNames.Select(ability => hero.FindItem(ability) ?? hero.FindSpell(ability))
                        .Where(
                            ability => ability != null && ability.CanBeCasted() && (ability is Item || hero.CanCast()))) {

                if (ability.IsAbilityBehavior(AbilityBehavior.NoTarget)) {
                    if (ability.GetCastDelay(hero, target, true) <= castpoint &&
                        target.IsValidTarget(ability.GetCastRange(), false, hero.NetworkPosition) &&
                        (!target.IsMagicImmune() || IgnoresMagicImmunity.Any(ability.Name.Equals))) {
                            ability.UseAbility();
                        } else continue;
                } else if (ability.IsAbilityBehavior(AbilityBehavior.UnitTarget)) {
                    if (ability.GetCastDelay(hero, target, true) <= castpoint &&
                        target.IsValidTarget(ability.GetCastRange(), false, hero.NetworkPosition) &&
                        (!target.IsMagicImmune() || IgnoresMagicImmunity.Any(ability.Name.Equals))) {
                            ability.UseAbility(target);
                    } else continue;
                } else {
                    if (ability.GetCastDelay(hero, target, true) <= castpoint &&
                        target.IsValidTarget(ability.GetCastRange(), false, hero.NetworkPosition) &&
                        (!target.IsMagicImmune() || IgnoresMagicImmunity.Any(ability.Name.Equals))) {
                            ability.UseAbility(hero.Position);
                        } else continue;
                }

                Utils.Sleep(1000, "CounterDelay");
                return true;
            }
            return false;
        }
开发者ID:LimbViolencer,项目名称:Ensage-1,代码行数:35,代码来源:Program.cs

示例6: CanBeCasted

        /// <summary>
        ///     Checks if given ability can be used
        /// </summary>
        /// <param name="ability">
        ///     The ability.
        /// </param>
        /// <param name="target">
        ///     The target.
        /// </param>
        /// <returns>
        ///     returns true in case ability can be used
        /// </returns>
        public static bool CanBeCasted(this Ability ability, Unit target)
        {
            if (ability == null || !ability.IsValid)
            {
                return false;
            }

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

            if (!target.IsValidTarget())
            {
                return false;
            }

            var canBeCasted = ability.CanBeCasted();
            if (!target.IsMagicImmune())
            {
                return canBeCasted;
            }

            var data = ability.CommonProperties();

            return data == null ? canBeCasted : data.MagicImmunityPierce;
        }
开发者ID:EnsageSharp,项目名称:Ensage.Common,代码行数:39,代码来源:AbilityExtensions.cs

示例7: CanBeCasted

        /// <summary>
        ///     Checks if given ability can be used
        /// </summary>
        /// <param name="ability"></param>
        /// <param name="target"></param>
        /// <returns>returns true in case ability can be used</returns>
        public static bool CanBeCasted(this Ability ability, Unit target)
        {
            if (!target.IsValidTarget())
            {
                return false;
            }

            var canBeCasted = ability.CanBeCasted();
            if (!target.IsMagicImmune())
            {
                return canBeCasted;
            }

            AbilityInfo data;
            if (!AbilityDamage.DataDictionary.TryGetValue(ability, out data))
            {
                data = AbilityDatabase.Find(ability.Name);
                AbilityDamage.DataDictionary.Add(ability, data);
            }
            return data == null ? canBeCasted : data.MagicImmunityPierce;
        }
开发者ID:beminee,项目名称:Ensage.Common,代码行数:27,代码来源:AbilityExtensions.cs

示例8: UseOnTarget

        private static bool UseOnTarget(Unit target, double castpoint, params string[][] abilitiesNames) {
            if (!Program.Menu.Item("disable").GetValue<bool>())
                return false;

            var canCast = Program.Hero.CanCast();
            var magicImmune = target.IsMagicImmune();
            var castDelay = 0d;

            var ability =
                abilitiesNames.SelectMany(
                    x =>
                        x.Select(y => Program.Hero.FindItem(y) ?? Program.Hero.FindSpell(y))
                            .Where(
                                y =>
                                    y.CanBeCasted() && (castDelay = y.GetCastDelay(Program.Hero, target)) < castpoint &&
                                    target.IsValidTarget(y.GetCastRange(), false, Program.Hero.NetworkPosition) &&
                                    (!magicImmune || y.PiercesMagicImmunity()) &&
                                    (y is Item || canCast))).FirstOrDefault();

            if (ability == null)
                return false;

            if (ability.IsAbilityBehavior(AbilityBehavior.NoTarget))
                ability.UseAbility();
            else if (ability.IsAbilityBehavior(AbilityBehavior.UnitTarget))
                ability.UseAbility(target);
            else
                ability.UseAbility(target.NetworkPosition);

            Utils.Sleep(castDelay * 1000 + Program.Menu.Item("delay").GetValue<Slider>().Value, "CounterDelay");
            return true;
        }
开发者ID:IdcNoob,项目名称:Ensage,代码行数:32,代码来源:Counter.cs

示例9: CheckTarget

        private static bool CheckTarget(Unit enemy, bool doubleOwnage = false) {
            if (enemy.IsIllusion || !enemy.IsValidTarget(dagon.GetCastRange(), true, hero.NetworkPosition))
                return false;

            if (enemy.IsLinkensProtected() || enemy.IsMagicImmune())
                return false;

            if (!enemy.CanDie() || enemy.Modifiers.Any(x => IgnoreModifiers.Any(x.Name.Equals)))
                return false;

            return enemy.Health <
                   enemy.DamageTaken(DagonDamage[dagon.Level - 1] * (doubleOwnage ? 2 : 1), DamageType.Magical, hero);
        }
开发者ID:RetiredQQ,项目名称:Ensage,代码行数:13,代码来源:Program.cs


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