本文整理汇总了C#中WCell.RealmServer.Entities.Unit.CheckResist方法的典型用法代码示例。如果您正苦于以下问题:C# Unit.CheckResist方法的具体用法?C# Unit.CheckResist怎么用?C# Unit.CheckResist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WCell.RealmServer.Entities.Unit
的用法示例。
在下文中一共展示了Unit.CheckResist方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckCastHit
/// <summary>
/// Indicates whether a spell hit a target or not
/// TODO: Actually check whether a spell 'Misses' (CastMissReason.Miss)
/// </summary>
public CastMissReason CheckCastHit(Unit target, Spell spell)
{
if (CasterObject != null && CasterObject.MayAttack(target))
{
var school = target.GetLeastResistantSchool(spell);
// evasion
if (target.IsEvading)
{
return CastMissReason.Evade;
}
// immune & invul
if (!spell.Attributes.HasFlag(SpellAttributes.UnaffectedByInvulnerability) ||
(target is Character && ((Character)target).Role.IsStaff))
{
if (target.IsInvulnerable)
{
return CastMissReason.Immune_2;
}
if (spell.Schools.All(target.IsImmune))
{
return CastMissReason.Immune;
}
}
//// avoid/miss
//var avoidance = target.GetSpellAvoidancePct(school);
//if (avoidance > 0 && Utility.Random(1, 101) < avoidance)
//{
// return CastMissReason.Miss;
//}
// resist
if (target.CheckResist(CasterUnit, school, spell.Mechanic) && !spell.AttributesExB.HasFlag(SpellAttributesExB.CannotBeResisted))
{
return CastMissReason.Resist;
}
}
return CastMissReason.None;
}
示例2: 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;
}