本文整理匯總了C#中Service.List.Where方法的典型用法代碼示例。如果您正苦於以下問題:C# List.Where方法的具體用法?C# List.Where怎麽用?C# List.Where使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Service.List
的用法示例。
在下文中一共展示了List.Where方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: GetClosestToTarget
public Hero GetClosestToTarget(List<Hero> units, Hero z)
{
Hero closestHero = null;
foreach (var v in units.Where(v => closestHero == null || closestHero.Distance2D(z) > v.Distance2D(z)))
{
closestHero = v;
}
return closestHero;
}
示例3: GetClosestToWeb
private Unit GetClosestToWeb(List<Unit> units, Hero x)
{
Unit closestHero = null;
foreach (var b in units.Where(v => closestHero == null || closestHero.Distance2D(x) > v.Distance2D(x)))
{
closestHero = b;
}
return closestHero;
}
示例4: GetLowestToQ
private Unit GetLowestToQ(List<Hero> units, Unit z)
{
Q = me.Spellbook.SpellQ;
int[] qDmg = { 40, 80, 120, 160 };
int[] creepsDmg = { 14, 16, 18, 20 };
int[] enemyDmg = { 20, 40, 60, 80 };
int enemiesCount;
int creepsECount;
double[] penitence = { 0, 1.15, 1.2, 1.25, 1.3 };
double[] bloodrage = { 0, 1.15, 1.2, 1.25, 1.3 };
double[] soul = { 0, 1.2, 1.3, 1.4, 1.5 };
foreach (var v in units.Where(x => !x.IsMagicImmune()))
{
creepsECount = ObjectManager.GetEntities<Unit>().Where(creep =>
(creep.ClassID == ClassID.CDOTA_BaseNPC_Creep_Lane
|| creep.ClassID == ClassID.CDOTA_BaseNPC_Creep_Siege
|| creep.ClassID == ClassID.CDOTA_BaseNPC_Creep_Neutral
|| creep.ClassID == ClassID.CDOTA_Unit_Broodmother_Spiderling
|| creep.ClassID == ClassID.CDOTA_Unit_SpiritBear
|| creep.ClassID == ClassID.CDOTA_BaseNPC_Invoker_Forged_Spirit
|| creep.ClassID == ClassID.CDOTA_BaseNPC_Warlock_Golem
|| creep.ClassID == ClassID.CDOTA_BaseNPC_Creep) &&
creep.IsAlive && creep.Team != me.Team && creep.IsVisible && v.Distance2D(creep) <= 330 &&
creep.IsSpawned).ToList().Count();
enemiesCount = ObjectManager.GetEntities<Hero>().Where(x =>
x.Team != me.Team && x.IsAlive && x.IsVisible && v.Distance2D(x) <= 330).ToList().Count();
if (enemiesCount == 0)
{
enemiesCount = 0;
}
if (creepsECount == 0)
{
creepsECount = 0;
}
damage = ((creepsECount * creepsDmg[Q.Level - 1] + enemiesCount * enemyDmg[Q.Level - 1]) +
qDmg[Q.Level - 1]) * (1 - v.MagicDamageResist);
if (v.NetworkName == "CDOTA_Unit_Hero_Spectre" && v.Spellbook.Spell3.Level > 0)
{
damage =
Math.Floor((((creepsECount * creepsDmg[Q.Level - 1] + enemiesCount * enemyDmg[Q.Level - 1]) +
qDmg[Q.Level - 1]) *
(1 - (0.10 + v.Spellbook.Spell3.Level * 0.04))) * (1 - v.MagicDamageResist));
}
if (v.NetworkName == "CDOTA_Unit_Hero_Tusk" &&
v.Spellbook.SpellW.CooldownLength - 3 > v.Spellbook.SpellQ.Cooldown)
damage = 0;
var rum = v.HasModifier("modifier_kunkka_ghost_ship_damage_absorb");
if (rum) damage = damage * 0.5;
var mom = v.HasModifier("modifier_item_mask_of_madness_berserk");
if (mom) damage = damage * 1.3;
var spellamplymult = 1 + (me.TotalIntelligence / 16 / 100);
if (v.HasModifier("modifier_bloodseeker_bloodrage"))
{
var blood =
ObjectManager.GetEntities<Hero>()
.FirstOrDefault(x => x.ClassID == ClassID.CDOTA_Unit_Hero_Bloodseeker);
if (blood != null)
damage = damage * bloodrage[blood.Spellbook.Spell1.Level];
else
damage = damage * 1.4;
}
if (v.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)
damage = damage * penitence[chen.Spellbook.Spell1.Level];
}
if (v.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)
damage = damage * soul[demon.Spellbook.Spell2.Level];
}
damage = damage * spellamplymult;
//Console.WriteLine(damage);
if (damage >= v.Health && z.Distance2D(v) <= Q.GetCastRange())
return v;
}
return null;
}
示例5: GetStudentScheduleMin
public List<ScheduleMin> GetStudentScheduleMin(string id, ref List<string> errors)
{
List<ScheduleMin> getMinSchedule = this.repository.GetStudentScheduleMin(id, ref errors);
List<ScheduleMin> convertMinSchedule = new List<ScheduleMin>();
foreach (ScheduleMin sm in getMinSchedule)
{
if (convertMinSchedule.Where(x => x.Quarter == sm.Quarter && x.Year == sm.Year).Count() == 0)
{
convertMinSchedule.Add(sm);
}
}
return convertMinSchedule;
}
示例6: SyncRoles
private void SyncRoles(IList<RoleCheckbox> checkboxes, IList<Role> roles)
{
var selectedRoles = new List<Role>();
foreach (var role in userService.GetRoles())
{
var checkbox = checkboxes.Single(c => c.Id == role.ID);
checkbox.Name = role.Name;
if (checkbox.IsChecked)
selectedRoles.Add(role);
}
foreach (var forAdd in selectedRoles.Where(t => !roles.Contains(t)))
{
roles.Add(forAdd);
}
foreach (var forRemove in roles.Where(t=>!selectedRoles.Contains(t)).ToList())
{
roles.Remove(forRemove);
}
}