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


C# Vector2.Intersection方法代码示例

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


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

示例1: LineIntersectLinearSpellEx

        //edited
        public static bool LineIntersectLinearSpellEx(this Spell spell, Vector2 a, Vector2 b, out Vector2 intersection)
        {
            var myBoundingRadius = ObjectManager.Player.BoundingRadius;
            var spellDir = spell.Direction;
            var pSpellDir = spell.Direction.Perpendicular();
            var spellRadius = spell.Radius;
            var spellPos = spell.CurrentSpellPosition - spellDir * myBoundingRadius; //leave some space at back of spell
            var endPos = spell.GetSpellEndPosition() + spellDir * myBoundingRadius; //leave some space at the front of spell

            var startRightPos = spellPos + pSpellDir * (spellRadius + myBoundingRadius);
            var startLeftPos = spellPos - pSpellDir * (spellRadius + myBoundingRadius);
            var endRightPos = endPos + pSpellDir * (spellRadius + myBoundingRadius);
            var endLeftPos = endPos - pSpellDir * (spellRadius + myBoundingRadius);

            List<Geometry.IntersectionResult> intersects = new List<Geometry.IntersectionResult>();
            Vector2 heroPos = ObjectManager.Player.ServerPosition.To2D();

            intersects.Add(a.Intersection(b, startRightPos, startLeftPos));
            intersects.Add(a.Intersection(b, endRightPos, endLeftPos));
            intersects.Add(a.Intersection(b, startRightPos, endRightPos));
            intersects.Add(a.Intersection(b, startLeftPos, endLeftPos));

            var sortedIntersects = intersects.Where(i => i.Intersects).OrderBy(i => i.Point.Distance(heroPos)); //Get first intersection

            if (sortedIntersects.Count() > 0)
            {
                intersection = sortedIntersects.First().Point;
                return true;
            }

            intersection = Vector2.Zero;
            return false;
        }
开发者ID:giaanthunder,项目名称:EloBuddy,代码行数:34,代码来源:Spell.cs

示例2: CheckLineIntersection

 public static bool CheckLineIntersection(Vector2 a, Vector2 b, Vector2 c, Vector2 d)
 {
     return a.Intersection(b, c, d).Intersects;
 }
开发者ID:bongy97,项目名称:LeagueSharp-1,代码行数:4,代码来源:MathUtils.cs

示例3: LineIntersectLinearSpellEx

        public static bool LineIntersectLinearSpellEx(Vector2 a, Vector2 b, Spell spell, out Vector2 intersection)
        {
            var myBoundingRadius = myHero.BoundingRadius;
            var spellDir = spell.direction;
            var pSpellDir = spell.direction.Perpendicular();
            var spellRadius = GetSpellRadius(spell);
            var spellPos = SpellDetector.GetCurrentSpellPosition(spell) - spellDir * myBoundingRadius; //leave some space at back of spell
            var endPos = spell.endPos + spellDir * myBoundingRadius; //leave some space at the front of spell

            var startRightPos = spellPos + pSpellDir * (spellRadius + myBoundingRadius);
            var startLeftPos = spellPos - pSpellDir * (spellRadius + myBoundingRadius);
            var endRightPos = endPos + pSpellDir * (spellRadius + myBoundingRadius);
            var endLeftPos = endPos - pSpellDir * (spellRadius + myBoundingRadius);

            var int1 = a.Intersection(b, startRightPos, startLeftPos);

            var int2 = a.Intersection(b, endRightPos, endLeftPos);
            var int3 = a.Intersection(b, startRightPos, endRightPos);
            var int4 = a.Intersection(b, startLeftPos, endLeftPos);

            if (int1.Intersects)
            {
                intersection = int1.Point;
                return true;
            }
            else if (int2.Intersects)
            {
                intersection = int2.Point;
                return true;
            }
            else if (int3.Intersects)
            {
                intersection = int3.Point;
                return true;
            }
            else if (int4.Intersects)
            {
                intersection = int4.Point;
                return true;
            }

            intersection = Vector2.Zero;

            return false;
        }
开发者ID:qktlfflzk,项目名称:Backup5.4,代码行数:45,代码来源:EvadeHelper.cs


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