本文整理匯總了C#中Service.List.Count方法的典型用法代碼示例。如果您正苦於以下問題:C# List.Count方法的具體用法?C# List.Count怎麽用?C# List.Count使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Service.List
的用法示例。
在下文中一共展示了List.Count方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: AutoSpells
private void AutoSpells()
{
enemies = ObjectManager.GetEntities<Hero>()
.Where(x => x.IsVisible && x.IsAlive && x.Team != me.Team && !x.IsMagicImmune() && !x.IsIllusion).ToList();
if (Menu.Item("autoUlt").IsActive())
{
e = Toolset.ClosestToMouse(me, 9000);
foreach (var v in enemies.Where(x => !x.IsMagicImmune()))
{
damage[v.Handle] = GetDamageTaken(v, ref enemies);
if (me.IsInvisible()) return;
if (
enemies.Count(
x => x.Health <= damage[v.Handle] && v.Distance2D(x) <= R.GetCastRange() + me.HullRadius + 24) >=
Menu.Item("Heel").GetValue<Slider>().Value)
{
uint elsecount = 0; elsecount += 1;
if (blink != null
&& me.CanCast()
&& blink.CanBeCasted()
&& me.Distance2D(v) > 100
&& me.Distance2D(v) <= 1180
&& Utils.SleepCheck("blink")
)
{
blink.UseAbility(v.Position);
Utils.Sleep(250, "blink");
}
else if (W != null && W.CanBeCasted() && me.Distance2D(v) <= 900 + me.HullRadius + 24 && me.AghanimState()
&& Menu.Item("AutoSpells").GetValue<AbilityToggler>().IsEnabled(W.Name)
&& (blink == null || !blink.CanBeCasted())
&& Utils.SleepCheck("W"))
{
W.UseAbility(v.Position);
Utils.Sleep(250, "W");
}
else elsecount += 1;
if (enemies.Count(
x => me.Distance2D(x) <= R.GetCastRange() + me.HullRadius + 24) >=
Menu.Item("Heel").GetValue<Slider>().Value)
{
if (vail != null
&& vail.CanBeCasted()
&& me.CanCast()
&& Menu.Item("AutoItems").GetValue<AbilityToggler>().IsEnabled(vail.Name)
&& me.Distance2D(v) <= 1190
&& Utils.SleepCheck("vail")
)
{
vail.UseAbility(v.Position);
Utils.Sleep(250, "vail");
} // orchid Item endelse
else elsecount += 1;
if (elsecount == 3 &&
ethereal != null
&& ethereal.CanBeCasted()
&& me.CanCast()
&& Menu.Item("AutoItems").GetValue<AbilityToggler>().IsEnabled(ethereal.Name)
&& (v.Handle == e.Handle || e.Distance2D(v) > 700)
&& me.Distance2D(v) <= 1190
&& Utils.SleepCheck("ethereal")
)
{
ethereal.UseAbility(v);
Utils.Sleep(250, "ethereal");
} // orchid Item end
else elsecount += 1;
if (!CanIncreaseMagicDmg(me, v))
{
if (elsecount == 4 && R != null && R.CanBeCasted() && Utils.SleepCheck("R")
&& Menu.Item("AutoSpells").GetValue<AbilityToggler>().IsEnabled(R.Name))
{
R.UseAbility();
Utils.Sleep(250, "R");
}
if (R == null || !R.CanBeCasted() ||
!Menu.Item("AutoSpells").GetValue<AbilityToggler>().IsEnabled(R.Name))
{
if (Q != null && Q.CanBeCasted() && v.Distance2D(me) <= 525 + me.HullRadius + 24
&& Menu.Item("AutoSpells").GetValue<AbilityToggler>().IsEnabled(Q.Name)
&& Utils.SleepCheck("Q"))
{
Q.UseAbility(v.Position);
Utils.Sleep(250, "Q");
}
if (shiva != null
&& shiva.CanBeCasted()
&& Menu.Item("AutoItems").GetValue<AbilityToggler>().IsEnabled(shiva.Name)
&& v.Distance2D(me) <= shiva.GetCastRange()
&& Utils.SleepCheck("shiva"))
{
shiva.UseAbility();
Utils.Sleep(250, "shiva");
}
}
//.........這裏部分代碼省略.........
示例2: GetDamageTaken
// При передаче по значению метод получает не саму переменную, а ее копию.
// А при передаче параметра по ссылке (ref) метод получает адрес переменной в памяти, что в свою очередь экономит память.
private double GetDamageTaken(Hero victim, ref List<Hero> enemies)
{
double dmgResult = 0;
List<Unit> creeps = ObjectManager.GetEntities<Unit>().Where(x =>
(x.ClassID == ClassID.CDOTA_BaseNPC_Creep_Lane
|| x.ClassID == ClassID.CDOTA_BaseNPC_Creep_Siege
|| x.ClassID == ClassID.CDOTA_BaseNPC_Creep_Neutral
|| x.ClassID == ClassID.CDOTA_Unit_Broodmother_Spiderling
|| x.ClassID == ClassID.CDOTA_Unit_SpiritBear
|| x.ClassID == ClassID.CDOTA_BaseNPC_Invoker_Forged_Spirit
|| x.ClassID == ClassID.CDOTA_BaseNPC_Warlock_Golem
|| x.ClassID == ClassID.CDOTA_BaseNPC_Creep
|| x.HasInventory) && !x.IsMagicImmune() &&
x.IsAlive && x.Team != me.Team && x.IsVisible && victim.Distance2D(x) <= R.GetCastRange() + me.HullRadius + 24 &&
x.IsSpawned && x.IsValidTarget()).ToList();
int creepsECount = creeps.Count;
dmgResult = R != null && Menu.Item("AutoSpells").GetValue<AbilityToggler>().IsEnabled(R.Name) &&
R.CanBeCasted() && enemies.Count(
x => victim.Distance2D(x) <= R.GetCastRange() + me.HullRadius + 24) >=
Menu.Item("Heel").GetValue<Slider>().Value ? ((creepsECount * creepsDmg[R.Level]) + rDmg[R.Level]) + eDmg[E.Level] : 0;
if (victim.NetworkName == "CDOTA_Unit_Hero_Spectre" && victim.Spellbook.Spell3.Level > 0)
{
dmgResult = R != null && Menu.Item("AutoSpells").GetValue<AbilityToggler>().IsEnabled(R.Name) &&
R.CanBeCasted() && enemies.Count(
x => victim.Distance2D(x) <= R.GetCastRange() + me.HullRadius + 24) >=
Menu.Item("Heel").GetValue<Slider>().Value ? ((creepsECount * creepsDmg[R.Level]) + rDmg[R.Level]) + eDmg[E.Level] *
(1 - (0.10 + victim.Spellbook.Spell3.Level * 0.04)) : 0;
if (me.Distance2D(victim) < 300 + me.HullRadius)
dmgResult += eDmg[E.Level] * (1 - (0.10 + victim.Spellbook.Spell3.Level * 0.04));
}
if (Q != null && Menu.Item("AutoSpells").GetValue<AbilityToggler>().IsEnabled(Q.Name) && Q.CanBeCasted())
{
dmgResult += qDmg[Q.Level];
if (enemies.Count(x => x.Distance2D(victim) <= 300 + me.HullRadius && !Equals(x)) > 1)
dmgResult += eDmg[E.Level];
}
if (W != null && W.CanBeCasted() && Menu.Item("AutoSpells").GetValue<AbilityToggler>().IsEnabled(W.Name))
{
if (enemies.Count(x => x.Distance2D(victim) <= 300 + me.HullRadius && !Equals(x)) > 1)
dmgResult += eDmg[E.Level];
}
if (victim.NetworkName == "CDOTA_Unit_Hero_SkeletonKing" && victim.Spellbook.SpellR.CanBeCasted())
dmgResult = 0;
if (victim.HasModifier("modifier_kunkka_ghost_ship_damage_absorb"))
dmgResult *= 0.5;
if (victim.HasModifier("modifier_bloodseeker_bloodrage"))
{
var blood = ObjectManager.GetEntities<Hero>()
.FirstOrDefault(x => x.ClassID == ClassID.CDOTA_Unit_Hero_Bloodseeker);
if (blood != null)
dmgResult *= bloodrage[blood.Spellbook.Spell1.Level];
else
dmgResult *= 1.4;
}
if (victim.HasModifier("modifier_chen_penitence"))
{
var chen =
ObjectManager.GetEntities<Hero>()
.FirstOrDefault(x => x.Team == me.Team && x.ClassID == ClassID.CDOTA_Unit_Hero_Chen);
if (chen != null)
dmgResult *= penitence[chen.Spellbook.Spell1.Level];
}
if (victim.HasModifier("modifier_shadow_demon_soul_catcher"))
{
var demon = ObjectManager.GetEntities<Hero>()
.FirstOrDefault(x => x.Team == me.Team && x.ClassID == ClassID.CDOTA_Unit_Hero_Shadow_Demon);
if (demon != null)
dmgResult *= souls[demon.Spellbook.Spell2.Level];
}
if (victim.HasModifier("modifier_item_mask_of_madness_berserk"))
dmgResult *= 1.3;
vail = me.FindItem("item_veil_of_discord");
if (vail != null && vail.CanBeCasted() && !victim.HasModifier("modifier_item_veil_of_discord_debuff")
&& Menu.Item("AutoItems").GetValue<AbilityToggler>().IsEnabled(vail.Name))
{
dmgResult *= 1.25;
}
var spellamplymult = 1 + (me.TotalIntelligence / 16 / 100);
dmgResult = dmgResult * spellamplymult;
shiva = me.FindItem("item_shivas_guard");
if (shiva != null && shiva.CanBeCasted() && Menu.Item("AutoItems").GetValue<AbilityToggler>().IsEnabled(shiva.Name))
dmgResult += 200;
//.........這裏部分代碼省略.........
示例3: AutoSpells
private void AutoSpells()
{
enemies = ObjectManager.GetEntities<Hero>()
.Where(x => x.IsVisible && x.IsAlive && x.Team != me.Team && !x.IsMagicImmune() && !x.IsMagicImmune() && !x.IsIllusion && !x.IsFullMagicSpellResist()).ToList();
if (Menu.Item("AutoUsage").IsActive())
{
e = Toolset.ClosestToMouse(me,8000);
foreach (var v in enemies)
{
if (me.IsInvisible()) return;
if(v.IsFullMagiclResistZuus()) return;
damage[v.Handle] = CalculateDamage(v);
var Range = me.HullRadius + (dagon == null ? W?.GetCastRange() : dagon.GetCastRange());
float angle = me.FindAngleBetween(v.Position, true);
Vector3 pos = new Vector3((float)(v.Position.X - 290 * Math.Cos(angle)), (float)(v.Position.Y - 290 * Math.Sin(angle)), 0);
Vector3 posBlink = new Vector3((float)(v.Position.X - Range * Math.Cos(angle)), (float)(v.Position.Y - Range * Math.Sin(angle)), 0);
var Units = ObjectManager.GetEntities<Hero>().Where(x =>
!x.Equals(v)
&& x.IsAlive
&& x.Distance2D(pos) < v.Distance2D(pos)
&& x.Distance2D(v) <= 320
&& x.Team != me.Team
).ToList();
if (enemies.Count(
x => x.Distance2D(v) <= 500) <= Menu.Item("Heelm").GetValue<Slider>().Value
&& blink != null
&& blink.CanBeCasted()
&& me.CanCast()
&& me.Health >= (me.MaximumHealth / 100 * Menu.Item("minHealth").GetValue<Slider>().Value)
&& v.Health <= damage[v.Handle]
&& me.Distance2D(posBlink) <= 1180
&& Menu.Item("AutoItems").GetValue<AbilityToggler>().IsEnabled(blink.Name)
&& me.Distance2D(v) > 500
&& Utils.SleepCheck("blink")
)
{
blink.UseAbility(posBlink);
Utils.Sleep(250, "blink");
}
if (v.Health <= damage[v.Handle] && me.Distance2D(v) <= W.GetCastRange() + me.HullRadius + 300)
{
if (vail != null
&& vail.CanBeCasted()
&& me.CanCast()
&& Menu.Item("AutoItems").GetValue<AbilityToggler>().IsEnabled(vail.Name)
&& Utils.SleepCheck("vail")
)
{
vail.UseAbility(v.Position);
Utils.Sleep(250, "vail");
} // orchid Item endelse
else if (ethereal != null
&& ethereal.CanBeCasted()
&& me.CanCast()
&& Menu.Item("AutoItems").GetValue<AbilityToggler>().IsEnabled(ethereal.Name)
&& Utils.SleepCheck("ethereal")
)
{
ethereal.UseAbility(v);
Utils.Sleep(250, "ethereal");
} // orchid Item end
if (!CanIncreaseMagicDmg(me, v))
{
if (dagon != null
&& dagon.CanBeCasted()
&& Menu.Item("AutoItems").GetValue<AbilityToggler>().IsEnabled("item_dagon")
&& Utils.SleepCheck("dagon"))
{
dagon.UseAbility(v);
Utils.Sleep(250, "dagon");
}
else if(Q != null && Q.CanBeCasted() && Menu.Item("AutoSpells").GetValue<AbilityToggler>().IsEnabled(Q.Name)
&& Utils.SleepCheck("Q"))
{
Q.UseAbility(v);
Utils.Sleep(250, "Q");
}
else if (W != null && W.CanBeCasted() && me.Distance2D(v) <= W.GetCastRange() + me.HullRadius && Menu.Item("AutoSpells").GetValue<AbilityToggler>().IsEnabled(W.Name)
&& Utils.SleepCheck("W"))
{
W.UseAbility(v.Position);
Utils.Sleep(250, "W");
}
else if (W != null && W.CanBeCasted() && Units.Count(x => x.Distance2D(pos) <= 300) == 0 && me.Distance2D(v) <= W.GetCastRange() + me.HullRadius + 300 && Menu.Item("AutoSpells").GetValue<AbilityToggler>().IsEnabled(W.Name)
&& Utils.SleepCheck("W"))
{
W.UseAbility(pos);
Utils.Sleep(250, "W");
}
else if (R != null
&& R.CanBeCasted()
&& (W == null || !W.CanBeCasted() || !Menu.Item("AutoSpells").GetValue<AbilityToggler>().IsEnabled(W.Name))
&& Menu.Item("AutoSpells").GetValue<AbilityToggler>().IsEnabled(R.Name)
&& Utils.SleepCheck("R"))
{
//.........這裏部分代碼省略.........