本文整理汇总了C#中ICamera.GetSceneTranslationVector方法的典型用法代码示例。如果您正苦于以下问题:C# ICamera.GetSceneTranslationVector方法的具体用法?C# ICamera.GetSceneTranslationVector怎么用?C# ICamera.GetSceneTranslationVector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICamera
的用法示例。
在下文中一共展示了ICamera.GetSceneTranslationVector方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 hexDistance = this.HexSize.Width - (this.HexSize.Width - this.TopEdgeLength) / 2;
var halfHeight = this.HexSize.Height / 2;
var rectangle = new Rectangle(
this.Offset.X + i * hexDistance,
this.Offset.Y + j * this.HexSize.Height + (i % 2 == 1 ? halfHeight : 0),
this.HexSize.Width, this.HexSize.Height);
var mapPosition = position
.Translate(-camera.GetSceneTranslationVector(this.ParallaxScrollingVector))
.Scale(1.0f / camera.ZoomFactor);
var x1 = (this.HexSize.Width - this.TopEdgeLength) / 2;
var x2 = x1 + this.TopEdgeLength;
var polygone = new[]
{
new Vector(rectangle.X + x1, rectangle.Y),
new Vector(rectangle.X + x2, rectangle.Y),
new Vector(rectangle.X + this.HexSize.Width, rectangle.Y + halfHeight),
new Vector(rectangle.X + x2, rectangle.Y + this.HexSize.Height),
new Vector(rectangle.X + x1, rectangle.Y + this.HexSize.Height),
new Vector(rectangle.X, rectangle.Y + halfHeight)
};
if (MathUtil.IsHitPolygone(polygone, mapPosition))
return new HexHit(new Point(i, j));
}
return null;
}
示例3: 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;
}
示例4: 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;
}