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


C# Ability.CanHit方法代码示例

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


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

示例1: CastCombo

        private static void CastCombo(Hero globalTarget, Ability laser, Ability rockets, bool singleCombo = false)
        {
            var myInventory = Members.MyHero.Inventory.Items.ToList();
            var allItems = myInventory.Where(x =>
                Helper.IsItemEnable(x.StoredName()) && x.CanBeCasted()).ToList();
            var distance = Members.MyHero.Distance2D(globalTarget);
            var daggerCastRange = 1150 + (myInventory.Any(x => x.StoredName() == "item_aether_lens") ? 200 : 0);
            var inventory =
                allItems.Where(
                    x =>
                         ((x.StoredName() == "item_blink" && distance <= daggerCastRange + CloseRange) ||
                         (x.GetCastRange() > 0 && x.CanHit(globalTarget) /* && distance <= x.GetCastRange() + 150*/) ||
                         (x.GetCastRange() <= 0)) && Utils.SleepCheck($"{x.Handle}+item_usages"))
                    .ToList();

            if (laser != null && Helper.IsAbilityEnable(laser.StoredName()) && laser.CanBeCasted() &&
                laser.CanHit(globalTarget) && !_spellSleeper.Sleeping(laser))
            {
                laser.UseAbility(globalTarget);
                _spellSleeper.Sleep(1000, laser);
            }
            var slarkMod = globalTarget.HasModifiers(new[] { "modifier_slark_dark_pact", "modifier_slark_dark_pact_pulses" }, false);
            foreach (var item in inventory.OrderByDescending(Helper.PriorityHelper))
            {
                var name = item.StoredName();
                if (name == "item_ethereal_blade")
                    _ethereal.Sleep(1000);
                if (name.Contains("dagon"))
                    if (_ethereal.Sleeping && !globalTarget.HasModifier("modifier_item_ethereal_blade_ethereal"))
                        continue;
                if (item.IsAbilityBehavior(AbilityBehavior.NoTarget))
                {
                    item.UseAbility();
                }
                else if (item.IsAbilityBehavior(AbilityBehavior.UnitTarget))
                    if (item.TargetTeamType == TargetTeamType.Enemy || item.TargetTeamType == TargetTeamType.All ||
                        item.TargetTeamType == TargetTeamType.Custom)
                    {
                        if (item.IsDisable())
                        {
                            if (!slarkMod && !globalTarget.IsLinkensProtected())
                                item.UseAbility(globalTarget);
                                /*if (item.CastStun(globalTarget))
                                {
                                    Utils.Sleep(250, $"{item.Handle}+item_usages");
                                    continue;
                                }*/
                        }
                        else if (item.IsSilence())
                        {
                            if (!slarkMod)
                                if (!globalTarget.IsSilenced())
                                {
                                    item.UseAbility(globalTarget);
                                }
                        }
                        else if ((item.StoredName().Contains("dagon") || item.StoredName() == "item_ethereal_blade") &&
                                 globalTarget.HasModifiers(
                                     new[]
                                     {
                                         /*"modifier_templar_assassin_refraction_absorb",
                                         "modifier_templar_assassin_refraction_absorb_stacks",*/
                                         "modifier_oracle_fates_edict",
                                         "modifier_abaddon_borrowed_time"
                                     }, false))
                        {
                            continue;
                        }
                        else
                        {
                            item.UseAbility(globalTarget);
                        }

                        /*item.UseAbility(target);
                        Print($"[Using]: {item.Name} (3)", print: false);*/
                    }
                    else
                    {
                        item.UseAbility(Members.MyHero);
                    }
                else
                {
                    if (name == "item_blink")
                    {
                        if (singleCombo || _spellSleeper.Sleeping("blink_fix"))
                            continue;
                        if (distance > daggerCastRange+CloseRange)
                        {
                            var angle = Members.MyHero.FindAngleBetween(globalTarget.Position, true);
                            var point = new Vector3(
                                (float)
                                    (globalTarget.Position.X -
                                     daggerCastRange *
                                     Math.Cos(angle)),
                                (float)
                                    (globalTarget.Position.Y -
                                     daggerCastRange *
                                     Math.Sin(angle)),
                                globalTarget.Position.Z);
                            var dist = Members.MyHero.Distance2D(point);
//.........这里部分代码省略.........
开发者ID:JumpAttacker,项目名称:EnsageSharp,代码行数:101,代码来源:ComboAction.cs

示例2: UseAbility

        private static async Task UseAbility(Ability ability, Unit target, CancellationToken cancellationToken,
            int extraDelay = 0)
        {
            if (ability.CanBeCasted() && ability.CanHit(target) && Helper.IsAbilityEnable(ability.StoredName()))
            {
                var cPont = ability.GetCastDelay(Members.MyHero, target, true)*1000 + 250;

                switch (ability.StoredName())
                {
                    case "riki_smoke_screen":
                        ability.UseAbility(Prediction.PredictedXYZ(target, (float) cPont));
                        break;
                    default:
                        ability.UseAbility(target);
                        break;

                }
                Printer.Print($"[{(int) Game.RawGameTime}] [Ability] {ability.Name}: {cPont}");
                await Task.Delay((int) cPont, cancellationToken);
            }
            else
            {
                //Printer.Print($"[CANT]: ({ability.Name})");
            }
        }
开发者ID:JumpAttacker,项目名称:EnsageSharp,代码行数:25,代码来源:Core.cs


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