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


C# Unit.GetEnemyTeam方法代码示例

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


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

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

示例2: CalculateDamage


//.........这里部分代码省略.........
                        source, 
                        name, 
                        data.MagicImmunityPierce, 
                        minusMagicResistancePerc: minusMagicResistancePerc);
                    outgoingDamage = blinkdamage
                                     + target.SpellDamageTaken(
                                         agiMultiplier * hero.TotalAgility + (source.MinimumDamage + source.BonusDamage), 
                                         DamageType.Physical, 
                                         source, 
                                         name, 
                                         data.MagicImmunityPierce, 
                                         minusMagicResistancePerc: minusMagicResistancePerc);
                    break;
                case "undying_soul_rip":
                    var radius = ability.GetAbilityData("radius");
                    var nearUnits = ObjectManager.GetEntities<Unit>();
                    var damagePerUnit = ability.GetAbilityData("damage_per_unit");
                    var maxUnits = ability.GetAbilityData("max_units");
                    outgoingDamage =
                        Math.Min(
                            nearUnits.Count(
                                x =>
                                !x.Equals(source) && !x.Equals(target) && x.Distance2D(source) < radius + x.HullRadius
                                && (x.ClassID == ClassID.CDOTA_BaseNPC_Creep_Lane
                                    || x.ClassID == ClassID.CDOTA_BaseNPC_Creep
                                    || x.ClassID == ClassID.CDOTA_BaseNPC_Creep_Neutral
                                    || x.ClassID == ClassID.CDOTA_BaseNPC_Creep_Siege
                                    || x.ClassID == ClassID.CDOTA_BaseNPC_Creature
                                    || x.ClassID == ClassID.CDOTA_BaseNPC_Invoker_Forged_Spirit
                                    || x.ClassID == ClassID.CDOTA_Unit_Undying_Zombie
                                    || x.ClassID == ClassID.CDOTA_BaseNPC_Warlock_Golem
                                    || (x is Hero
                                        && (x.Team == source.Team
                                            || (x.Team == source.GetEnemyTeam() && !x.IsMagicImmune())))) && x.IsAlive
                                && x.IsVisible), 
                            maxUnits) * damagePerUnit;
                    outgoingDamage = target.SpellDamageTaken(
                        outgoingDamage, 
                        DamageType.Magical, 
                        source, 
                        name, 
                        data.MagicImmunityPierce, 
                        minusMagicResistancePerc: minusMagicResistancePerc);
                    break;
                default:
                    var damageString = data.DamageString;
                    if (damageString == null)
                    {
                        outgoingDamage = ability.GetDamage(level - 1);
                    }
                    else
                    {
                        if (ability.AbilityType.HasFlag(AbilityType.Ultimate) && level > 0 && source.AghanimState())
                        {
                            level -= 1;
                        }

                        if (data.SpellLevel != null)
                        {
                            var spellLevel = source.FindSpell(data.SpellLevel, true);
                            level = spellLevel.Level;
                        }

                        if (source.ClassID == ClassID.CDOTA_Unit_Hero_Invoker && level > 0 && source.AghanimState())
                        {
                            level += 1;
开发者ID:EnsageSharp,项目名称:Ensage.Common,代码行数:67,代码来源:AbilityDamage.cs

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

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

示例5: HighestHealthPointsTarget

 /// <summary>
 ///     The highest health points target.
 /// </summary>
 /// <param name="source">
 ///     The source hero (LocalHero).
 /// </param>
 /// <param name="range">
 ///     The range.
 /// </param>
 /// <returns>
 ///     The <see cref="Hero" />.
 /// </returns>
 public static Hero HighestHealthPointsTarget(Unit source, float range)
 {
     return
         Heroes.GetByTeam(source.GetEnemyTeam())
             .Where(
                 hero =>
                 hero.IsValid && hero.IsAlive && hero.IsVisible && hero.Distance2D(source) <= range
                 && !hero.IsInvul() && !hero.HasModifier("modifier_skeleton_king_reincarnation_scepter_active"))
             .MaxOrDefault(hero => hero.Health);
 }
开发者ID:EnsageSharp,项目名称:Ensage.Common,代码行数:22,代码来源:TargetSelector.cs


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