本文整理汇总了C#中Unit.IsValidTarget方法的典型用法代码示例。如果您正苦于以下问题:C# Unit.IsValidTarget方法的具体用法?C# Unit.IsValidTarget怎么用?C# Unit.IsValidTarget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Unit
的用法示例。
在下文中一共展示了Unit.IsValidTarget方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Cast
public static void Cast(this Ability ability, Unit unit)
{
if (ability.IsReady() && unit.IsValidTarget(ability.CastRange))
{
ability.UseAbility(unit);
}
}
示例2: CheckTarget
private static bool CheckTarget(Unit enemy, bool doubleOwnage = false)
{
if (enemy.IsIllusion || !enemy.IsValidTarget(dagon.GetCastRange(), true, hero.NetworkPosition))
{
return false;
}
if (enemy.IsLinkensProtected() || enemy.IsMagicImmune())
{
return false;
}
if (!enemy.CanDie() || enemy.Modifiers.Any(x => IgnoreModifiers.Any(x.Name.Equals)))
{
return false;
}
var damage = AbilityDamage.CalculateDamage(dagon, hero, enemy);
if (doubleOwnage)
{
damage *= 2;
}
return enemy.Health < damage;
}
示例3: CheckTarget
private static bool CheckTarget(Unit enemy)
{
if (enemy == null || enemy.IsIllusion || !enemy.IsValidTarget(dagon.GetCastRange(), true, me.NetworkPosition) || enemy.IsLinkensProtected() || enemy.IsMagicImmune() || !enemy.CanDie() || enemy.Modifiers.Any(x => IgnoreModifiers.Any(x.Name.Equals)))
return false;
return enemy.Health <
enemy.SpellDamageTaken(dagon.GetAbilityData("damage"), DamageType.Magical, me, dagon.Name);
}
示例4: CanBeCasted
/// <summary>
/// Checks if given ability can be used
/// </summary>
/// <param name="ability"></param>
/// <param name="target"></param>
/// <returns>returns true in case ability can be used</returns>
public static bool CanBeCasted(this Ability ability, Unit target)
{
if (!target.IsValidTarget())
{
return false;
}
var canBeCasted = ability.CanBeCasted();
if (!target.IsMagicImmune())
{
return canBeCasted;
}
var data = AbilityDatabase.Find(ability.Name);
return data == null ? canBeCasted : data.MagicImmunityPierce;
}
示例5: UseOnTarget
private static bool UseOnTarget(IEnumerable<string> abilitiesNames, Unit target, double castpoint = 5) {
if (!Menu.Item("disable").GetValue<bool>())
return false;
foreach (
var ability in
abilitiesNames.Select(ability => hero.FindItem(ability) ?? hero.FindSpell(ability))
.Where(
ability => ability != null && ability.CanBeCasted() && (ability is Item || hero.CanCast()))) {
if (ability.IsAbilityBehavior(AbilityBehavior.NoTarget)) {
if (ability.GetCastDelay(hero, target, true) <= castpoint &&
target.IsValidTarget(ability.GetCastRange(), false, hero.NetworkPosition) &&
(!target.IsMagicImmune() || IgnoresMagicImmunity.Any(ability.Name.Equals))) {
ability.UseAbility();
} else continue;
} else if (ability.IsAbilityBehavior(AbilityBehavior.UnitTarget)) {
if (ability.GetCastDelay(hero, target, true) <= castpoint &&
target.IsValidTarget(ability.GetCastRange(), false, hero.NetworkPosition) &&
(!target.IsMagicImmune() || IgnoresMagicImmunity.Any(ability.Name.Equals))) {
ability.UseAbility(target);
} else continue;
} else {
if (ability.GetCastDelay(hero, target, true) <= castpoint &&
target.IsValidTarget(ability.GetCastRange(), false, hero.NetworkPosition) &&
(!target.IsMagicImmune() || IgnoresMagicImmunity.Any(ability.Name.Equals))) {
ability.UseAbility(hero.Position);
} else continue;
}
Utils.Sleep(1000, "CounterDelay");
return true;
}
return false;
}
示例6: CanBeCasted
/// <summary>
/// Checks if given ability can be used
/// </summary>
/// <param name="ability">
/// The ability.
/// </param>
/// <param name="target">
/// The target.
/// </param>
/// <returns>
/// returns true in case ability can be used
/// </returns>
public static bool CanBeCasted(this Ability ability, Unit target)
{
if (ability == null || !ability.IsValid)
{
return false;
}
if (target == null || !target.IsValid)
{
return false;
}
if (!target.IsValidTarget())
{
return false;
}
var canBeCasted = ability.CanBeCasted();
if (!target.IsMagicImmune())
{
return canBeCasted;
}
var data = ability.CommonProperties();
return data == null ? canBeCasted : data.MagicImmunityPierce;
}
示例7: CanBeCasted
/// <summary>
/// Checks if given ability can be used
/// </summary>
/// <param name="ability"></param>
/// <param name="target"></param>
/// <returns>returns true in case ability can be used</returns>
public static bool CanBeCasted(this Ability ability, Unit target)
{
if (!target.IsValidTarget())
{
return false;
}
var canBeCasted = ability.CanBeCasted();
if (!target.IsMagicImmune())
{
return canBeCasted;
}
AbilityInfo data;
if (!AbilityDamage.DataDictionary.TryGetValue(ability, out data))
{
data = AbilityDatabase.Find(ability.Name);
AbilityDamage.DataDictionary.Add(ability, data);
}
return data == null ? canBeCasted : data.MagicImmunityPierce;
}
示例8: UseOnTarget
private static bool UseOnTarget(Unit target, double castpoint, params string[][] abilitiesNames) {
if (!Program.Menu.Item("disable").GetValue<bool>())
return false;
var canCast = Program.Hero.CanCast();
var magicImmune = target.IsMagicImmune();
var castDelay = 0d;
var ability =
abilitiesNames.SelectMany(
x =>
x.Select(y => Program.Hero.FindItem(y) ?? Program.Hero.FindSpell(y))
.Where(
y =>
y.CanBeCasted() && (castDelay = y.GetCastDelay(Program.Hero, target)) < castpoint &&
target.IsValidTarget(y.GetCastRange(), false, Program.Hero.NetworkPosition) &&
(!magicImmune || y.PiercesMagicImmunity()) &&
(y is Item || canCast))).FirstOrDefault();
if (ability == null)
return false;
if (ability.IsAbilityBehavior(AbilityBehavior.NoTarget))
ability.UseAbility();
else if (ability.IsAbilityBehavior(AbilityBehavior.UnitTarget))
ability.UseAbility(target);
else
ability.UseAbility(target.NetworkPosition);
Utils.Sleep(castDelay * 1000 + Program.Menu.Item("delay").GetValue<Slider>().Value, "CounterDelay");
return true;
}
示例9: CheckTarget
private static bool CheckTarget(Unit enemy, bool doubleOwnage = false) {
if (enemy.IsIllusion || !enemy.IsValidTarget(dagon.GetCastRange(), true, hero.NetworkPosition))
return false;
if (enemy.IsLinkensProtected() || enemy.IsMagicImmune())
return false;
if (!enemy.CanDie() || enemy.Modifiers.Any(x => IgnoreModifiers.Any(x.Name.Equals)))
return false;
return enemy.Health <
enemy.DamageTaken(DagonDamage[dagon.Level - 1] * (doubleOwnage ? 2 : 1), DamageType.Magical, hero);
}