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


C# FloatRect类代码示例

本文整理汇总了C#中FloatRect的典型用法代码示例。如果您正苦于以下问题:C# FloatRect类的具体用法?C# FloatRect怎么用?C# FloatRect使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FloatRect类属于命名空间,在下文中一共展示了FloatRect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CalculateBoundingBox

        public FloatRect CalculateBoundingBox(float thrusterXScale = 0.3f)
        {
            var sprites = ServiceLocator.Instance.GetService<ISpriteManagerService>().Sprites;
            return Parts.Where(p=>p.SpriteId!=null).Aggregate(new FloatRect(), (box, part) =>
            {
                Sprite spr;
                if (!sprites.TryGetValue(part.SpriteId, out spr)) return box;

                var aabb = new FloatRect(-(spr.OriginX ?? spr.W / 2), -(spr.OriginY ?? spr.H / 2), spr.W, spr.H);

                var topleft = new Vector2(Math.Min(aabb.Left, aabb.Right), Math.Min(aabb.Top, aabb.Bottom));
                var bottomright = new Vector2(Math.Max(aabb.Left, aabb.Right), Math.Max(aabb.Top, aabb.Bottom));

                var matrix = part.Transform.Matrix;
                if (part is Thruster)
                {
                    matrix = Matrix.CreateScale(new Vector3(thrusterXScale, 1, 1)) * matrix;
                }

                Vector2.Transform(ref topleft, ref matrix, out topleft);
                Vector2.Transform(ref bottomright, ref matrix, out topleft);

                return new FloatRect(new Vector2(Math.Min(Math.Min(topleft.X, bottomright.X), box.Left), Math.Min(Math.Min(topleft.Y, bottomright.Y), box.Top)),
                    new Vector2(Math.Max(Math.Abs(topleft.X - bottomright.X), box.Width), Math.Max(Math.Abs(topleft.Y - bottomright.Y), box.Width)));
            });
        }
开发者ID:raycrasher,项目名称:Fell-Sky,代码行数:26,代码来源:ShipModel.cs

示例2: Draw

        public void Draw(Texture2D texture, ref Matrix transform, FloatRect? sourceRectangle = null, Color? color=null, Vector3? normal = null)
        {
            Vertex3CTN vtx;
            vtx.Color = color ?? Color.White;
            vtx.Normal = normal ?? Vector3.Forward;
            FloatRect texRect = sourceRectangle ?? new FloatRect(texture.Bounds);

            Vector2 texCoordLT = texture.GetUV(texRect.Left, texRect.Top);
            Vector2 texCoordBR = texture.GetUV(texRect.Right, texRect.Bottom);

            vtx.Position = Vector3.Zero;
            vtx.TextureCoords = texCoordLT;
            _quadVertices[0] = vtx;
            vtx.Position = new Vector3(0, texRect.Height, 0);
            vtx.TextureCoords = new Vector2(texCoordLT.X, texCoordBR.Y);
            _quadVertices[1] = vtx;
            vtx.Position = new Vector3(texRect.Width, 0, 0);
            vtx.TextureCoords = new Vector2(texCoordBR.X, texCoordLT.Y);
            _quadVertices[2] = vtx;
            vtx.Position = new Vector3(texRect.Width, texRect.Height, 0);
            vtx.TextureCoords = texCoordBR;
            _quadVertices[3] = vtx;

            DrawVertices(texture, _quadVertices, _quadIndices, ref transform);
        }
开发者ID:raycrasher,项目名称:Fell-Sky,代码行数:25,代码来源:FastSpriteBatch.cs

示例3: SetParameter

        /// <summary>
        /// Set parameters :)
        /// </summary>
        /// <param name="parameter"></param>
        public override void SetParameter(ComponentParameter parameter)
        {
            var tileSize = IoCManager.Resolve<IMapManager>().TileSize;

            //base.SetParameter(parameter);
            switch (parameter.MemberName)
            {
                case "SizeX":
                    var width = parameter.GetValue<float>() / tileSize;
                    AABB = new FloatRect(AABB.Left + (AABB.Width - width) / 2f, AABB.Top, width, AABB.Height);
                    break;
                case "SizeY":
                    var height = parameter.GetValue<float>() / tileSize;
                    AABB = new FloatRect(AABB.Left, AABB.Top + (AABB.Height - height) / 2f, AABB.Width, height);
                    break;
                case "OffsetX":
                    var x = parameter.GetValue<float>() / tileSize;
                    AABB = new FloatRect(x - AABB.Width / 2f, AABB.Top, AABB.Width, AABB.Height);
                    break;
                case "OffsetY":
                    var y = parameter.GetValue<float>() / tileSize;
                    AABB = new FloatRect(AABB.Left, y - AABB.Height / 2f, AABB.Width, AABB.Height);
                    break;
            }
        }
开发者ID:MSylvia,项目名称:space-station-14,代码行数:29,代码来源:HitboxComponent.cs

示例4: Draw

        public void Draw(Stopwatch time)
        {
            myApp.window.Clear(myStyle.BackgroundColor);

            if( myStyle.BackgroundImage != null )
            {
                ImagePart part= myStyle.BackgroundImage;
                myUIManager.Painter.Begin();
                if( myStyle.BackgroundDisplayMode == TextureDisplayMode.Stretch )
                    myUIManager.Painter.DrawImage(part.SourceTexture, new FloatRect(0f, 0f, myUIManager.ScreenSize.X, myUIManager.ScreenSize.Y), part.SourceRectangle);
                else
                {
                    // the image must be centered.
                    FloatRect destRect = new FloatRect(
                        0.5f*(myUIManager.ScreenSize.X - myStyle.BackgroundImage.Size.X),
                        0.5f * (myUIManager.ScreenSize.Y - myStyle.BackgroundImage.Size.Y),
                        myStyle.BackgroundImage.Size.X,
                        myStyle.BackgroundImage.Size.Y);
                    myUIManager.Painter.DrawImage(part.SourceTexture, destRect, part.SourceRectangle);
                }

                myUIManager.Painter.End();
            }

            myUIManager.Render();
        }
开发者ID:Ziple,项目名称:NOubliezPas,代码行数:26,代码来源:ThemeSelectionMenu.cs

示例5: Update

        public override bool Update(Vector2i mouseS, IMapManager currentMap)
        {
            if (currentMap == null) return false;

            spriteToDraw = GetDirectionalSprite(pManager.CurrentBaseSpriteKey);

            mouseScreen = mouseS;
            mouseWorld = CluwneLib.ScreenToWorld(mouseScreen);

            var bounds = spriteToDraw.GetLocalBounds();
            var spriteSize = CluwneLib.PixelToTile(new Vector2f(bounds.Width, bounds.Height));
            var spriteRectWorld = new FloatRect(mouseWorld.X - (spriteSize.X / 2f),
                                                 mouseWorld.Y - (spriteSize.Y / 2f),
                                                 spriteSize.X, spriteSize.Y);

            if (pManager.CurrentPermission.IsTile)
                return false;

            if (pManager.CollisionManager.IsColliding(spriteRectWorld))
                return false;

            //if (currentMap.IsSolidTile(mouseWorld)) return false;

            var rangeSquared = pManager.CurrentPermission.Range * pManager.CurrentPermission.Range;
            if (rangeSquared > 0)
                if (
                    (pManager.PlayerManager.ControlledEntity.GetComponent<TransformComponent>(ComponentFamily.Transform)
                         .Position - mouseWorld).LengthSquared() > rangeSquared) return false;

            currentTile = currentMap.GetTileRef(mouseWorld);

            return true;
        }
开发者ID:MSylvia,项目名称:space-station-14,代码行数:33,代码来源:AlignNone.cs

示例6: DrawRectangle

 public static void DrawRectangle(FloatRect rect, Color color) => drawInfos.Add(new DebugDrawInfo(new[]
 {
     new Vertex(new Vector2f(rect.Left, rect.Top), color),
     new Vertex(new Vector2f(rect.Left + rect.Width, rect.Top), color),
     new Vertex(new Vector2f(rect.Left + rect.Width, rect.Top + rect.Height), color),
     new Vertex(new Vector2f(rect.Left, rect.Top + rect.Height), color),
     new Vertex(new Vector2f(rect.Left, rect.Top), color)
 }, PrimitiveType.LinesStrip));
开发者ID:Spanfile,项目名称:LD33,代码行数:8,代码来源:Debug.cs

示例7: Backdrop

        /// <summary>
        /// The FloatRects are relative to inside that Texture sent in
        /// </summary>
        public Backdrop(String[] bgText, FloatRect startSquare, FloatRect finalSquare)
        {
            backgroundString = bgText[0];
            waterString = bgText[1];

            topProps = new List<PropSprite>();
            lowProps = new List<PropSprite>();
        }
开发者ID:nik0kin,项目名称:ProjectTurtle,代码行数:11,代码来源:Backdrop.cs

示例8: QuadTreeNode

 public QuadTreeNode(FloatRect range, int capacity, Vector2f minSize)
 {
     this.range = range;
     this.capacity = capacity;
     this.child = null;
     this.cubeList = new List<Cube>();
     this.minSize = minSize;
 }
开发者ID:CyrilPaulus,项目名称:2dThing,代码行数:8,代码来源:QuadTree.cs

示例9: HWSurfaceInstance

 public HWSurfaceInstance(ScriptEngine parent, Texture texture)
     : base(parent.Object.InstancePrototype)
 {
     _source = new FloatRect(_ox, _oy, texture.Size.X, texture.Size.Y);
     _ox += _source.Width + 1;
     if (_ox > _aw) { _ox = 0; _oy += _source.Height + 1; }
     Init();
 }
开发者ID:Radnen,项目名称:sphere-sfml,代码行数:8,代码来源:HWSurfaceInstance2.cs

示例10: Pillar

        List<ChampItemPair> units; //ingroup

        #endregion Fields

        #region Constructors

        internal Pillar(FloatRect postion)
        {
            rect = postion;
            units = new List<ChampItemPair>();

            pillarSprite = new Sprite();
            unitSprite = new Sprite();
        }
开发者ID:nik0kin,项目名称:ProjectTurtle,代码行数:14,代码来源:Pillar.cs

示例11: Draw

        /// <summary>
        /// Draws a rectangle.
        /// </summary>
        /// <param name="sb"><see cref="ISpriteBatch"/> to draw to.</param>
        /// <param name="dest">Destination rectangle.</param>
        /// <param name="color">Color of the rectangle.</param>
        public static void Draw(ISpriteBatch sb, Rectangle dest, Color color)
        {
            var fDest = new FloatRect(dest.Left, dest.Top, dest.Width, dest.Height);

            using (var s = Shape.Rectangle(fDest, color))
            {
                sb.Draw(s);
            }
        }
开发者ID:wtfcolt,项目名称:game,代码行数:15,代码来源:RenderRectangle.cs

示例12: Player

        public Player(FloatRect screenRect)
        {
            // setup player
            _shape = new CircleShape(30, 3);
            _shape.Position = new Vector2f(screenRect.Width/2 - (_shape.Radius), screenRect.Height - (_shape.Radius*2));
            _shape.FillColor = Color.Green;

            _bullets = new List<RectangleShape> ();
        }
开发者ID:aishsingh,项目名称:EquationInvasion,代码行数:9,代码来源:Player.cs

示例13: Update

 public override void Update(float dt)
 {
     base.Update(dt);
     Hitbox = new FloatRect(
         MyEntity.Transform.Position.X - MyEntity.Transform.Origin.X,
         MyEntity.Transform.Position.Y - MyEntity.Transform.Origin.Y,
         Hitbox.Width,
         Hitbox.Height);
 }
开发者ID:nikibobi,项目名称:LD26-fail,代码行数:9,代码来源:ColiderComponent.cs

示例14: OnColides

 private void OnColides(ColiderComponent colider, FloatRect overlap)
 {
     if(colider.MyEntity.HasComponent<Player>() &&
        StateManager.Instance.CurrentState is LevelState )
     {
         var levelState = StateManager.Instance.CurrentState as LevelState;
         levelState.CurrentLevel++;
     }
 }
开发者ID:nikibobi,项目名称:LD26-fail,代码行数:9,代码来源:LevelEnd.cs

示例15: draw

        internal override void draw(RenderWindow window)
        {
            //remember mPos is the middle this time
            FloatRect r = new FloatRect((int)(mPos.X - length / 2), (int)(mPos.Y - ylength / 2), (int)length, (int)ylength);

            sprite.Position = new Vector2f((mPos.X - (float)length / 2.0f),(mPos.Y - (float)ylength / 2.0f) );
            sprite.Color = color;
            sprite.Scale = new Vector2f((float)length / sprite.TextureRect.Width, (float)ylength / sprite.TextureRect.Height);
            window.Draw(sprite);
        }
开发者ID:nik0kin,项目名称:ProjectTurtle,代码行数:10,代码来源:Puri.cs


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