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


C# Unit.Distance2D方法代码示例

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


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

示例1: Cast

 public static bool Cast(Ability ability, Unit target, string name)
 {
     if (name == "razor_static_link" && target.Distance2D(AbilityMain.Me) > (ability.GetCastRange(name) * 0.75))
     {
         return false;
     }
     if (ability.IsAbilityBehavior(AbilityBehavior.UnitTarget, name))
     {
         Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
         ManageAutoAttack.AutoAttackDisabled = true;
         SoulRing.Cast(ability);
         ability.UseAbility(target);
         return true;
     }
     if ((ability.IsAbilityBehavior(AbilityBehavior.AreaOfEffect, name)
          || ability.IsAbilityBehavior(AbilityBehavior.Point, name))
         && (Prediction.StraightTime(target) > 1000 || target.MovementSpeed < 200))
     {
         Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
         ManageAutoAttack.AutoAttackDisabled = true;
         return ability.CastSkillShot(target, name, SoulRing.Check(ability) ? MyAbilities.SoulRing : null);
     }
     if (ability.IsAbilityBehavior(AbilityBehavior.NoTarget, name))
     {
         Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
         ManageAutoAttack.AutoAttackDisabled = true;
         SoulRing.Cast(ability);
         ability.UseAbility();
         return true;
     }
     return false;
 }
开发者ID:dendimonster,项目名称:EnsageSharp,代码行数:32,代码来源:Special.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: CastStun

 /// <summary>
 ///     Uses given ability in case enemy is not disabled or would be chain stunned.
 /// </summary>
 /// <param name="ability"></param>
 /// <param name="target"></param>
 /// <param name="sourcePosition"></param>
 /// <param name="straightTimeforSkillShot"></param>
 /// <param name="chainStun"></param>
 /// <param name="useSleep"></param>
 /// <returns>returns true in case of successfull cast</returns>
 public static bool CastStun(
     this Ability ability,
     Unit target,
     Vector3 sourcePosition,
     float straightTimeforSkillShot = 0,
     bool chainStun = true,
     bool useSleep = true)
 {
     var owner = ability.Owner as Unit;
     var position = owner.Position;
     if (sourcePosition != Vector3.Zero)
     {
         position = sourcePosition;
     }
     if (!ability.CanBeCasted())
     {
         return false;
     }
     var delay = ability.GetHitDelay(target);
     var radius = ability.GetRadius();
     var canUse = Utils.ChainStun(target, delay, null, false, ability.Name);
     if (!canUse && chainStun)
     {
         return false;
     }
     if (ability.AbilityBehavior.HasFlag(AbilityBehavior.UnitTarget) && ability.Name != "lion_impale")
     {
         ability.UseAbility(target);
     }
     else if ((ability.AbilityBehavior.HasFlag(AbilityBehavior.AreaOfEffect)
               || ability.AbilityBehavior.HasFlag(AbilityBehavior.Point)))
     {
         if (Prediction.StraightTime(target) > straightTimeforSkillShot * 1000
             && ability.CastSkillShot(target))
         {
             if (useSleep)
             {
                 Utils.Sleep(Math.Max(delay, 0.2) * 1000 + 250, "CHAINSTUN_SLEEP");
             }
             return true;
         }
         return false;
     }
     else if (ability.AbilityBehavior.HasFlag(AbilityBehavior.NoTarget))
     {
         if (target.Distance2D(position) > radius)
         {
             return false;
         }
         ability.UseAbility();
     }
     if (useSleep)
     {
         Utils.Sleep(Math.Max(delay, 0.2) * 1000 + 250, "CHAINSTUN_SLEEP");
     }
     return true;
 }
开发者ID:beminee,项目名称:Ensage.Common,代码行数:67,代码来源:AbilityExtensions.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: 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;
     }
     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.Distance2D(me)
                   <= (me.GetAttackRange() + me.HullRadius + 50 + targetHull + bonusRange + distance);
     if (isValid || (target != null && me.IsAttacking() && me.GetTurnTime(target.Position) < 0.1))
     {
         var canAttack = (!AttackOnCooldown(target, bonusWindupMs) || !CanCancelAnimation())
                         && !target.IsAttackImmune() && !target.IsInvul() && me.CanAttack();
         if (canAttack && Utils.SleepCheck("Orbwalk.Attack"))
         {
             Attack(target, attackmodifiers);
             Utils.Sleep(100, "Orbwalk.Attack");
             return;
         }
     }
     var canCancel = (CanCancelAnimation() && AttackOnCooldown(target, bonusWindupMs))
                     || (!isValid && !me.IsAttacking());
     if (!canCancel || !Utils.SleepCheck("Orbwalk.Move"))
     {
         return;
     }
     me.Move(Game.MousePosition);
     Utils.Sleep(100, "Orbwalk.Move");
 }
开发者ID:MarkHC,项目名称:Ensage.Common,代码行数:53,代码来源:Orbwalking.cs

示例6: CreepCount

 private static int CreepCount(Unit h, float radius)
 {
     try
     {
         return
             ObjectManager.GetEntities<Unit>()
                 .Where(x => x.Team == Team.Neutral && x.IsSpawned && x.IsVisible && h.Distance2D(x) <= radius)
                 .ToList().Count;
     }
     catch (Exception)
     {
         //
     }
     return 0;
 }
开发者ID:Zuena,项目名称:Ensagebeminee,代码行数:15,代码来源:Program.cs

示例7: Cast

 public static bool Cast(Ability ability, Unit target, string name)
 {
     if (target.Modifiers.Any(x => x.Name == "modifier_item_blade_mail_reflect")
         && AbilityDamage.CalculateDamage(ability, AbilityMain.Me, target) > AbilityMain.Me.Health)
     {
         return false;
     }
     if (target.Modifiers.Any(x => x.Name == "modifier_nyx_assassin_spiked_carapace"))
     {
         return false;
     }
     if (ability.Name == "sniper_assassinate")
     {
         if (AbilityMain.Me.Distance2D(target) <= AbilityMain.Me.GetAttackRange() + 100)
         {
             return false;
         }
     }
     if (ability.IsAbilityBehavior(AbilityBehavior.UnitTarget, name) && ability.Name != "lion_impale")
     {
         Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
         ManageAutoAttack.AutoAttackDisabled = true;
         SoulRing.Cast(ability);
         if (name == "omniknight_purification")
         {
             ability.UseAbility(AbilityMain.Me);
         }
         ability.UseAbility(target);
         return true;
     }
     if ((ability.IsAbilityBehavior(AbilityBehavior.AreaOfEffect, name)
          || ability.IsAbilityBehavior(AbilityBehavior.Point, name))
         && (Prediction.StraightTime(target) > 1000 || target.MovementSpeed < 200))
     {
         Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
         ManageAutoAttack.AutoAttackDisabled = true;
         return ability.CastSkillShot(target, name, SoulRing.Check(ability) ? MyAbilities.SoulRing : null);
     }
     if (ability.IsAbilityBehavior(AbilityBehavior.NoTarget, name))
     {
         if (ability.Name == "templar_assassin_meld")
         {
             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();
             DelayAction.Add(
                 new DelayActionItem(
                     (int)ability.GetCastDelay(AbilityMain.Me, target)*1000,
                     () =>
                         {
                             AbilityMain.Me.Attack(target);
                         },
                     CancellationToken.None));
             Utils.Sleep(ability.GetCastDelay(AbilityMain.Me, target) * 1000, "GlobalCasting");
             Utils.Sleep(ability.GetCastDelay(AbilityMain.Me, target) * 1000 + 200, "casting");
             Utils.Sleep(ability.GetCastDelay(AbilityMain.Me, target) * 1000 + 200, "Ability.Move");
             return true;
         }
         if (ability.Name.Contains("nevermore_shadowraze"))
         {
             Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
             ManageAutoAttack.AutoAttackDisabled = true;
             return ability.CastSkillShot(target, name);
         }
         SoulRing.Cast(ability);
         Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
         ManageAutoAttack.AutoAttackDisabled = true;
         ability.UseAbility();
         return true;
     }
     return false;
 }
开发者ID:dendimonster,项目名称:EnsageSharp,代码行数:82,代码来源:Nuke.cs

示例8: SuicideKillSteal

 private static void SuicideKillSteal(Unit hero)
 {
     if (!Utils.SleepCheck("suicide"))
     {
         return;
     }
     var pos = hero.Position;
     if (hero.NetworkActivity == NetworkActivity.Move)
     {
         pos = Prediction.InFront(hero, (float)((Game.Ping / 1000 + me.GetTurnTime(hero)) * hero.MovementSpeed));
     }
     if (pos.Distance2D(me) < hero.Distance2D(me))
     {
         pos = hero.Position;
     }
     if (me.Distance2D(pos) > 100)
     {
         pos = (pos - me.Position) * 99 / pos.Distance2D(me) + me.Position;
     }
     if (!(pos.Distance2D(me) < suicideAttackRadius))
     {
         return;
     }
     var dmg = hero.DamageTaken(suicideAttackDmg, DamageType.Physical, me, true);
     //Console.WriteLine(dmg);
     if (!(dmg >= hero.Health))
     {
         return;
     }
     suicideAttack.UseAbility(pos);
     Utils.Sleep(500, "suicide");
 }
开发者ID:anon2281,项目名称:EnsageSharp,代码行数:32,代码来源:Techies.cs

示例9: CastStun

 /// <summary>
 ///     Uses given ability in case enemy is not disabled or would be chain stunned.
 /// </summary>
 /// <param name="ability"></param>
 /// <param name="target"></param>
 /// <returns>returns true in case of successfull cast</returns>
 public static bool CastStun(this Ability ability, Unit target)
 {
     if (!ability.CanBeCasted())
     {
         return false;
     }
     var data = AbilityDatabase.Find(ability.Name);
     var owner = ability.Owner;
     var delay = Game.Ping / 1000 + ability.GetCastPoint();
     var radius = 0f;
     if (!ability.AbilityBehavior.HasFlag(AbilityBehavior.NoTarget))
     {
         delay += (float)owner.GetTurnTime(target);
     }
     if (data != null)
     {
         if (data.AdditionalDelay > 0)
         {
             delay += (float)data.AdditionalDelay;
         }
         if (data.Speed != null)
         {
             var speed = ability.AbilityData.FirstOrDefault(x => x.Name == data.Speed)
                 .GetValue(ability.Level - 1);
             delay += owner.Distance2D(target) / speed;
         }
         if (data.Radius != 0)
         {
             radius = data.Radius;
         }
         else if (data.StringRadius != null)
         {
             radius =
                 ability.AbilityData.FirstOrDefault(x => x.Name == data.StringRadius).GetValue(ability.Level - 1);
         }
         else if (data.Width != null)
         {
             radius = ability.AbilityData.FirstOrDefault(x => x.Name == data.Width).GetValue(ability.Level - 1);
         }
     }
     var canUse = Utils.ChainStun(target, delay, null, false);
     if (!canUse)
     {
         return false;
     }
     if (ability.AbilityBehavior.HasFlag(AbilityBehavior.UnitTarget))
     {
         ability.UseAbility(target);
     }
     else if (ability.AbilityBehavior.HasFlag(AbilityBehavior.AreaOfEffect))
     {
         ability.CastSkillShot(target);
     }
     else if (ability.AbilityBehavior.HasFlag(AbilityBehavior.NoTarget))
     {
         if (target.Distance2D(owner) > radius)
         {
             return false;
         }
         ability.UseAbility();
     }
     Utils.Sleep(delay * 1000, "CHAINSTUN_SLEEP");
     return true;
 }
开发者ID:MarkHC,项目名称:Ensage.Common,代码行数:70,代码来源:AbilityExtensions.cs

示例10: DoShit

 private static void DoShit(Unit hero, bool isTempest=false)
 {
     var handle = hero.Handle;
     var items = isTempest?hero.Inventory.Items.ToList():null;
     var travelBoots = isTempest?
         items.FirstOrDefault(
             x =>
                 (x.Name == "item_travel_boots" ||
                 x.Name == "item_travel_boots_2") && x.CanBeCasted() &&
                 Utils.SleepCheck("Tempest.Travels.Cd" + handle)):null;
     var autoPushItems =isTempest?
         items.Where(
             x =>
                 AutoPushItems.Contains(x.Name) && x.CanBeCasted() &&
                 Utils.SleepCheck("Tempest.AutoPush.Cd" + handle + x.Name)):null;
     var myCreeps = Objects.LaneCreeps.GetCreeps().Where(x => x.Team == hero.Team).ToList();
     var enemyCreeps = Objects.LaneCreeps.GetCreeps().Where(x => x.Team != hero.Team).ToList();
     var creepWithEnemy =
         myCreeps.FirstOrDefault(
             x => x.MaximumHealth * 65 / 100 < x.Health && enemyCreeps.Any(y => y.Distance2D(x) <= 1000));
     var isChannel = isTempest && hero.IsChanneling();
     if (travelBoots != null && !enemyCreeps.Any(x => x.Distance2D(hero) <= 1000) && isTempest && !isChannel)
     {
         if (creepWithEnemy == null)
         {
             creepWithEnemy = myCreeps.OrderByDescending(x => x.Distance2D(hero)).FirstOrDefault();
         }
         if (creepWithEnemy != null)
         {
             travelBoots.UseAbility(creepWithEnemy);
             Utils.Sleep(500, "Tempest.Travels.Cd" + handle);
             return;
         }
     }
     if (isChannel) return;
     var nearestTower =
             Objects.Towers.GetTowers()
                 .Where(x => x.Team == hero.GetEnemyTeam())
                 .OrderBy(y => y.Distance2D(hero))
                 .FirstOrDefault() ?? Objects.Fountains.GetEnemyFountain();
     var fountain = Objects.Fountains.GetAllyFountain();
     var curlane = GetCurrentLane(hero);
     var clospoint = GetClosestPoint(curlane);
     var useThisShit = clospoint.Distance2D(fountain) - 250 > hero.Distance2D(fountain);
     //Print($"{clospoint.Distance2D(fountain)} ??? {hero.Distance2D(fountain)}");
     if (nearestTower != null)
     {
         var pos = curlane == "mid" || !useThisShit ? nearestTower.Position : clospoint;
         if (nearestTower.Distance2D(hero) <= 1000 && Utils.SleepCheck("Tempest.Attack.Tower.Cd" + handle) &&
             Utils.SleepCheck("shield" + handle) && isTempest)
         {
             var spell = hero.Spellbook.Spell2;
             if (spell != null && spell.CanBeCasted())
             {
                 spell.UseAbility(Prediction.InFront(hero, 100));
                 Utils.Sleep(1500, "shield" + handle);
             }
             else if (!hero.IsAttacking())
             {
                 hero.Attack(nearestTower);
             }
             Utils.Sleep(1000, "Tempest.Attack.Tower.Cd" + handle);
         }
         else if (Utils.SleepCheck("Tempest.Attack.Cd" + handle) && !hero.IsAttacking())
         {
             hero.Attack(pos);
             Utils.Sleep(1000, "Tempest.Attack.Cd" + handle);
         }
         if (enemyCreeps.Any(x => x.Distance2D(hero) <= 800) && isTempest)
         {
             foreach (var item in autoPushItems)
             {
                 if (item.Name != "item_mjollnir")
                 {
                     item.UseAbility();
                 }
                 else
                 {
                     var necros =
                         Objects.Necronomicon.GetNecronomicons(hero)
                             .FirstOrDefault(x => x.Distance2D(hero) <= 500 && x.Name.Contains("warrior"));
                     if (necros != null) item.UseAbility(necros);
                 }
                 Utils.Sleep(350, "Tempest.AutoPush.Cd" + handle + item.Name);
             }
         }
     }
 }
开发者ID:Romikus33,项目名称:EnsageSharp,代码行数:88,代码来源:Program.cs

示例11: SkillShotXYZ

 public static Vector3 SkillShotXYZ(Unit source, Unit target, float delay, float speed, float radius)
 {
     var data =
         TrackTable.FirstOrDefault(
             unitData => unitData.UnitName == target.Name || unitData.UnitClassID == target.ClassID);
     if (IsIdle(target) || data == null)
     {
         return target.Position;
     }
     var predict = PredictedXYZ(target, delay);
     var sourcePos = source.Position;
     var reachTime = CalculateReachTime(target, speed, predict - sourcePos);
     predict = PredictedXYZ(target, delay + reachTime);
     if (!(source.Distance2D(target) > radius)) return PredictedXYZ(target, delay + reachTime);
     sourcePos = (sourcePos - predict)*(sourcePos.Distance2D(predict) - radius - 100)/
                 sourcePos.Distance2D(predict) + predict;
     reachTime = CalculateReachTime(target, speed, predict - sourcePos);
     return PredictedXYZ(target, delay + reachTime);
 }
开发者ID:Esk0r,项目名称:Ensage.Common,代码行数:19,代码来源:Prediction.cs

示例12: DoShit

        /**
        * DoShit takes in a unit and makes the unit do pushing related actions:
        * 1) boots of travel to creep furthest away from unit
        * 2) push the current lane
        * 3) attack tower with shield if nearby
        * 4) attack creeps if nearby
        * 5) if enemy creeps are nearby, use mjollnir and necronomicon
        * args hero: unit to control
        * args isTempest: passed to easily distinguish between clone unit and other units
        **/
        private static void DoShit(Unit hero, bool isTempest=false)
        {
            if (!hero.IsAlive)
                return;
            // setting variables
            var handle = hero.Handle;
            var items = isTempest ? hero.Inventory.Items.ToList() : null;
            var travelBoots = isTempest?
                items.FirstOrDefault(
                    x =>
                        (x.Name == "item_travel_boots" ||
                         x.Name == "item_travel_boots_2") && x.CanBeCasted() &&
                        Utils.SleepCheck("Tempest.Travels.Cd" + handle)) : null;
            var autoPushItems =isTempest ?
                items.Where(
                    x =>
                        AutoPushItems.Contains(x.Name) && x.CanBeCasted() &&
                        Utils.SleepCheck("Tempest.AutoPush.Cd" + handle + x.Name)) : null;
            var myCreeps = Objects.LaneCreeps.GetCreeps().Where(x => x.Team == hero.Team).ToList();
            var enemyCreeps = Objects.LaneCreeps.GetCreeps().Where(x => x.Team != hero.Team).ToList();
            var creepWithEnemy =
                myCreeps.FirstOrDefault(
                    x => x.MaximumHealth * 65 / 100 < x.Health && enemyCreeps.Any(y => y.Distance2D(x) <= 1000));
            var isChannel = isTempest && hero.IsChanneling();

            // code for using boots of travel
            // note: chooses creep furthest away from unit to TP to
            if (travelBoots != null && !enemyCreeps.Any(x => x.Distance2D(hero) <= 1000) && !isChannel && Menu.Item("AutoPush.Travels").GetValue<bool>())
            {
                var mod = hero.FindModifier("modifier_kill");
                if (mod == null || mod.RemainingTime >= 10)
                {
                    if (creepWithEnemy == null)
                    {
                        creepWithEnemy = myCreeps.OrderByDescending(x => x.Distance2D(hero)).FirstOrDefault();
                    }
                    if (creepWithEnemy != null)
                    {
                        travelBoots.UseAbility(creepWithEnemy);
                        Utils.Sleep(500, "Tempest.Travels.Cd" + handle);
                        return;
                    }
                }
            }
            if (isChannel) return;

            var nearestTower =
                Objects.Towers.GetTowers()
                    .Where(x => x.Team == hero.GetEnemyTeam())
                    .OrderBy(y => y.Distance2D(hero))
                    .FirstOrDefault() ?? Objects.Fountains.GetEnemyFountain();
            var fountain = Objects.Fountains.GetAllyFountain();
            var curlane = GetCurrentLane(hero);
            var clospoint = GetClosestPoint(curlane);
            var useThisShit = clospoint.Distance2D(fountain) - 250 > hero.Distance2D(fountain);
            // useThisShit will return true if unit is closer to the fountain than the clospoint

            if (nearestTower != null)
            {
                var pos = (curlane == "mid" || !useThisShit) ? nearestTower.Position : clospoint;
                // if unit is at mid or clospoint is closer than the unit to the fountain, push the nearest tower
                // otherwise, push the closest point

                // if unit is a tempest and is close to the tower, use shield and attack tower
                if (nearestTower.Distance2D(hero) <= 900 && isTempest)
                {
                    if (Utils.SleepCheck("Tempest.Attack.Tower.Cd" + handle))
                    {
                        var spell = hero.Spellbook.Spell2;
                        if (spell != null && IsAbilityEnable(spell.StoredName(), calcForPushing: true) &&
                            spell.CanBeCasted() && Utils.SleepCheck("shield" + handle))
                            // handle used to uniquely identify the current hero's cooldowns
                        {
                            spell.UseAbility(Prediction.InFront(hero, 100));
                            Utils.Sleep(1500, "shield" + handle);
                        }
                        else if (!hero.IsAttacking())
                        {
                            hero.Attack(nearestTower);
                        }
                        Utils.Sleep(1000, "Tempest.Attack.Tower.Cd" + handle);
                    }
                }
                // make the unit issue an attack command at the position pos
                else if (Utils.SleepCheck("Tempest.Attack.Cd" + handle) && !hero.IsAttacking() && isTempest)
                {
                    hero.Attack(pos);
                    Utils.Sleep(1000, "Tempest.Attack.Cd" + handle);
                }
                // smart attack for necrobook (unaggro under tower)
//.........这里部分代码省略.........
开发者ID:JumpAttacker,项目名称:EnsageSharp,代码行数:101,代码来源:Core.cs

示例13: SmartAttack

 private static void SmartAttack(Unit me, List<Unit> myCreeps, Unit nearestTower, Vector3 pos)
 {
     var name = me.StoredName();
     if (Menu.Item("AutoPush.UnAggro.Enable").GetValue<bool>() &&
         myCreeps.Any(x => x.Distance2D(nearestTower) <= 800) && me.Distance2D(nearestTower) <= 1000)
     {
         var hpwasChanged = CheckForChangedHealth(me);
         if (hpwasChanged)
         {
             var allyCreep = myCreeps.OrderBy(x => x.Distance2D(me)).First();
             if (allyCreep != null)
             {
                 var towerPos = nearestTower.Position;
                 var ang = allyCreep.FindAngleBetween(towerPos, true);
                 var p = new Vector3((float) (allyCreep.Position.X - 250*Math.Cos(ang)),
                     (float) (allyCreep.Position.Y - 250*Math.Sin(ang)), 0);
                 me.Move(p);
                 me.Attack(allyCreep, true);
                 Utils.Sleep(1200, name + "attack");
             }
             else
             {
                 var towerPos = nearestTower.Position;
                 var ang = me.FindAngleBetween(towerPos, true);
                 var p = new Vector3((float) (me.Position.X - 1000*Math.Cos(ang)),
                     (float) (me.Position.Y - 1000*Math.Sin(ang)), 0);
                 me.Move(p);
                 Utils.Sleep(500, name + "attack");
             }
         }
         else
         {
             me.Attack(pos);
             Utils.Sleep(500, name + "attack");
         }
     }
     else
     {
         me.Attack(pos);
         Utils.Sleep(500, name + "attack");
     }
 }
开发者ID:JumpAttacker,项目名称:EnsageSharp,代码行数:42,代码来源:Core.cs

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

示例15: CalculateHitTime

        private double CalculateHitTime(Unit unit, Ability ability, float gameTime, float adjustCastPoint = 1)
        {
            var abilityEndPosition = unit.InFront(ability.GetCastRange() + 150);

            var unitAbilityEnd = unit.Distance2D(abilityEndPosition);
            var unitTarget = unit.Distance2D(xMark.Position);
            var targetAbilityEnd = xMark.Position.Distance2D(abilityEndPosition);

            if (Math.Abs(unitTarget + targetAbilityEnd - unitAbilityEnd) < 10)
            {
                return gameTime + ability.FindCastPoint() * adjustCastPoint
                       + (unitTarget - ability.GetRadius()) / ability.GetProjectileSpeed();
            }

            return 0;
        }
开发者ID:IdcNoob,项目名称:Ensage,代码行数:16,代码来源:Kunkka.cs


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