本文整理匯總了C#中WCell.RealmServer.Entities.Unit.IsImmune方法的典型用法代碼示例。如果您正苦於以下問題:C# Unit.IsImmune方法的具體用法?C# Unit.IsImmune怎麽用?C# Unit.IsImmune使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WCell.RealmServer.Entities.Unit
的用法示例。
在下文中一共展示了Unit.IsImmune方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CheckImmune
/// <summary>
/// Returns whether the spell can be casted (true) or if immunity of the target prevents it (false)
/// </summary>
public static bool CheckImmune(Unit target, Spell spell, bool hostile)
{
if (spell.Mechanic != SpellMechanic.None &&
hostile == spell.Mechanic.IsNegative() &&
((spell.Mechanic == SpellMechanic.Invulnerable_2 || spell.Mechanic == SpellMechanic.Invulnerable) &&
!spell.Attributes.HasFlag(SpellAttributes.UnaffectedByInvulnerability) &&
(target.IsImmune(SpellMechanic.Invulnerable_2) || target.IsImmune(SpellMechanic.Invulnerable))) ||
(target.IsImmune(spell.Mechanic) || target.IsImmune(spell.DispelType)))
{
return false;
}
return true;
}
示例2: IsImmune
/// <summary>
/// Returns whether the given target is immune to the given spell
/// </summary>
public static bool IsImmune(Unit target, Spell spell, bool hostile)
{
if (
hostile &&
spell.Mechanic.IsNegative() &&
!spell.Attributes.HasFlag(SpellAttributes.UnaffectedByInvulnerability) &&
(spell.Mechanic == SpellMechanic.Invulnerable_2 || spell.Mechanic == SpellMechanic.Invulnerable) &&
(
// immune against spell
target.IsInvulnerable ||
target.IsImmune(SpellMechanic.Invulnerable_2) ||
target.IsImmune(SpellMechanic.Invulnerable) ||
target.IsImmune(spell.Mechanic) ||
target.IsImmune(spell.DispelType)
)
)
{
return true;
}
return false;
}
示例3: CheckCastHit
/// <summary>
/// Indicates whether a spell hit a target or not
/// </summary>
public CastMissReason CheckCastHit(Unit target, Spell spell)
{
if (Caster.MayAttack(target))
{
if (target.IsEvading)
{
return CastMissReason.Evade;
}
if (!spell.Attributes.Has(SpellAttributes.UnaffectedByInvulnerability) ||
(target is Character && ((Character)target).Role.IsStaff))
{
if (target.IsInvulnerable)
{
return CastMissReason.Immune_2;
}
var immune = true;
for (var i = 0; i < spell.Schools.Length; i++)
{
var school = spell.Schools[i];
if (!target.IsImmune(school))
{
immune = false;
break;
}
}
if (immune)
{
return CastMissReason.Immune;
}
}
if (target.CheckResist(CasterUnit, target.GetLeastResistant(spell), spell.Mechanic) && !spell.AttributesExB.Has(SpellAttributesExB.CannotBeResisted))
{
return CastMissReason.Resist;
}
}
return CastMissReason.None;
}