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


C# Hero.CanUseItems方法代码示例

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


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

示例1: ComboInAction

        private static void ComboInAction(Hero me, Hero target)
        {
            #region Init
            /*
            var q = me.Spellbook.SpellQ;
            var w = me.Spellbook.SpellW;
            var e = me.Spellbook.SpellE;
            var active1 = me.Spellbook.Spell4;
            var active2 = me.Spellbook.Spell5;
            */
            var invoke = me.FindSpell("invoker_invoke");
            
            var eul = me.FindItem("item_cyclone");
            var dagger = me.FindItem("item_blink");
            var refresher = me.FindItem("item_refresher");
            var icewall = me.FindSpell("invoker_ice_wall");
            var deafblast = me.FindSpell("invoker_deafening_blast");
            var hex = me.FindItem("item_sheepstick");
            var urn = me.FindItem("item_urn_of_shadows");
            var orchid = me.FindItem("item_orchid");
            var meteor = me.FindSpell("invoker_chaos_meteor");
            var ss = me.FindSpell("invoker_sun_strike");
            //var emp = me.FindSpell("invoker_emp");
            /*
            
            var coldsnap = me.FindSpell("invoker_cold_snap");
            var ghostwalk = me.FindSpell("invoker_ghost_walk");
            
            var tornado = me.FindSpell("invoker_tornado");
            
            var forge = me.FindSpell("invoker_forge_spirit");
            
            var alacrity = me.FindSpell("invoker_alacrity");
            
            */
            if (!_initNewCombo)
            {
                _initNewCombo = true;
                _stage = 1;
                //PrintInfo("Starting new combo! " + $"[{_combo + 1}] target: {target.Name}");
            }
            if (!Utils.SleepCheck("StageCheck")) return;
            #endregion

            /*var modif = target.Modifiers.Where(x=>x.IsDebuff);
            PrintInfo("===========================");
            foreach (var s in modif)
            {
                PrintInfo(s.Name);
            }*/
            var myBoys = ObjectMgr.GetEntities<Unit>().Where(x => x.Team == me.Team && x.IsControllable && x.IsAlive && Utils.SleepCheck(x.Handle.ToString()));
            foreach (var myBoy in myBoys)
            {
                myBoy.Attack(target);
                Utils.Sleep(300, myBoy.Handle.ToString());
            }
            if (me.CanUseItems())
            {
                if (urn != null && urn.CanBeCasted(target))
                {
                    var urnMod = target.Modifiers.Any(x => x.Name == "modifier_item_urn_damage") &&
                                 Utils.SleepCheck(urn.Name);
                    if (!urnMod)
                    {
                        urn.UseAbility(target);
                        Utils.Sleep(300, urn.Name);
                    }
                }
                if (_stage > 2 && !target.IsHexed() && !target.IsStunned())
                {
                    if (hex != null && hex.CanBeCasted(target) &&
                        Menu.Item("items").GetValue<AbilityToggler>().IsEnabled(hex.Name) &&
                        Utils.SleepCheck("items"))
                    {
                        hex.UseAbility(target);
                        Utils.Sleep(300, "items");
                    }
                    if (orchid != null && orchid.CanBeCasted(target) &&
                        Menu.Item("items").GetValue<AbilityToggler>().IsEnabled(orchid.Name) &&
                        Utils.SleepCheck("items"))
                    {
                        orchid.UseAbility(target);
                        Utils.Sleep(300, "items");
                    }
                }
                if (dagger != null && Menu.Item("items").GetValue<AbilityToggler>().IsEnabled(dagger.Name) &&
                    dagger.CanBeCasted() && Utils.SleepCheck("blinker") && me.Distance2D(target) >= 700)
                {
                    var dist = 300;
                    var angle = me.FindAngleBetween(target.Position, true);
                    var point =
                        new Vector3(
                            (float) (target.Position.X -
                                     dist*
                                     Math.Cos(angle)),
                            (float) (target.Position.Y -
                                     dist*
                                     Math.Sin(angle)), 0);
                    if (me.Distance2D(target) <= 1150 + 700)
                        dagger.UseAbility(point);
//.........这里部分代码省略.........
开发者ID:dendimonster,项目名称:EnsageSharp-1,代码行数:101,代码来源:Program.cs

示例2: CanIncreaseMagicDmg

        private bool CanIncreaseMagicDmg(Hero source, Unit target)
        {
            //var orchid = source.FindItem("item_orchid") ?? source.FindItem("item_bloodthorn");
            var veil = source.FindItem("item_veil_of_discord");
            ethereal = source.FindItem("item_ethereal_blade");

            return (//(orchid != null && orchid.CanBeCasted() && !target.HasModifier("modifier_orchid_malevolence_debuff"))||
                  (veil != null && veil.CanBeCasted() && !target.HasModifier("modifier_item_veil_of_discord_debuff"))
                 || (ethereal != null && ethereal.CanBeCasted() && !IsDisembodied(target))
                 )
                 && source.CanUseItems();
        }
开发者ID:VickTheRock,项目名称:ReworkAllScripts,代码行数:12,代码来源:EarthshakerController.cs

示例3: DeffensiveAutoUsage

        public static bool DeffensiveAutoUsage(Hero allyHero, Hero me, Hero[] enemyHeroes, float ping)
        {
            var hero = allyHero;
            var heroName = NameManager.Name(hero);

            // var heroDistance = position.Distance2D(hero);
            var heroMissingHp = hero.MaximumHealth - hero.Health;
            var heroMissingMana = hero.MaximumMana - hero.Mana;
            var heroManaPercentage = (hero.Mana / hero.MaximumMana) * 100;
            var heroHpPercentage = ((float)hero.Health / hero.MaximumHealth) * 100;
            foreach (var data in
                MyAbilities.DeffensiveAbilities.Where(
                    x =>
                    (x.Value.IsValid
                     && (x.Value.CanBeCasted() || (x.Value.CanBeCasted(SoulRing.ManaGained) && SoulRing.Check(x.Value)))
                     && ((x.Value is Item && me.CanUseItems()) || (!(x.Value is Item) && me.CanCast()))
                     && (Utils.SleepCheck(x.Value.Handle.ToString())
                         || (!x.Value.IsInAbilityPhase && x.Value.FindCastPoint() > 0)))))
            {
                var ability = data.Value;
                var name = NameManager.Name(ability);
                if (name == "item_soul_ring")
                {
                    continue;
                }

                if (hero.IsMagicImmune() && ability.ImmunityType != (ImmunityType)1)
                {
                    continue;
                }

                var category = data.Key.Substring(name.Length);
                var handleString = ability.Handle.ToString();
                if (!CastingChecks.All(name, hero))
                {
                    continue;
                }

                var delay = ability.GetCastDelay(me, hero, abilityName: name) * 1000;
                var canHit = ability.CanHit(hero, MyHeroInfo.Position, name);
                if (category == "heal" && !hero.HasModifier("modifier_ice_blast")
                    && MainMenu.Menu.Item("healsToggler").GetValue<AbilityToggler>().IsEnabled(name)
                    && ((!(name == "item_soul_ring" || name == "item_magic_wand" || name == "item_magic_stick")
                         && Heals.HealsMenuDictionary[name].Item(name + "useonallies")
                                .GetValue<HeroToggler>()
                                .IsEnabled(heroName)) || hero.Equals(AbilityMain.Me)) && canHit
                    && (name == "item_arcane_boots"
                            ? (Heals.HealsMenuDictionary[name].Item(name + "missingmanamin").GetValue<Slider>().Value
                               < heroMissingMana
                               && Heals.HealsMenuDictionary[name].Item(name + "manapercentbelow")
                                      .GetValue<Slider>()
                                      .Value > heroManaPercentage
                               && (!AllyHeroes.Heroes.Any(
                                   x =>
                                   !x.Equals(hero)
                                   && Heals.HealsMenuDictionary[name].Item(name + "useonallies")
                                          .GetValue<HeroToggler>()
                                          .IsEnabled(x.Name)
                                   && x.Distance2D(AbilityMain.Me)
                                   < Heals.HealsMenuDictionary[name].Item(name + "waitrange").GetValue<Slider>().Value
                                   && !ability.CanHit(x, MyHeroInfo.Position))))
                            : (Heals.HealsMenuDictionary[name].Item(name + "missinghpmin").GetValue<Slider>().Value
                               < heroMissingHp
                               && Heals.HealsMenuDictionary[name].Item(name + "hppercentbelow").GetValue<Slider>().Value
                               > heroHpPercentage))
                    && (name == "item_urn_of_shadows"
                            ? (!enemyHeroes.Any(x => x.Distance2D(hero) < Math.Max(x.GetAttackRange(), 500))
                               && !hero.HasModifiers(
                                   new[]
                                       {
                                           "modifier_doom_bringer_doom", "modifier_axe_battle_hunger",
                                           "modifier_queenofpain_shadow_strike", "modifier_phoenix_fire_spirit_burn",
                                           "modifier_venomancer_poison_nova", "modifier_venomancer_venomous_gale"
                                       },
                                   false))
                            : (name == "item_arcane_boots"
                               || (enemyHeroes.Count(
                                   x =>
                                   (!Heals.HealsMenuDictionary[name].Item(name + "usenearbool").GetValue<bool>()
                                    || Heals.HealsMenuDictionary[name].Item(name + "usenear")
                                           .GetValue<HeroToggler>()
                                           .IsEnabled(NameManager.Name(x)))
                                   && (x.Distance2D(hero) < Math.Max(x.GetAttackRange(), 700))) - 1
                                   >= Heals.HealsMenuDictionary[name].Item(name + "minenemiesaround")
                                          .GetValue<StringList>()
                                          .SelectedIndex)))
                    && (name != "omniknight_purification" || hero.Health < hero.MaximumHealth * 0.22
                        || enemyHeroes.Any(
                            x => x.Predict(Game.Ping).Distance2D(hero.Predict(Game.Ping)) <= ability.GetRadius(name)))
                    && (!(name == "item_mekansm" || name == "item_guardian_greaves" || name == "chen_hand_of_god")
                        || ((!AllyHeroes.Heroes.Any(
                            x =>
                            !x.Equals(hero)
                            && Heals.HealsMenuDictionary[name].Item(name + "useonallies")
                                   .GetValue<HeroToggler>()
                                   .IsEnabled(x.Name)
                            && x.Distance2D(AbilityMain.Me)
                            < Heals.HealsMenuDictionary[name].Item(name + "waitrange").GetValue<Slider>().Value
                            && !ability.CanHit(x, MyHeroInfo.Position)))
                            && Heals.HealsMenuDictionary[name].Item(name + "minalliesheal")
//.........这里部分代码省略.........
开发者ID:Ray0fHope,项目名称:EnsageSharp,代码行数:101,代码来源:FullCombo.cs

示例4: Execute

        public static bool Execute(
            Hero target, 
            Hero[] enemyHeroes, 
            float ping, 
            bool onlyDamage, 
            bool onlyDisable, 
            Hero me,
            float mana)
        {
            var toggler = MainMenu.ComboKeysMenu.Item("comboAbilitiesToggler").GetValue<AbilityToggler>();
            if (Utils.SleepCheck("UpdateCombo"))
            {
                MyAbilities.Combo =
                    MyAbilities.OffensiveAbilities.Where(
                        x => x.Value.IsValid && x.Value.Owner.Equals(me) && toggler.IsEnabled(NameManager.Name(x.Value)))
                        .OrderBy(x => ComboOrder.GetComboOrder(x.Value, onlyDisable));
                Utils.Sleep(500, "UpdateCombo");
            }

            if (Utils.SleepCheck("casting") && MyAbilities.Combo != null)
            {
                if (target != null)
                {
                    if (Dictionaries.HitDamageDictionary.ContainsKey(target.Handle)
                        && Dictionaries.HitDamageDictionary[target.Handle] * 1.5 >= target.Health
                        && target.Distance2D(MyHeroInfo.Position) <= me.GetAttackRange() + 150)
                    {
                        return false;
                    }

                    if (!Utils.SleepCheck(target.Handle + "KeyCombo"))
                    {
                        return false;
                    }

                    if (AbilityMain.Me.ClassID == ClassID.CDOTA_Unit_Hero_TemplarAssassin)
                    {
                        var r = MyAbilities.Combo.FirstOrDefault(x => x.Key == "templar_assassin_psionic_trapslow");
                        var modifier = target.FindModifier("modifier_templar_assassin_trap_slow");
                        if (modifier == null || modifier.RemainingTime < r.Value.GetHitDelay(target))
                        {
                            Slow.TemplarAssasinUseTrap(target);
                        }
                    }

                    if (me.ClassID == ClassID.CDOTA_Unit_Hero_Tinker && toggler.IsEnabled("tinker_rearm")
                        && MyAbilities.TinkerRearm.CanBeCasted() && Utils.SleepCheck("Ability.TinkerRearm")
                        && !MyAbilities.Combo.Any(
                            x =>
                            x.Value.CanBeCasted()
                            || (x.Value.CanBeCasted(SoulRing.ManaGained) && SoulRing.Check(x.Value))))
                    {
                        MyAbilities.TinkerRearm.UseAbility();
                        Utils.Sleep(
                            MyAbilities.TinkerRearm.FindCastPoint() * 1000 + Game.Ping
                            + MyAbilities.TinkerRearm.GetChannelTime(MyAbilities.TinkerRearm.Level - 1) * 1000 + 500, 
                            "Ability.TinkerRearm");
                        Utils.Sleep(
                            MyAbilities.TinkerRearm.FindCastPoint() * 1000 + Game.Ping
                            + MyAbilities.TinkerRearm.GetChannelTime(MyAbilities.TinkerRearm.Level - 1) * 1000, 
                            "GlobalCasting");
                        Utils.Sleep(
                            MyAbilities.TinkerRearm.FindCastPoint() * 1000 + Game.Ping
                            + MyAbilities.TinkerRearm.GetChannelTime(MyAbilities.TinkerRearm.Level - 1) * 1000, 
                            "casting");
                        Utils.Sleep(
                            MyAbilities.TinkerRearm.FindCastPoint() * 1000 + Game.Ping
                            + MyAbilities.TinkerRearm.GetChannelTime(MyAbilities.TinkerRearm.Level - 1) * 1000, 
                            "cancelorder");
                        return true;
                    }

                    foreach (var data in
                        MyAbilities.Combo.Where(
                            x =>
                            x.Value.IsValid
                            && (x.Value.CanBeCasted()
                                || (x.Value.CanBeCasted(SoulRing.ManaGained) && SoulRing.Check(x.Value)))
                            && !x.Value.IsAbilityBehavior(AbilityBehavior.Hidden)
                            && ((x.Value is Item && me.CanUseItems()) || (!(x.Value is Item) && me.CanCast()))
                            && (Utils.SleepCheck(x.Value.Handle.ToString())
                                || (!x.Value.IsInAbilityPhase && x.Value.FindCastPoint() > 0))))
                    {
                        var ability = data.Value;
                        var name = NameManager.Name(ability);
                        var category = (name == "lion_impale") ? "disable" : data.Key.Substring(name.Length);

                        // if (category == "special" || category == "buff")
                        // {
                        // continue;
                        // }
                        // if (onlyDamage && (category == "disable" || category == "slow" || category == "silence"))
                        // {
                        // continue;
                        // }
                        // if (onlyDisable && (category == "nuke" || category == "harras"))
                        // {
                        // continue;
                        // }
                        if (category != "buff" && target.IsMagicImmune() && ability.ImmunityType != (ImmunityType)3)
//.........这里部分代码省略.........
开发者ID:Ray0fHope,项目名称:EnsageSharp,代码行数:101,代码来源:FullCombo.cs

示例5: AutoUsage

        public static bool AutoUsage(
            Hero enemyHero, 
            Hero[] enemyHeroes, 
            float meMissingHp,
            float ping, 
            Hero me, 
            float mana)
        {
            var hero = enemyHero;
            var heroName = NameManager.Name(hero);
            var heroDistance = MyHeroInfo.Position.Distance2D(hero);
            if (Utils.SleepCheck("GlobalCasting") && Utils.SleepCheck("casting"))
            {
                if (me.ClassID == ClassID.CDOTA_Unit_Hero_Tusk
                    && Dictionaries.InDamageDictionary.ContainsKey(hero.Handle)
                    && (Dictionaries.OutDamageDictionary[hero.Handle] + Dictionaries.InDamageDictionary[hero.Handle])
                    >= enemyHero.Health && Utils.SleepCheck("tusk_snowball") && heroDistance <= 1350
                    && me.FindSpell("tusk_snowball").CanBeCasted())
                {
                    if (!Nuke.Cast(me.FindSpell("tusk_snowball"), hero, "tusk_snowball"))
                    {
                        return false;
                    }

                    DelayAction.Add(
                        new DelayActionItem(300, () => { AbilityMain.LaunchSnowball(); }, CancellationToken.None));
                    Utils.Sleep(100 + me.GetTurnTime(hero) * 1000 + ping, "tusk_snowball");
                    Utils.Sleep(me.GetTurnTime(hero) * 1000 + (heroDistance / 675) * 1000 + 100, "GlobalCasting");
                    Utils.Sleep(me.GetTurnTime(hero) * 1000 + (heroDistance / 675) * 1000 + 100, "calculate");
                    Utils.Sleep(me.GetTurnTime(hero) * 1000 + (heroDistance / 675) * 1000, "cancelorder");

                    return true;
                }

                foreach (var data in
                    MyAbilities.OffensiveAbilities.Where(
                        x =>
                        x.Value.IsValid
                        && (x.Value.CanBeCasted()
                            || (x.Value.CanBeCasted(SoulRing.ManaGained) && SoulRing.Check(x.Value)))
                        && ((x.Value is Item && me.CanUseItems()) || (!(x.Value is Item) && me.CanCast()))
                        && (Utils.SleepCheck(x.Value.Handle.ToString())
                            || (!x.Value.IsInAbilityPhase && x.Value.FindCastPoint() > 0)))
                        .OrderBy(x => ComboOrder.GetAbilityOrder(x.Value)))
                {
                    var ability = data.Value;
                    var name = NameManager.Name(ability);
                    var category = data.Key.Substring(name.Length);
                    var handleString = ability.Handle.ToString();
                    if (category != "buff" && hero.IsMagicImmune() && ability.ImmunityType != (ImmunityType)3)
                    {
                        continue;
                    }

                    if (!CastingChecks.All(name, hero))
                    {
                        continue;
                    }

                    var delay = ability.GetCastDelay(me, hero, useCastPoint: false, abilityName: name) * 1000;
                    var canHit = ability.CanHit(hero, MyHeroInfo.Position, name);
                    if (name == "omniknight_purification")
                    {
                        if (Nukes.NukesMenuDictionary[name].Item(name + "minManaCheck").GetValue<Slider>().Value < mana
                            && MainMenu.Menu.Item("nukesToggler").GetValue<AbilityToggler>().IsEnabled(name)
                            && Nukes.NukesMenuDictionary[name].Item(name + "herotoggler")
                                   .GetValue<HeroToggler>()
                                   .IsEnabled(heroName)
                            && (etherealHitTime < (Environment.TickCount + ability.GetHitDelay(hero, name) * 1000))
                            && hero.Health
                            > Nukes.NukesMenuDictionary[name].Item(NameManager.Name(ability) + "minhealthslider")
                                  .GetValue<Slider>()
                                  .Value && CastingChecks.Killsteal(ability, hero, name))
                        {
                            var target = FindPurificationTarget(hero);
                            if (target != null && ability.CanHit(target, MyHeroInfo.Position, name)
                                && target.PredictedPosition().Distance2D(hero.PredictedPosition())
                                < ability.GetRadius(name)
                                && target.PredictedPosition()
                                       .Distance2D(
                                           hero.PredictedPosition(ability.FindCastPoint(NameManager.Name(ability))))
                                < ability.GetRadius(name))
                            {
                                if (Nuke.Cast(ability, target, name))
                                {
                                    Utils.Sleep(
                                        ability.GetCastDelay(me, hero, abilityName: name) * 1000 + ping + 100, 
                                        handleString);
                                    Utils.Sleep(delay, "GlobalCasting");
                                    Utils.Sleep(delay, "cancelorder");

                                    // Utils.Sleep(ping, "killsteal");
                                    return true;
                                }
                            }
                        }

                        return false;
                    }

//.........这里部分代码省略.........
开发者ID:Ray0fHope,项目名称:EnsageSharp,代码行数:101,代码来源:FullCombo.cs


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