本文整理汇总了C#中Unit.Is方法的典型用法代码示例。如果您正苦于以下问题:C# Unit.Is方法的具体用法?C# Unit.Is怎么用?C# Unit.Is使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Unit
的用法示例。
在下文中一共展示了Unit.Is方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Combat
public Combat(Unit attack, Unit defend)
{
Attack = attack;
Defend = defend;
var attackBonus = attack.StrengthBonus();
var defendBonusBase = defend.StrengthBonus();
var attackExtra = attack.BonusAgainst(defend, true);
var defendExtra = defend.BonusAgainst(attack, false);
if (!defend.Is<IgnoreFirstStrike>())
AttackFirstStrikes = attack.FirstStrikes();
if (!attack.Is<IgnoreFirstStrike>())
DefendFirstStrikes = defend.FirstStrikes();
var defendBonus = defendBonusBase + defendExtra - attackExtra;
AttackStrength = attack.Strength * (100 + attackBonus);
if (defendBonus >= 0)
DefendStrength = defend.Strength * (100 + defendBonus);
else
DefendStrength = defend.Strength * 10000 / (100 - defendBonus);
}
示例2: BonusAgainst
public override int BonusAgainst(Unit opponent, bool attacking)
{
return (attacking == true && opponent.Is<City>() ? _bonus : 0) + base.BonusAgainst(opponent, attacking);
}
示例3: BonusAgainst
public override int BonusAgainst(Unit opponent, bool attacking)
{
return (opponent.Is<MeleeUnit>() ? _bonus : 0) + base.BonusAgainst(opponent, attacking);
}