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


C# Vector2.Distance方法代码示例

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


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

示例1: WallTumble

        public static void WallTumble()
        {
            foreach (var delayedAction in DelayedActions)
            {
                if (delayedAction.Value <= Environment.TickCount)
                {
                    delayedAction.Key.Invoke();
                    DelayedActions.Remove(delayedAction.Key);
                    return;
                }
            }
            if (!Program.Q.IsReady()) return;

            Vector2 drakeWallQPos = new Vector2(11514, 4462);
            Vector2 midWallQPos = new Vector2(6667, 8794);

            var selectedPos = drakeWallQPos.Distance(_Player) < midWallQPos.Distance(_Player) ? drakeWallQPos :  midWallQPos;
            var walkPos = drakeWallQPos.Distance(_Player) < midWallQPos.Distance(_Player)
                ? new Vector2(12050, 4827)
                : new Vector2(6962, 8952);
            if (_Player.Distance(walkPos) < 200 && _Player.Distance(walkPos) > 1)
            {
                Player.IssueOrder(GameObjectOrder.MoveTo, walkPos.To3D());
            }
            else if(_Player.Distance(walkPos) <= 10)
            {
                Player.IssueOrder(GameObjectOrder.MoveTo, walkPos.To3D());
                DelayedActions.Add(delegate {Program.Q.Cast(selectedPos.To3D());}, Environment.TickCount + 106 + (Game.Ping/2));
            }
        }
开发者ID:hup3s,项目名称:Elobuddy-Addons,代码行数:30,代码来源:WallQ.cs

示例2: GetTumblePos

        public static Vector3 GetTumblePos(this Obj_AI_Base target)
        {
            //if the target is not a melee and he's alone he's not really a danger to us, proceed to 1v1 him :^ )
            if (!target.IsMelee && Heroes.Player.CountEnemiesInRange(800) == 1) return Game.CursorPos;

            var aRC = new Geometry.Circle(Heroes.Player.ServerPosition.To2D(), 300).ToPolygon().ToClipperPath();
            var cursorPos = Game.CursorPos;
            var targetPosition = target.ServerPosition;
            var pList = new List<Vector3>();
            var additionalDistance = (0.106 + Game.Ping / 2000f) * target.MoveSpeed;

            if (!cursorPos.IsDangerousPosition()) return cursorPos;

            foreach (var p in aRC)
            {
                var v3 = new Vector2(p.X, p.Y).To3D();

                if (target.IsFacing(Heroes.Player))
                {
                    if (!v3.IsDangerousPosition() && v3.Distance(targetPosition) < 550) pList.Add(v3);
                }
                else
                {
                    if (!v3.IsDangerousPosition() && v3.Distance(targetPosition) < 550 - additionalDistance) pList.Add(v3);
                }
            }
            if (Heroes.Player.UnderTurret() || Heroes.Player.CountEnemiesInRange(800) == 1)
            {
                return pList.Count > 1 ? pList.OrderBy(el => el.Distance(cursorPos)).FirstOrDefault() : Vector3.Zero;
            }
            return pList.Count > 1 ? pList.OrderBy(el => el.Distance(cursorPos)).FirstOrDefault() : Vector3.Zero;
        }
开发者ID:q51251,项目名称:LeagueSharp-1,代码行数:32,代码来源:MyExtensions.cs

示例3: WallTumble

        public static void WallTumble()
        {
            if (Game.MapId != GameMapId.SummonersRift) return;
            if (!Vayne.Q.IsReady())
            {
                Orbwalker.DisableMovement = false;
                return;
            }
            Orbwalker.DisableMovement = true;

            Vector2 drakeWallQPos = new Vector2(11514, 4462);
            Vector2 midWallQPos = new Vector2(6667, 8794);

            var selectedPos = drakeWallQPos.Distance(_Player) < midWallQPos.Distance(_Player) ? drakeWallQPos : midWallQPos;
            var walkPos = drakeWallQPos.Distance(_Player) < midWallQPos.Distance(_Player)
                ? new Vector2(12050, 4827)
                : new Vector2(6962, 8952);
            if (_Player.Distance(walkPos) < 200 && _Player.Distance(walkPos) > 60)
            {
                Player.IssueOrder(GameObjectOrder.MoveTo, walkPos.To3D());
            }
            else if (_Player.Distance(walkPos) <= 50)
            {
                Player.CastSpell(SpellSlot.Q, selectedPos.To3D());
            }
        }
开发者ID:himrengod,项目名称:Elobuddy-1,代码行数:26,代码来源:Misc.cs

示例4: CheckAllyHeroCollision

 /// <summary>
 /// Checks enemy hero collisions
 /// </summary>
 /// <param name="from">Start position</param>
 /// <param name="to">End position</param>
 /// <param name="width">Rectangle scale</param>
 /// <param name="delay">Spell delay</param>
 /// <param name="missileSpeed">Spell missile speed</param>
 /// <param name="isArc">Checks collision for arc spell</param>
 /// <returns>true if collision found</returns>
 public static bool CheckAllyHeroCollision(Vector2 from, Vector2 to, float width, float delay, float missileSpeed = 0, bool isArc = false)
 {
     var spellHitBox = ClipperWrapper.MakePaths(ClipperWrapper.DefineRectangle(from, to, width));
     if (isArc)
     {
         spellHitBox = ClipperWrapper.MakePaths(new SPrediction.Geometry.Polygon(
                         ClipperWrapper.DefineArc(from - new Vector2(875 / 2f, 20), to, (float)Math.PI * (to.Distance(from) / 875f), 410, 200 * (to.Distance(from) / 875f)),
                         ClipperWrapper.DefineArc(from - new Vector2(875 / 2f, 20), to, (float)Math.PI * (to.Distance(from) / 875f), 410, 320 * (to.Distance(from) / 875f))));
     }
     return HeroManager.Allies.AsParallel().Any(p => ClipperWrapper.IsIntersects(ClipperWrapper.MakePaths(ClipperWrapper.DefineCircle(Prediction.GetFastUnitPosition(p, delay, missileSpeed), p.BoundingRadius)), spellHitBox));
 }
开发者ID:Ryzeros,项目名称:L-,代码行数:21,代码来源:Collision.cs

示例5: GetPrediction

        /// <summary>
        /// Gets Prediction result
        /// </summary>
        /// <param name="target">Target for spell</param>
        /// <param name="width">Spell width</param>
        /// <param name="delay">Spell delay</param>
        /// <param name="missileSpeed">Spell missile speed</param>
        /// <param name="range">Spell range</param>
        /// <param name="collisionable">Spell collisionable</param>
        /// <param name="type">Spell skillshot type</param>
        /// <param name="path">Waypoints of target</param>
        /// <param name="avgt">Average reaction time (in ms)</param>
        /// <param name="movt">Passed time from last movement change (in ms)</param>
        /// <param name="avgp">Average Path Lenght</param>
        /// <param name="from">Spell casted position</param>
        /// <param name="rangeCheckFrom"></param>
        /// <returns>Prediction result as <see cref="Prediction.Result"/></returns>
        public static Prediction.Result GetPrediction(Obj_AI_Base target, float width, float delay, float missileSpeed, float range, bool collisionable, List<Vector2> path, float avgt, float movt, float avgp, Vector2 from, Vector2 rangeCheckFrom)
        {
            Prediction.Result result = Prediction.GetPrediction(target, width, delay, missileSpeed, range, collisionable, SkillshotType.SkillshotCircle, path, avgt, movt, avgp, from, rangeCheckFrom);
            if (result.HitChance >= HitChance.Low && delay >= 1.0f && width < 250)
            {
                result.CastPosition += (result.CastPosition - from + target.Direction.To2D()).Normalized() * width / 2f;
                if (from.Distance(result.CastPosition) > range - Prediction.GetArrivalTime(from.Distance(result.CastPosition), delay, missileSpeed) * target.MoveSpeed * (100 - Prediction.predMenu.Item("SPREDMAXRANGEIGNORE").GetValue<Slider>().Value) / 100f)
                    result.HitChance = HitChance.OutOfRange;
            }

            return result;
        }
开发者ID:MrWenzoxfs,项目名称:elobuddy,代码行数:29,代码来源:CirclePrediction.cs

示例6: GetFirstNonWallPos

 public static Vector2 GetFirstNonWallPos(Vector2 startPos, Vector2 endPos)
 {
     int distance = 0;
     for (int i = 0; i < Program.CondemnMenu["pushDistance"].Cast<Slider>().CurrentValue; i += 20)
     {
         var cell = startPos.Extend(endPos, endPos.Distance(startPos) + i).ToNavMeshCell().CollFlags;
         if (cell.HasFlag(CollisionFlags.Wall) || cell.HasFlag(CollisionFlags.Building))
         {
             distance = i - 20;
         }
     }
     return startPos.Extend(endPos, distance + endPos.Distance(startPos));
 }
开发者ID:hup3s,项目名称:Elobuddy-Addons,代码行数:13,代码来源:Condemn.cs

示例7: GetFirstNonWallPos

 public static Vector2 GetFirstNonWallPos(Vector2 startPos, Vector2 endPos)
 {
     int distance = 0;
     for (int i = 0; i < Manager.MenuManager.CondemnPushDistance; i += 20)
     {
         var cell = startPos.Extend(endPos, endPos.Distance(startPos) + i);
         if (NavMesh.GetCollisionFlags(cell).HasFlag(CollisionFlags.Wall) ||
             NavMesh.GetCollisionFlags(cell).HasFlag(CollisionFlags.Building))
         {
             distance = i - 20;
         }
     }
     return startPos.Extend(endPos, distance + endPos.Distance(startPos));
 }
开发者ID:Kysamaa,项目名称:EloBuddy,代码行数:14,代码来源:Mechanics.cs

示例8: FastPrediction

        public static FastPredResult FastPrediction(Vector2 from, Obj_AI_Base unit, int delay, int speed)
        {
            var tDelay = delay / 1000f + (from.Distance(unit) / speed);
            var d = tDelay * unit.MoveSpeed;
            var path = unit.Path;

            if (path.Length > d)
            {
                return new FastPredResult
                {
                    IsMoving = true,
                    CurrentPos = unit.ServerPosition.To2D(),
                    PredictedPos = CutPath(path, d)[0].To2D(),
                };
            }

            if (path.Count() == 0)
            {
                return new FastPredResult
                {
                    IsMoving = false,
                    CurrentPos = unit.ServerPosition.To2D(),
                    PredictedPos = unit.ServerPosition.To2D(),
                };
            }

            return new FastPredResult
            {
                IsMoving = false,
                CurrentPos = path[path.Count() - 1].To2D(),
                PredictedPos = path[path.Count() - 1].To2D(),
            };
        }
开发者ID:denizereer3,项目名称:EloBuddy,代码行数:33,代码来源:Collision.cs

示例9: GetCondemnPosition

        public static Vector3 GetCondemnPosition(this Vector3 position)
        {
            var pointList = new List<Vector3>();

            pointList.Add(Vector3.Zero);

            for (var j = 485; j >= 50; j -= 100)
            {
                var offset = (int)(2 * Math.PI * j / 100);

                for (var i = 0; i <= offset; i++)
                {
                    var angle = i * Math.PI * 2 / offset;
                    var point =
                        new Vector2(
                            (float)(position.X + j * Math.Cos(angle)),
                            (float)(position.Y - j * Math.Sin(angle))).To3D();

                    var cP = point.Extend(position, point.Distance(position) + 50);
                    if (point.IsWall() && cP.Distance(point) < 425 && !cP.UnderTurret(true) && cP.Distance(position) > 325 && cP.Distance(position) < 545 &&
                 (cP.CountEnemiesInRange(425) <= cP.CountAlliesInRange(325)))
                    {
                        pointList.Add(cP);
                    }
                }
            }

            return pointList.OrderByDescending(p=>p.Distance(position)).FirstOrDefault();
        }
开发者ID:Hydro202,项目名称:Leaguesharp,代码行数:29,代码来源:Extensions.cs

示例10: GetPRADAPos

        public static Vector3 GetPRADAPos(this AIHeroClient target)
        {
            if (target == null) return Vector3.Zero;
            var aRC = new Geometry.Circle(Heroes.Player.ServerPosition.To2D(), 300).ToPolygon().ToClipperPath();
            var tP = target.ServerPosition;
            var pList = new List<Vector3>();
            foreach (var p in aRC)
            {
                var v3 = new Vector2(p.X, p.Y).To3D();


                if (!v3.UnderTurret(true) && v3.Distance(tP) > 325 && v3.Distance(tP) < Heroes.Player.AttackRange &&
                    (v3.CountEnemiesInRange(425) <= v3.CountAlliesInRange(325))) pList.Add(v3);
            }
            return pList.Count > 1 ? pList.OrderByDescending(el => el.Distance(tP)).FirstOrDefault() : Vector3.Zero;
        }
开发者ID:AristoLOL,项目名称:EloBuddy-1,代码行数:16,代码来源:Wizard.cs

示例11: FastPrediction

        public static FastPredResult FastPrediction(Vector2 from, Obj_AI_Base unit, int delay, int speed)
        {
            var tDelay = delay/1000f + (from.Distance(unit)/speed);
            var d = tDelay*unit.MoveSpeed;
            var path = unit.GetWaypoints();

            if (path.PathLength() > d)
            {
                return new FastPredResult
                {
                    IsMoving = true,
                    CurrentPos = unit.ServerPosition.To2D(),
                    PredictedPos = path.CutPath((int) d)[0]
                };
            }
            if (path.Count == 0)
            {
                return new FastPredResult
                {
                    IsMoving = false,
                    CurrentPos = unit.ServerPosition.To2D(),
                    PredictedPos = unit.ServerPosition.To2D()
                };
            }
            return new FastPredResult
            {
                IsMoving = false,
                CurrentPos = path[path.Count - 1],
                PredictedPos = path[path.Count - 1]
            };
        }
开发者ID:amanditateamuh,项目名称:LeagueSharp,代码行数:31,代码来源:Collision.cs

示例12: InitPositionInfo

        public static PositionInfo InitPositionInfo(Vector2 pos, float extraDelayBuffer, float extraEvadeDistance, Vector2 lastMovePos, Spell lowestEvadeTimeSpell) //clean this shit up
        {
            var extraDist = Evade.menu.SubMenu("MiscSettings").SubMenu("ExtraBuffers").Item("ExtraCPADistance").GetValue<Slider>().Value;

            var posInfo = canHeroWalkToPos(pos, myHero.MoveSpeed, extraDelayBuffer + Game.Ping, extraDist);
            posInfo.isDangerousPos = CheckDangerousPos(pos, 6);
            posInfo.hasExtraDistance = extraEvadeDistance > 0 ? CheckDangerousPos(pos, extraEvadeDistance) : false;// ? 1 : 0;            
            posInfo.closestDistance = posInfo.distanceToMouse;
            posInfo.intersectionTime = GetIntersectTime(lowestEvadeTimeSpell, myHero.ServerPosition.To2D(), pos);
            posInfo.distanceToMouse = pos.Distance(lastMovePos);
            posInfo.posDistToChamps = GetDistanceToChampions(pos);

            if (Evade.menu.SubMenu("MiscSettings").SubMenu("FastEvade").Item("RejectMinDistance").GetValue<Slider>().Value > 0
            && Evade.menu.SubMenu("MiscSettings").SubMenu("FastEvade").Item("RejectMinDistance").GetValue<Slider>().Value >
                posInfo.closestDistance) //reject closestdistance
            {
                posInfo.rejectPosition = true;
            }

            if (Evade.menu.SubMenu("MiscSettings").SubMenu("ExtraBuffers").Item("MinComfortZone").GetValue<Slider>().Value >
                posInfo.posDistToChamps)
            {
                posInfo.hasComfortZone = false;
            }

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

示例13: Arc

 public Arc(Vector2 start, Vector2 end, int hitbox)
 {
     Start = start;
     End = end;
     HitBox = hitbox;
     Distance = Start.Distance(End);
 }
开发者ID:StopMotionCuber,项目名称:LeagueSharp-1,代码行数:7,代码来源:Geometry.cs

示例14: CanEscapeWithFlash

 public static bool CanEscapeWithFlash(Vector2 pos)
 {
     foreach (Obj_AI_Turret turret in ObjectManager.Get<Obj_AI_Turret>().Where(turret => turret.IsEnemy && turret.Health > 0))
     {
         if (pos.Distance(turret.Position.To2D()) < (1800 + Player.BoundingRadius))
             return true;
     }
     return false;
 }
开发者ID:0s0speedy,项目名称:LeagueSharp,代码行数:9,代码来源:Program.cs

示例15: AngleBetween

        public static double AngleBetween(Vector2 a, Vector2 b, Vector2 c)
        {
            var a1 = c.Distance(b);
            var b1 = a.Distance(c);
            var c1 = b.Distance(a);
            if (a1 == 0 || c1 == 0) { return 0; }

            return Math.Acos((a1 * a1 + c1 * c1 - b1 * b1) / (2 * a1 * c1)) * (180 / Math.PI);
        }
开发者ID:himrengod,项目名称:Elobuddy-1,代码行数:9,代码来源:VectorHelper.cs


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