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


C# Unit.HasModifiers方法代码示例

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


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

示例1: IsDisembodied

        private bool IsDisembodied(Unit target)
        {
            string[] modifs =
            {
                "modifier_item_ethereal_blade_ethereal",
                "modifier_pugna_decrepify"
            };

            return target.HasModifiers(modifs);
        }
开发者ID:VickTheRock,项目名称:ReworkAllScripts,代码行数:10,代码来源:EarthshakerController.cs

示例2: CanAttack

        /// <summary>
        ///     The can attack.
        /// </summary>
        /// <param name="target">
        ///     The target.
        /// </param>
        /// <param name="bonusWindupMs">
        ///     The bonus windup milliseconds.
        /// </param>
        /// <returns>
        ///     The <see cref="bool" />.
        /// </returns>
        public bool CanAttack(Unit target = null, float bonusWindupMs = 0)
        {
            if (this.Unit == null || !this.Unit.IsValid)
            {
                return false;
            }

            var targetHull = 0f;
            if (target != null)
            {
                targetHull = target.HullRadius;
            }

            float distance = 0;
            if (target != null)
            {
                var pos = Prediction.InFront(
                    this.Unit, 
                    (float)(Game.Ping / 1000 + this.Unit.GetTurnTime(target.Position) * this.Unit.MovementSpeed));
                distance = pos.Distance2D(target) - this.Unit.Distance2D(target);
            }

            var isValid = (target != null && target.IsValid && target.IsAlive && target.IsVisible && !target.IsInvul()
                           && !target.HasModifiers(
                               new[] { "modifier_ghost_state", "modifier_item_ethereal_blade_slow" }, 
                               false)
                           && target.Distance2D(this.Unit)
                           <= this.Unit.GetAttackRange() + this.Unit.HullRadius + 75 + targetHull
                           + Math.Max(distance, 0))
                          || (target != null && this.Unit.IsAttacking() && this.Unit.GetTurnTime(target.Position) < 0.1);

            return !this.IsAttackOnCoolDown(target, bonusWindupMs) && (target == null || isValid);
        }
开发者ID:EnsageSharp,项目名称:Ensage.Common,代码行数:45,代码来源:AttackAnimationTracker.cs

示例3: 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

示例4: Orbwalk

        /// <summary>
        ///     Orbwalks on given target if they are in range, while moving to mouse position
        /// </summary>
        /// <param name="target"></param>
        /// <param name="bonusWindupMs"></param>
        /// <param name="bonusRange"></param>
        /// <param name="attackmodifiers"></param>
        public static void Orbwalk(
            Unit target, 
            float bonusWindupMs = 0, 
            float bonusRange = 0, 
            bool attackmodifiers = false)
        {
            if (me == null)
            {
                return;
            }

            // if (!Utils.SleepCheck("GlobalCasting"))
            // {
            // return;
            // }
            var targetHull = 0f;
            if (target != null)
            {
                targetHull = target.HullRadius;
            }

            float distance = 0;
            if (target != null)
            {
                var pos = Prediction.InFront(
                    me, 
                    (float)((Game.Ping / 1000 + me.GetTurnTime(target.Position)) * me.MovementSpeed));
                distance = pos.Distance2D(target) - me.Distance2D(target);
            }

            var isValid = target != null && target.IsValid && target.IsAlive && target.IsVisible && !target.IsInvul()
                          && !target.HasModifiers(
                              new[] { "modifier_ghost_state", "modifier_item_ethereal_blade_slow" }, 
                              false)
                          && target.Distance2D(me)
                          <= me.GetAttackRange() + me.HullRadius + 50 + targetHull + bonusRange + Math.Max(distance, 0);
            if (isValid || (target != null && me.IsAttacking() && me.GetTurnTime(target.Position) < 0.1))
            {
                var canAttack = !AttackOnCooldown(target, bonusWindupMs) && !target.IsAttackImmune()
                                && !target.IsInvul() && me.CanAttack();
                if (canAttack && Utils.SleepCheck("Orbwalk.Attack"))
                {
                    Attack(target, attackmodifiers);
                    Utils.Sleep(
                        UnitDatabase.GetAttackPoint(me) * 1000 + me.GetTurnTime(target) * 1000, 
                        "Orbwalk.Attack");
                    return;
                }
            }

            var canCancel = (CanCancelAnimation() && AttackOnCooldown(target, bonusWindupMs))
                            || (!isValid && !me.IsAttacking() && CanCancelAnimation());
            if (!canCancel || !Utils.SleepCheck("Orbwalk.Move") || !Utils.SleepCheck("Orbwalk.Attack"))
            {
                return;
            }

            me.Move(Game.MousePosition);
            Utils.Sleep(100, "Orbwalk.Move");
        }
开发者ID:nbIxMaN,项目名称:Ensage.Common,代码行数:67,代码来源:Orbwalking.cs

示例5: AbilityMove

 /// <summary>
 ///     The ability move.
 /// </summary>
 /// <param name="unit">
 ///     The unit.
 /// </param>
 /// <returns>
 ///     The <see cref="bool" />.
 /// </returns>
 public static bool AbilityMove(Unit unit)
 {
     return
         unit.HasModifiers(
             new[]
                 {
                     "modifier_spirit_breaker_charge_of_darkness", "modifier_earth_spirit_boulder_smash", 
                     "modifier_earth_spirit_rolling_boulder_caster", "modifier_earth_spirit_geomagnetic_grip", 
                     "modifier_spirit_breaker_charge_of_darkness", "modifier_huskar_life_break_charge", 
                     "modifier_magnataur_skewer_movement", "modifier_storm_spirit_ball_lightning", 
                     "modifier_faceless_void_time_walk", "modifier_mirana_leap", "modifier_slark_pounce"
                 }, 
             false);
 }
开发者ID:EnsageSharp,项目名称:Ensage.Common,代码行数:23,代码来源:Prediction.cs

示例6: OrbwalkOn

        /// <summary>
        ///     The orbwalk.
        /// </summary>
        /// <param name="target">
        ///     The target.
        /// </param>
        /// <param name="movePosition">
        ///     The move Position.
        /// </param>
        /// <param name="bonusWindupMs">
        ///     The bonus windup ms.
        /// </param>
        /// <param name="bonusRange">
        ///     The bonus range.
        /// </param>
        /// <param name="attackmodifiers">
        ///     The attackmodifiers.
        /// </param>
        /// <param name="followTarget">
        ///     The follow target.
        /// </param>
        public void OrbwalkOn(
            Unit target, 
            Vector3 movePosition, 
            float bonusWindupMs = 0, 
            float bonusRange = 0, 
            bool attackmodifiers = true, 
            bool followTarget = false)
        {
            if (this.Unit == null || !this.Unit.IsValid)
            {
                return;
            }

            var targetHull = 0f;
            if (target != null)
            {
                targetHull = target.HullRadius;
            }

            float distance = 0;
            if (target != null)
            {
                var pos = Prediction.InFront(
                    this.Unit, 
                    (float)(Game.Ping / 1000 + this.Unit.GetTurnTime(target.Position) * this.Unit.MovementSpeed));
                distance = pos.Distance2D(target) - this.Unit.Distance2D(target);
            }

            var isValid = target != null && target.IsValid && target.IsAlive && target.IsVisible;
            var isAttackable = target != null && target.IsValid && !target.IsInvul() && !target.IsAttackImmune()
                               && !target.HasModifiers(
                                   new[] { "modifier_ghost_state", "modifier_item_ethereal_blade_slow" }, 
                                   false)
                               && target.Distance2D(this.Unit)
                               <= this.Unit.GetAttackRange() + this.Unit.HullRadius + 50 + targetHull + bonusRange
                               + Math.Max(distance, 0);
            if ((isValid && isAttackable)
                || (!isAttackable && target != null && target.IsValid && this.Unit.IsAttacking()
                    && this.Unit.GetTurnTime(target.Position) < 0.1))
            {
                var canAttack = !this.IsAttackOnCoolDown(target, bonusWindupMs) && this.Unit.CanAttack();
                if (canAttack && !this.attackSleeper.Sleeping && (!this.hero || Utils.SleepCheck("Orbwalk.Attack")))
                {
                    this.attacker.Attack(target, attackmodifiers);
                    this.AttackOrder();
                    this.attackSleeper.Sleep(
                        (float)
                        (UnitDatabase.GetAttackPoint(this.Unit) * 1000 + this.Unit.GetTurnTime(target) * 1000
                         + Game.Ping + 100));
                    this.moveSleeper.Sleep(
                        (float)
                        (UnitDatabase.GetAttackPoint(this.Unit) * 1000 + this.Unit.GetTurnTime(target) * 1000 + 50));
                    if (!this.hero)
                    {
                        return;
                    }

                    Utils.Sleep(
                        UnitDatabase.GetAttackPoint(this.Unit) * 1000 + this.Unit.GetTurnTime(target) * 1000 + Game.Ping
                        + 100, 
                        "Orbwalk.Attack");
                    Utils.Sleep(
                        UnitDatabase.GetAttackPoint(this.Unit) * 1000 + this.Unit.GetTurnTime(target) * 1000 + 50, 
                        "Orbwalk.Move");
                    return;
                }

                if (canAttack && !this.attackSleeper2.Sleeping)
                {
                    this.attacker.Attack(target, attackmodifiers);
                    this.AttackOrder();
                    this.attackSleeper2.Sleep(100);
                    return;
                }
            }

            var userdelay = this.setUserDelayManually ? this.UserDelay : Orbwalking.UserDelay;
            var canCancel = (this.CanCancelAttack(userdelay) && this.IsAttackOnCoolDown(target, bonusWindupMs))
                            || ((!isValid || !isAttackable)
//.........这里部分代码省略.........
开发者ID:EnsageSharp,项目名称:Ensage.Common,代码行数:101,代码来源:Orbwalker.cs


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