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


C# Ability.ToggleAbility方法代码示例

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


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

示例1: Cast

        public static bool Cast(Ability ability, Unit target, string name)
        {
            if (name == "pudge_rot" && Utils.SleepCheck("rotToggle"))
            {
                if (!ability.IsToggled)
                {
                    ability.ToggleAbility();
                    Utils.Sleep(500, "rotToggle");
                    return true;
                }

                return false;
            }

            if (name == "templar_assassin_psionic_trap")
            {
                var modifier = target.FindModifier("modifier_templar_assassin_trap_slow");
                if (modifier != null && modifier.RemainingTime > ability.GetHitDelay(target, name))
                {
                    return false;
                }

                if (TemplarAssasinUseTrap(target))
                {
                    return false;
                }

                var casted = ability.CastSkillShot(target, MyHeroInfo.Position, name);
                if (casted)
                {
                    DelayAction.Add(
                        new DelayActionItem(
                            (int)ability.GetHitDelay(target, name) * 1000 + 700, 
                            delegate { TemplarAssasinUseTrap(target); }, 
                            CancellationToken.None));
                }

                return casted;
            }

            return ability.CastStun(
                target, 
                1, 
                abilityName: name, 
                soulRing: SoulRing.Check(ability) ? MyAbilities.SoulRing : null);
        }
开发者ID:Ray0fHope,项目名称:EnsageSharp,代码行数:46,代码来源:Slow.cs

示例2: CastHeal

        private static void CastHeal(Ability healSpell, Hero destination = null, bool toggle = false)
        {
            /*if (destination != null)
            {
                if (healSpell.CanBeCasted() && Utils.SleepCheck("Casting Heal"))
                {
                    healSpell.UseAbility(destination);
                    Utils.Sleep(100 + Game.Ping, "Casting Heal");
                }
            }
            else
            {
                if (Utils.SleepCheck("Casting Heal"))
                {
                    healSpell.UseAbility();
                    Utils.Sleep(healSpell.ChannelTime + Game.Ping, "Casting Heal");
                }
            }*/

            if (healSpell != null && healSpell.CanBeCasted() && me.CanCast())
            {
                if (toggle)
                {
                    if (!healSpell.IsToggled)
                    {
                        healSpell.ToggleAbility();
                    }
                }
                else
                {
                    if (destination == null)
                    {
                    }
                    else
                    {
                        healSpell.UseAbility(target);
                        if (healSpell.Name == "wisp_tether" && !me.Spellbook.SpellW.IsToggled &&
                            me.Spellbook.SpellW.Cooldown == 0)
                        {
                            me.Spellbook.Spell4.ToggleAbility();
                        }
                    }
                }
            }
        }
开发者ID:evezus,项目名称:EnsageSharp,代码行数:45,代码来源:Program.cs

示例3: Heal

        private static void Heal(Hero self, Ability healSpell, float[] amount, uint range, int targettingType,
            bool targetSelf = true)
        {
            if (healSpell != null && healSpell.CanBeCasted() && !self.IsChanneling())
            {
                if (self.IsAlive && !self.IsChanneling() &&
                    (!self.IsInvisible() || !me.Modifiers.Any(x => x.Name == "modifier_treant_natures_guise")) &&
                    self.Distance2D(fountain) > 2000)
                {
                    var heroes = targetSelf
                        ? ObjectMgr.GetEntities<Hero>()
                            .Where(
                                entity =>
                                    entity.Team == self.Team && self.Distance2D(entity) <= range && !entity.IsIllusion &&
                                    entity.IsAlive)
                            .ToList()
                        : ObjectMgr.GetEntities<Hero>()
                            .Where(
                                entity =>
                                    entity.Team == self.Team && self.Distance2D(entity) <= range && !entity.IsIllusion &&
                                    entity.IsAlive && !Equals(entity, me)).ToList();

                    if (heroes.Any())
                    {
                        foreach (var ally in heroes)
                        {
                            if (ally.Health <= (ally.MaximumHealth*0.7) && healSpell.CanBeCasted() &&
                                self.Distance2D(fountain) > 2000 && IsInDanger(ally) &&
                                ally.Health + amount[healSpell.Level - 1] <= ally.MaximumHealth && (me.ClassID != ClassID.CDOTA_Unit_Hero_WitchDoctor || !me.Spellbook.SpellW.IsToggled))
                            {
                                if (targettingType == 1)
                                    CastHeal(healSpell, ally);
                                else if (targettingType == 2)
                                    CastHeal(healSpell);
                                else if (targettingType == 3 && Utils.SleepCheck("ToggleHeal"))
                                {
                                    /*if (healSpell.CanBeCasted() && Utils.SleepCheck("ToggleHeal"))
                                    {
                                        if (!healSpell.IsToggled)
                                        {
                                            CastHeal(healSpell);
                                            Utils.Sleep(1000 + Game.Ping, "ToggleHeal");
                                        }
                                    }*/

                                    CastHeal(healSpell, null, true);
                                    Utils.Sleep(1000 + Game.Ping, "ToggleHeal");
                                }
                            }
                            else if (targettingType == 3 && ally.Health > (ally.MaximumHealth*0.7) && healSpell.IsToggled &&
                                     Utils.SleepCheck("ToggleHeal"))
                            {
                                healSpell.ToggleAbility();
                                Utils.Sleep(1000 + Game.Ping, "ToggleHeal");
                            }
                        }
                    }
                }
            }
        }
开发者ID:evezus,项目名称:EnsageSharp,代码行数:60,代码来源:Program.cs

示例4: Cast

 public static bool Cast(
     Ability ability,
     Unit target,
     Unit buffTarget,
     string name,
     List<Modifier> modifiers,
     bool togglearmlet = false)
 {
     if (name == "item_armlet")
     {
         if (buffTarget.Modifiers.Any(x => x.Name == "modifier_ice_blast"))
         {
             return false;
         }
         if (!togglearmlet && buffTarget.Distance2D(target) > Math.Max(target.GetAttackRange(), 500))
         {
             return false;
         }
         var armlettoggled = modifiers.Any(x => x.Name == "modifier_item_armlet_unholy_strength")
                             && ability.IsToggled;
         Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
         ManageAutoAttack.AutoAttackDisabled = true;
         if (armlettoggled)
         {
             ability.ToggleAbility();
             ability.ToggleAbility();
             return true;
         }
         ability.ToggleAbility();
         return true;
     }
     if (!(buffTarget.Distance2D(target) < MyHeroInfo.AttackRange() + 150))
     {
         return false;
     }
     SoulRing.Cast(ability);
     if (ability.Name == "templar_assassin_refraction")
     {
         var meld = AbilityMain.Me.Spellbook.Spell2;
         if (meld != null && meld.CanBeCasted())
         {
             if (
                 !(target.Distance2D(MyHeroInfo.Position)
                   < (AbilityMain.Me.GetAttackRange() + 50 + target.HullRadius + AbilityMain.Me.HullRadius))
                 || Orbwalking.AttackOnCooldown(target) || AbilityMain.Me.IsAttacking()
                 || (target.Predict(Game.Ping).Distance2D(MyHeroInfo.Position)
                     > (AbilityMain.Me.GetAttackRange() + 50 + target.HullRadius + AbilityMain.Me.HullRadius))
                 || !Utils.SleepCheck("GlobalCasting"))
             {
                 return false;
             }
             Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
             ManageAutoAttack.AutoAttackDisabled = true;
             ability.UseAbility();
             if (Nuke.Cast(meld, target, NameManager.Name(meld)))
             {
                 DelayAction.Add(
                     new DelayActionItem(
                         (int)meld.GetCastDelay(AbilityMain.Me, target) * 1000 + 100,
                         () =>
                             {
                                 AbilityMain.Me.Attack(target);
                             },
                         CancellationToken.None));
             }
             Utils.Sleep(meld.GetCastDelay(AbilityMain.Me,target)*1000, "GlobalCasting");
             Utils.Sleep(meld.GetHitDelay(target, name) * 1000 + 200, "casting");
             Utils.Sleep(meld.GetHitDelay(target, name) * 1000 + 200, ability.Handle.ToString());
             return true;
         }
     }
     if (ability.IsAbilityBehavior(AbilityBehavior.NoTarget, name))
     {
         Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
         ManageAutoAttack.AutoAttackDisabled = true;
         ability.UseAbility();
         return true;
     }
     Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
     ManageAutoAttack.AutoAttackDisabled = true;
     ability.UseAbility(buffTarget);
     return true;
 }
开发者ID:dendimonster,项目名称:EnsageSharp,代码行数:83,代码来源:Buff.cs

示例5: UseItem

 private static async Task UseItem(Ability ability, Unit target, CancellationToken cancellationToken)
 {
     if (ComboSleeper.Sleeping("invisAction"))
         return;
     ComboSleeper.Sleep(150, ability);
     if (ability.StoredName() == "item_armlet")
     {
         if (!Members.MyHero.HasModifier("modifier_item_armlet_unholy_strength"))
         {
             ability.ToggleAbility();
         }
         else
         {
             return;
         }
     }
     else if (ability.IsAbilityBehavior(AbilityBehavior.NoTarget))
     {
         ability.UseAbility();
     }
     else if (ability.IsAbilityBehavior(AbilityBehavior.UnitTarget))
     {
         if (ability.TargetTeamType == TargetTeamType.Enemy || ability.TargetTeamType == TargetTeamType.All ||
             ability.TargetTeamType == TargetTeamType.Custom)
         {
             ability.UseAbility(target);
         }
         else
         {
             ability.UseAbility(Members.MyHero);
         }
     }
     Printer.Print($"[{(int) Game.RawGameTime}] [Item] {ability.Name}: {50}");
     await Task.Delay(5, cancellationToken);
 }
开发者ID:JumpAttacker,项目名称:EnsageSharp,代码行数:35,代码来源:Core.cs


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