• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Graphics.Vector2类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: MoveManyTransBox

 /// <summary>
 /// Initializes a new instance of the <see cref="MoveManyTransBox"/> class.
 /// </summary>
 /// <param name="owner">The <see cref="TransBoxManager"/>.</param>
 /// <param name="spatials">The <see cref="ISpatial"/>s.</param>
 /// <param name="position">The position.</param>
 /// <param name="camera">The camera.</param>
 public MoveManyTransBox(TransBoxManager owner, IEnumerable<ISpatial> spatials, Vector2 position, ICamera2D camera)
 {
     _owner = owner;
     _camera = camera;
     _position = position;
     _spatials = spatials.ToImmutable();
 }
开发者ID:mateuscezar,项目名称:netgore,代码行数:14,代码来源:TransBoxManager.MoveManyTransBox.cs


示例2: Contains

        /// <summary>
        /// Checks if the <see cref="ISpatial"/> contains a point.
        /// </summary>
        /// <param name="spatial">The spatial.</param>
        /// <param name="p">Point to check if the <paramref name="spatial"/> contains.</param>
        /// <returns>True if the <paramref name="spatial"/> contains <paramref name="p"/>; otherwise false.</returns>
        public static bool Contains(this ISpatial spatial, Vector2 p)
        {
            var min = spatial.Position;
            var max = spatial.Max;

            return (min.X <= p.X && max.X >= p.X && min.Y <= p.Y && max.Y >= p.Y);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:13,代码来源:ISpatialExtensions.cs


示例3: MTD

        /// <summary>
        /// Finds the Minimal Translational Distance between two <see cref="ISpatial"/>s.
        /// </summary>
        /// <param name="srcMin">Top-left of the source (dynamic) <see cref="ISpatial"/> that will be the one moving.</param>
        /// <param name="srcMax">Bottom-right of the source (dynamic) <see cref="ISpatial"/> that will be the one moving.</param>
        /// <param name="tarMin">Top-left of the target (static) <see cref="ISpatial"/> that will not move.</param>
        /// <param name="tarMax">Bottom-right of the target (static) <see cref="ISpatial"/> that will not move.</param>
        /// <returns>The MTD for the source to no longer intersect the target.</returns>
        public static Vector2 MTD(Vector2 srcMin, Vector2 srcMax, Vector2 tarMin, Vector2 tarMax)
        {
            // Down
            float mtd = srcMax.Y - tarMin.Y;
            BoxSide side = BoxSide.Bottom;

            // Left
            float diff = srcMax.X - tarMin.X;
            if (diff < mtd)
            {
                mtd = diff;
                side = BoxSide.Left;
            }

            // Right
            diff = tarMax.X - srcMin.X;
            if (diff < mtd)
            {
                mtd = diff;
                side = BoxSide.Right;
            }

            // Up
            diff = tarMax.Y - srcMin.Y;
            if (diff < mtd)
            {
                mtd = diff;
                side = BoxSide.Top;
            }

            if (mtd < 0.0f)
                return Vector2.Zero;

            return CreateMTDVector(side, mtd + 1);
        }
开发者ID:wtfcolt,项目名称:game,代码行数:43,代码来源:SpatialHelper.cs


示例4: ContainsPoint

 /// <summary>
 /// Checks if this <see cref="ITransBox"/> contains the given world point.
 /// </summary>
 /// <param name="worldPos">The world point.</param>
 /// <returns>True if this <see cref="ITransBox"/> contains the <paramref name="worldPos"/>; otherwise false.</returns>
 public bool ContainsPoint(Vector2 worldPos)
 {
     var w = worldPos;
     var lo = Position;
     var hi = Max;
     return (lo.X <= w.X) && (lo.Y <= w.Y) && (hi.X >= w.X) && (hi.Y >= w.Y);
 }
开发者ID:Vizzini,项目名称:netgore,代码行数:12,代码来源:TransBoxManager.MoveManyTransBox.cs


示例5: Align

            Vector2 Align(Vector2 v)
            {
                if (_owner == null || _owner.GridAligner == null)
                    return v;

                return _owner.GridAligner.Align(v);
            }
开发者ID:Vizzini,项目名称:netgore,代码行数:7,代码来源:TransBoxManager.TransBox.cs


示例6: ChatForm

        /// <summary>
        /// Initializes a new instance of the <see cref="ChatForm"/> class.
        /// </summary>
        /// <param name="parent">The parent.</param>
        /// <param name="pos">The pos.</param>
        public ChatForm(Control parent, Vector2 pos) : base(parent, pos, new Vector2(300, 150))
        {
            // Create the input and output TextBoxes
            _input = new TextBox(this, Vector2.Zero, new Vector2(32, 32))
            {
                IsMultiLine = false,
                IsEnabled = true,
                Font = GameScreenHelper.DefaultChatFont,
                MaxInputTextLength = GameData.MaxClientSayLength,
                BorderColor = new Color(255, 255, 255, 100)
            };

            _output = new TextBox(this, Vector2.Zero, new Vector2(32, 32))
            {
                IsMultiLine = true,
                IsEnabled = false,
                Font = GameScreenHelper.DefaultChatFont,
                BorderColor = new Color(255, 255, 255, 100)
            };

            _input.KeyPressed -= Input_KeyPressed;
            _input.KeyPressed += Input_KeyPressed;
           
            // Force the initial repositioning
            RepositionTextBoxes();
        }
开发者ID:wtfcolt,项目名称:game,代码行数:31,代码来源:ChatForm.cs


示例7: Draw

        /// <summary>
        /// Draws the <see cref="SkeletonBodyItem"/>.
        /// </summary>
        /// <param name="sb"><see cref="ISpriteBatch"/> to draw to.</param>
        /// <param name="position">Position to draw at.</param>
        /// <param name="scale">Amount to scale the Grh in percent (1.0f for no scaling).</param>
        /// <param name="color">The color.</param>
        /// <param name="effect">SpriteEffects to use when drawing.</param>
        internal void Draw(ISpriteBatch sb, Vector2 position, float scale, Color color, SpriteEffects effect)
        {
            // Validate
            if (Source == null)
                return;

            // Find the effect
            Vector2 m;
            switch (effect)
            {
                case SpriteEffects.FlipHorizontally:
                    m = new Vector2(-1, 1);
                    break;

                case SpriteEffects.FlipVertically:
                    m = new Vector2(1, -1);
                    break;

                default:
                    m = new Vector2(1, 1);
                    break;
            }

            // Calculate the angle
            float angle;
            if (Dest == null)
                angle = 0.0f;
            else
                angle = SkeletonNode.GetAngle(Source.Position * m, Dest.Position * m) - MathHelper.PiOver2;

            // Draw
            var v = Source.Position + ItemInfo.Offset;
            Grh.Draw(sb, (v * m) + position, color, effect, angle, ItemInfo.Origin, scale);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:42,代码来源:SkeletonBodyItem.cs


示例8: Play

        /// <summary>
        /// Plays a sound.
        /// </summary>
        /// <param name="soundManager">The sound manager.</param>
        /// <param name="name">The name of the sound to play.</param>
        /// <param name="source">The source of the sound.</param>
        /// <returns>
        /// True if the sound was successfully played; otherwise false.
        /// </returns>
        public static bool Play(this ISoundManager soundManager, string name, Vector2 source)
        {
            var info = soundManager.GetSoundInfo(name);
            if (info == null)
                return false;

            return soundManager.Play(info.ID, source);
        }
开发者ID:wtfcolt,项目名称:game,代码行数:17,代码来源:ISoundManagerExtensions.cs


示例9: SkeletonBodyItemInfo

 /// <summary>
 /// Initializes a new instance of the <see cref="SkeletonBodyItemInfo"/> class.
 /// </summary>
 /// <param name="grhIndex">The <see cref="GrhIndex"/> for the sprite to draw for the body item.</param>
 /// <param name="sourceName">Name of the source node.</param>
 /// <param name="destName">Name of the destination node (String.Empty for no destination).</param>
 /// <param name="offset">Grh drawing offset.</param>
 /// <param name="origin">Grh drawing origin.</param>
 public SkeletonBodyItemInfo(GrhIndex grhIndex, string sourceName, string destName, Vector2 offset, Vector2 origin)
 {
     GrhIndex = grhIndex;
     _sourceName = sourceName;
     _destName = destName;
     Offset = offset;
     Origin = origin;
 }
开发者ID:wtfcolt,项目名称:game,代码行数:16,代码来源:SkeletonBodyItemInfo.cs


示例10: Toolbar

        /// <summary>
        /// Initializes a new instance of the <see cref="Toolbar"/> class.
        /// </summary>
        /// <param name="parent">The parent.</param>
        /// <param name="pos">The pos.</param>
        public Toolbar(Control parent, Vector2 pos) : base(parent, pos, Vector2.One)
        {
            ResizeToChildren = true;
            ResizeToChildrenPadding = _padding;

            _items = CreateToolbarItems();

            Position = pos;
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:14,代码来源:Toolbar.cs


示例11: CreateEntities

        static IEnumerable<Entity> CreateEntities(int amount, Vector2 minPos, Vector2 maxPos)
        {
            var ret = new Entity[amount];
            for (var i = 0; i < amount; i++)
            {
                ret[i] = new TestEntity { Position = RandomHelper.NextVector2(minPos, maxPos) };
            }

            return ret;
        }
开发者ID:wtfcolt,项目名称:game,代码行数:10,代码来源:SpatialAggregateTests.cs


示例12: Draw

        /// <summary>
        /// Draws a rectangle.
        /// </summary>
        /// <param name="sb"><see cref="ISpriteBatch"/> to draw to.</param>
        /// <param name="position">Top-left corner position.</param>
        /// <param name="size">The size of the rectangle.</param>
        /// <param name="color">Color of the rectangle.</param>
        public static void Draw(ISpriteBatch sb, Vector2 position, Vector2 size, Color color)
        {
            var drawRect = _drawRectBorder;

            drawRect.Size = size;
            drawRect.Position = position;
            drawRect.FillColor = color;

            sb.Draw(drawRect);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:17,代码来源:RenderRectangle.cs


示例13: ThralledNPC

        public ThralledNPC(World parent, CharacterTemplate template, Map map, Vector2 position)
            : base(parent, template, map, position)
        {
            // This NPC should never respawn. Once it's dead, that should be it!
            RespawnMapID = null;
            RespawnPosition = Vector2.Zero;

            if (log.IsDebugEnabled)
                log.DebugFormat("Created ThralledNPC `{0}` on map `{1}` at `{2}` with template `{3}`.", this, Map, Position,
                    template);
        }
开发者ID:wtfcolt,项目名称:game,代码行数:11,代码来源:ThralledNPC.cs


示例14: GetObjUnderCursor

        /// <summary>
        /// Gets the selectable object currently under the cursor.
        /// </summary>
        /// <param name="map">The <see cref="EditorMap"/>.</param>
        /// <param name="worldPos">The world position.</param>
        /// <returns>The selectable object currently under the cursor, or null if none.</returns>
        protected override object GetObjUnderCursor(EditorMap map, Vector2 worldPos)
        {
            var closestLight = map.Lights.MinElementOrDefault(x => worldPos.QuickDistance(x.Center));
            if (closestLight == null)
                return null;

            if (worldPos.QuickDistance(closestLight.Center) > 10)
                return null;

            return closestLight;
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:17,代码来源:MapLightCursorTool.cs


示例15: DrawStringShaded

        /// <summary>
        /// Draws a string with shading.
        /// </summary>
        /// <param name="spriteBatch"><see cref="ISpriteBatch"/> to use to draw.</param>
        /// <param name="font"><see cref="Font"/> to draw the string with.</param>
        /// <param name="text">The string to draw.</param>
        /// <param name="position">The position of the top-left corner of the string to draw.</param>
        /// <param name="fontColor">The font color.</param>
        /// <param name="borderColor">The shading color.</param>
        public static void DrawStringShaded(this ISpriteBatch spriteBatch, Font font, string text, Vector2 position,
                                            Color fontColor, Color borderColor)
        {
            position = position.Round();

            spriteBatch.DrawString(font, text, position - new Vector2(0, 1), borderColor);
            spriteBatch.DrawString(font, text, position - new Vector2(1, 0), borderColor);
            spriteBatch.DrawString(font, text, position + new Vector2(0, 1), borderColor);
            spriteBatch.DrawString(font, text, position + new Vector2(1, 0), borderColor);

            spriteBatch.DrawString(font, text, position, fontColor);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:21,代码来源:ISpriteBatchExtensions.cs


示例16: Particle

        public Particle(Vector2 position, Vector2 direction, float decayTime, Vector2 size, Color color)
        {
            _position = position;
            _direction = direction;
            _decayTime = decayTime;
            _startTime = Game.ElapsedTime;

            _shape = new RectangleShape
            {
                Size = size,
                Rotation = RandomHelper.RandomFloat(360),
                FillColor = color,
                Origin = size / 2
            };
        }
开发者ID:Thunder7102,项目名称:RPG,代码行数:15,代码来源:Particle.cs


示例17: FocusCameraAtScreenPoint

        void FocusCameraAtScreenPoint(MouseEventArgs e)
        {
            if (Camera == null || Camera.Map == null)
                return;

            if (e.Button == MouseButtons.Left)
            {
                var percent = new Vector2(e.X, e.Y) / new Vector2(Size.Width, Size.Height);
                var min = Vector2.Zero;
                var max = Vector2.One;
                Vector2.Clamp(ref percent, ref min, ref max, out percent);

                var worldPos = Camera.Map.Size * percent;
                Camera.CenterOn(worldPos);
            }
        }
开发者ID:wtfcolt,项目名称:game,代码行数:16,代码来源:MapPreviewScreenControl.cs


示例18: Activate

        /// <summary>
        /// Activates the DamageText.
        /// </summary>
        /// <param name="damage">Damage value to display.</param>
        /// <param name="entity">Entity the damage was done to.</param>
        /// <param name="currTime">Current time.</param>
        public void Activate(int damage, Entity entity, TickCount currTime)
        {
            if (entity == null)
            {
                Debug.Fail("entity is null.");
                return;
            }

            // Set the starting values
            _alpha = 255;
            _pos = entity.Position;
            _lastUpdate = currTime;
            _text = damage.ToString();

            // Get a random velocity
            _velocity = new Vector2(-1.0f + (float)_random.NextDouble() * 2.0f, -2.0f - (float)_random.NextDouble() * 0.25f);
        }
开发者ID:Vizzini,项目名称:netgore,代码行数:23,代码来源:DamageText.cs


示例19: Draw

        /// <summary>
        /// Draws a line.
        /// </summary>
        /// <param name="sb"><see cref="ISpriteBatch"/> to draw to.</param>
        /// <param name="p1">First point of the line.</param>
        /// <param name="p2">Second point of the line.</param>
        /// <param name="color">Color of the line.</param>
        /// <param name="thickness">The thickness of the line in pixels. Default is 1.</param>
        public static void Draw(ISpriteBatch sb, Vector2 p1, Vector2 p2, Color color, float thickness = 1f)
        {
            if (sb == null)
            {
                Debug.Fail("sb is null.");
                return;
            }

            if (sb.IsDisposed)
            {
                Debug.Fail("sb is disposed.");
                return;
            }

            using (var s = Shape.Line(p1, p2, thickness, color))
            {
                sb.Draw(s);
            }
        }
开发者ID:wtfcolt,项目名称:game,代码行数:27,代码来源:RenderLine.cs


示例20: FireballProjectile

        public FireballProjectile(IProjectileOwner owner, Vector2 direction)
            : base(owner, 0)
        {
            _direction = direction;
            Position = owner.Position;
            fireballAge = Game.ElapsedTime + 10;

            _centerShapes = new List<RectangleShape>();
            _particles = new List<Particle>();
            for (int i = 0; i < 3; i++)
            {
                _centerShapes.Add(new RectangleShape
                {
                    Size = new Vector2(15, 15),
                    Origin = new Vector2(7.5f, 7.5f),
                    Rotation = RandomHelper.RandomFloat(360),
                    FillColor = Color.Red
                });
            }
        }
开发者ID:Thunder7102,项目名称:RPG,代码行数:20,代码来源:FireballProjectile.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Graphics.Vertex类代码示例发布时间:2022-05-26
下一篇:
C# Graphics.Texture类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap