当前位置: 首页>>代码示例>>C#>>正文


C# ICamera.GetSceneTranslationVector方法代码示例

本文整理汇总了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;
        }
开发者ID:plaurin,项目名称:MonoGameEngine2D,代码行数:15,代码来源:RectangleElement.cs

示例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;
        }
开发者ID:plaurin,项目名称:MonoGameEngine2D,代码行数:36,代码来源:HexLayer.cs

示例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;
        }
开发者ID:plaurin,项目名称:MonoGameEngine2D,代码行数:20,代码来源:TileLayer.cs

示例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;
        }
开发者ID:plaurin,项目名称:MonoGameEngine2D,代码行数:16,代码来源:SpriteSheet.cs


注:本文中的ICamera.GetSceneTranslationVector方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。