本文整理汇总了C#中Rectangle.Intercept方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.Intercept方法的具体用法?C# Rectangle.Intercept怎么用?C# Rectangle.Intercept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rectangle
的用法示例。
在下文中一共展示了Rectangle.Intercept方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetHit
public HitBase GetHit(Vector position, ICamera camera, WorldTransform worldTransform)
{
var rectangle =
new Rectangle(
worldTransform.Offset.X + this.x,
worldTransform.Offset.Y + this.y,
this.width,
this.height)
.Scale(camera.ZoomFactor)
.Translate(camera.GetSceneTranslationVector(worldTransform.ParallaxScrollingVector));
return rectangle.Intercept(position)
? new RectangleHit(this)
: null;
}
示例2: GetHit
public HitBase GetHit(Vector position, ICamera camera, WorldTransform worldTransform)
{
for (var i = 0; i < this.MapSize.Width; i++)
for (var j = 0; j < this.MapSize.Height; j++)
{
var tileRectangle =
new Rectangle(
this.Offset.X + i * this.TileSize.Width,
this.Offset.Y + j * this.TileSize.Height,
this.TileSize.Width,
this.TileSize.Height)
.Scale(camera.ZoomFactor)
.Translate(camera.GetSceneTranslationVector(this.ParallaxScrollingVector));
if (tileRectangle.Intercept(position))
return new TileHit(new Point(i, j));
}
return null;
}
示例3: GetHit
public HitBase GetHit(Vector position, ICamera camera, WorldTransform worldTransform, Sprite sprite)
{
var source = this.definitions[sprite.SpriteName];
var spriteRectangle =
new Rectangle(
worldTransform.Offset.X + sprite.Position.X,
worldTransform.Offset.X + sprite.Position.Y,
source.Rectangle.Width,
source.Rectangle.Height)
.Scale(camera.ZoomFactor)
.Translate(camera.GetSceneTranslationVector(worldTransform.ParallaxScrollingVector));
return spriteRectangle.Intercept(position)
? new SpriteHit(sprite)
: null;
}