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


C# Unit.FindItem方法代码示例

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


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

示例1: FindMidas

 // --→ Function: Find Midas
 private static Item FindMidas(Unit entity)
 {
     if (entity.ClassID.Equals(ClassID.CDOTA_Unit_Hero_LoneDruid))
     {
         var bear = ObjectMgr.GetEntities<Unit>().Where(unit => unit.ClassID.Equals(ClassID.CDOTA_Unit_SpiritBear) && unit.IsAlive && unit.Team.Equals(mHero.Team) && unit.IsControllable).ToList();
         var heroMidas = entity.FindItem("item_hand_of_midas");
         if (heroMidas.CanBeCasted()) return heroMidas;
         return bear.Any() ? bear.First().FindItem("item_hand_of_midas") : null;
     }
     else
     {
         var heroMidas = entity.FindItem("item_hand_of_midas");
         return heroMidas;
     }
 }
开发者ID:vitac1998,项目名称:ensagesharp-1,代码行数:16,代码来源:AutoMidas.cs

示例2: CastSpell

        private static void CastSpell(Unit hero, ExecuteOrderEventArgs args)
        {
            var spell = args.Ability;

            if (hero == null || spell == null || spell.ManaCost <= 25 || IgnoredSpells.Any(spell.Name.Contains))
                return;

            var powerTreads = hero.FindItem("item_power_treads");

            if (powerTreads == null)
                return;

            args.Process = false;

            var sleep = spell.FindCastPoint() * 1000 + 555;

            switch (args.Order) {
                case Order.AbilityTarget: {
                    var target = (Unit) args.Target;
                    if (target != null && target.IsAlive) {

                        var castRange = spell.GetCastRange() + 300;

                        if (hero.Distance2D(target) <= castRange) {
                            ChangePt(powerTreads, Attribute.Intelligence);
                            sleep += hero.GetTurnTime(target) * 1000;
                        }

                        spell.UseAbility(target);

                    }
                    break;
                }
                case Order.AbilityLocation: {
                    var castRange = spell.GetCastRange() + 300;

                    if (hero.Distance2D(Game.MousePosition) <= castRange) {
                        ChangePt(powerTreads, Attribute.Intelligence);
                        sleep += hero.GetTurnTime(Game.MousePosition) * 1000;
                    }

                    spell.UseAbility(Game.MousePosition);

                    break;
                }
                case Order.Ability: {
                    ChangePt(powerTreads, Attribute.Intelligence);
                    spell.UseAbility();
                    break;
                }
                case Order.ToggleAbility: {
                    ChangePt(powerTreads, Attribute.Intelligence);
                    spell.ToggleAbility();
                    break;
                }
            }

            Utils.Sleep(sleep, "delay");
        }
开发者ID:7ajlosh,项目名称:Ensage,代码行数:59,代码来源:Program.cs

示例3: CastSpell

 private static void CastSpell(Ability spell, Unit target, Unit me, bool lsblock)
 {
     if (spell.CanBeCasted() && me.CanCast() && (target.Modifiers.FirstOrDefault(modifier => modifier.Name == "modifier_item_sphere") == null || target.FindItem("item_sphere").Cooldown > 0) || lsblock == false)
         spell.UseAbility(target);
 }
开发者ID:YukinoAguria,项目名称:ensagesharp,代码行数:5,代码来源:Program.cs

示例4: SafeTp

        private static bool SafeTp(Unit me, Ability w)
        {
            if (true) //(Menu.Item("AutoHeal.Hero.Enable").GetValue<bool>())
            {
                var handle = me.Handle;
                bool nh;
                if (!NeedHeal.TryGetValue(handle, out nh))
                    NeedHeal.Add(handle, false);
                var perc = me.Health/(float) me.MaximumHealth*100;
                //Print(String.Format("Health: {0}, Max Health: {1}, Percent: {2}", Me.Health, Me.MaximumHealth, perc));
                if (NeedHeal[handle])
                {
                    if ((perc > 95 &&
                         me.HasModifiers(new[] {"modifier_fountain_aura", "modifier_fountain_aura_buff"}, false)) ||
                        OrderStates[handle] != OrderState.Escape)
                    {
                        NeedHeal[handle] = false;
                        var newOrder = LastOrderStates[handle] != OrderState.Escape
                            ? LastOrderStates[handle]
                            : OrderState.Idle;
                        OrderStates[handle] = _globalTarget == null ? newOrder/*OrderState.Idle*/ : OrderState.InCombo;
                        //Print(newOrder.ToString());
                        //Print("im full now ["+handle+"]");
                    }
                    else if (!me.HasModifiers(new[] {"modifier_fountain_aura", "modifier_fountain_aura_buff"}, false))
                    {
                        if (Utils.SleepCheck("move check" + handle))
                        {
                            var anyEnemyHero =
                                Heroes.GetByTeam(me.GetEnemyTeam())
                                    .FirstOrDefault(x => x.IsAlive && x.IsVisible && x.Distance2D(me) <= 800);
                            if (anyEnemyHero != null)
                            {
                                var spell = SpellQ[handle];
                                if (spell != null && spell.CanBeCasted() && !anyEnemyHero.HasModifier("modifier_meepo_earthbind"))
                                {
                                    spell.CastSkillShot(anyEnemyHero);
                                }
                            }
                            var anyAllyMeepoNearBase =
                                _meepoList.Where(
                                    x =>
                                        !Equals(x, me) && x.Distance2D(Fountains.GetAllyFountain()) <= 5000 &&
                                        !Heroes.GetByTeam(me.GetEnemyTeam()).Any(y => y.IsAlive && y.IsVisible && y.Distance2D(x) <= 1500))
                                    .OrderBy(z => z.Distance2D(Fountains.GetAllyFountain())).FirstOrDefault();
                            var underTower = Towers.All.Where(x => x.Team == me.GetEnemyTeam())
                                .Any(x => x.Distance2D(me) <= 800);
                            if (anyAllyMeepoNearBase != null && w.CanBeCasted() && !underTower)
                            {
                                if (Utils.SleepCheck("poofTimeToBase" + handle))
                                {
                                    w.UseAbility(anyAllyMeepoNearBase.Position);
                                    Utils.Sleep(2000, "poofTimeToBase" + handle);
                                }
                            }
                            var channeledAbility = me.GetChanneledAbility();
                            var travelBoots = me.FindItem("item_travel_boots", true) ??
                                              me.FindItem("item_travel_boots_2", true) ??
                                              me.FindItem("item_tpscroll", true);
                            if (me.IsChanneling() && channeledAbility.Name != "item_travel_boots"
                                && channeledAbility.Name != "item_travel_boots_2" &&
                                channeledAbility.Name != "item_tpscroll")
                            {
                                //do nothing while in tp
                            }
                            else if (!underTower && travelBoots != null && travelBoots.CanBeCasted() &&
                                     me.Distance2D(Fountains.GetAllyFountain()) >= 5000 && Utils.SleepCheck("tp_cd" + handle) && Utils.SleepCheck("poofTimeToBase" + handle))
                            {
                                Utils.Sleep(250, "tp_cd" + handle);
                                travelBoots.UseAbility(Fountains.GetAllyFountain().Position);
                            }
                            else
                            {
                                me.Move(Fountains.GetAllyFountain().Position);
                            }
                            Utils.Sleep(500, "move check"+handle);
                        }
                    }
                }
                else
                {
                    if (perc < Menu.Item("Escape.MinRangePercent").GetValue<Slider>().Value || me.Health <= Menu.Item("Escape.MinRange").GetValue<Slider>().Value)
                    {
                        //Print("hp too low, go to fountain. Perc: "+perc);
                        NeedHeal[handle] = true;
                        LastOrderStates[handle] = OrderStates[handle] == OrderState.Escape
                            ? OrderState.Idle
                            : OrderStates[handle];

                        OrderStates[handle] = OrderState.Escape;
                    }
                    else
                    {
                        //Print("checking for hp");
                    }
                }
                return NeedHeal[handle];
            }
        }
开发者ID:JumpAttacker,项目名称:EnsageSharp,代码行数:99,代码来源:Program.cs


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