本文整理汇总了C#中Microsoft.Xna.Framework.Rectangle.TouchAnywhere方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.TouchAnywhere方法的具体用法?C# Rectangle.TouchAnywhere怎么用?C# Rectangle.TouchAnywhere使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Rectangle
的用法示例。
在下文中一共展示了Rectangle.TouchAnywhere方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Collision
public void Collision(Player player)
{
Rectangle bulletCollisionBox;
Santa attacker = player as Santa;
if (attacker == null)
{
return;
}
if (player.CollisionBox.TouchAnywhere(this.CollisionBox))
{
player.Health -= 1;
}
for (int i = 0; i < attacker.BulletFactory.GeneratedBullets.Count; i++)
{
bulletCollisionBox = new Rectangle(attacker.BulletFactory.GeneratedBullets[i].PositionX,
attacker.BulletFactory.GeneratedBullets[i].PositionY,
attacker.BulletFactory.GeneratedBullets[i].ProjectileTexture.Width,
attacker.BulletFactory.GeneratedBullets[i].ProjectileTexture.Height);
if (bulletCollisionBox.TouchAnywhere(this.CollisionBox))
{
this.Health -= (int)player.Damage;
attacker.BulletFactory.GeneratedBullets.Remove(attacker.BulletFactory.GeneratedBullets[i]);
}
}
}
示例2: Collision
public override void Collision(Rectangle newRectangle)
{
base.Collision(newRectangle);
Rectangle bulletCollisionBox;
for(int i = 0; i < this.bulletFactory.GeneratedBullets.Count; i++)
{
bulletCollisionBox = new Rectangle(this.bulletFactory.GeneratedBullets[i].PositionX,
this.bulletFactory.GeneratedBullets[i].PositionY,
this.bulletFactory.GeneratedBullets[i].ProjectileTexture.Width,
this.bulletFactory.GeneratedBullets[i].ProjectileTexture.Height);
if (bulletCollisionBox.TouchAnywhere(newRectangle))
{
this.bulletFactory.GeneratedBullets.Remove(this.bulletFactory.GeneratedBullets[i]);
}
}
}