本文整理汇总了C#中Pair.Count方法的典型用法代码示例。如果您正苦于以下问题:C# Pair.Count方法的具体用法?C# Pair.Count怎么用?C# Pair.Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pair
的用法示例。
在下文中一共展示了Pair.Count方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: onCollision
public override void onCollision(string type, bEntity other, Pair<bBody, bBody>[] collisionPairs)
{
base.onCollision(type, other, collisionPairs);
if (!type.Equals("fists") || actionState == ActionState.punchReturn)
return;
// Pairs are (other, me), always dealing with bodies
bool hitHead = false;
foreach (Pair<bBody, bBody> item in collisionPairs)
{
if (item.second.name.Equals("fists"))
{
(other as Ringo).body.attached["fists"].bodyPart.currentAnim.speed *= -1;
(other as Ringo).actionState = ActionState.punchReturn;
SoundEffect soundEffect;
soundEffect = game.Content.Load<SoundEffect>("fist-fist");
soundEffect.Play();
return;
}
else if (item.second.name.Equals("head"))
{
hitHead = true;
}
}
if (collisionPairs.Count() >= 1 && (other as Ringo).myHit != hisHit)
{
SoundEffect soundEffect;
soundEffect = game.Content.Load<SoundEffect>("fist-body");
soundEffect.Play();
// right punch is shorter but deals more damage
// head hurts the most
int damage = 1;
if (hitHead)
{
body.attached["head"].bodyPart.play("damage");
damage = 3;
headDamaged = true;
}
else
{
if ((other as Ringo).myHit % 2 == 0)
{
// right punch
damage = 1;
}
else
{
// left punch
damage = 2;
}
bodyDamaged = true;
body.play("damage");
}
life = Math.Max(0, life - damage);
if (life == 0)
{
actionState = ActionState.dead;
}
hisHit = (other as Ringo).myHit;
}
}