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


C# Vector2.LSDistance方法代码示例

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


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

示例1: BadaoAngleBetween

 public static double BadaoAngleBetween(Vector2 a, Vector2 center, Vector2 c)
 {
     float a1 = c.LSDistance(center);
     float b1 = a.LSDistance(c);
     float c1 = center.LSDistance(a);
     if (a1 == 0 || c1 == 0) { return 0; }
     else
     {
         return Math.Acos((a1 * a1 + c1 * c1 - b1 * b1) / (2 * a1 * c1)) * (180 / Math.PI);
     }
 }
开发者ID:yashine59fr,项目名称:PortAIO-1,代码行数:11,代码来源:BadaoChecker.cs

示例2: GetAoePrediction

        /// <summary>
        ///     Gets Aoe Prediction result
        /// </summary>
        /// <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="from">Spell casted position</param>
        /// <param name="rangeCheckFrom"></param>
        /// <returns>Prediction result as <see cref="Prediction.AoeResult" /></returns>
        public static Prediction.AoeResult GetAoePrediction(float width, float delay, float missileSpeed, float range,
            Vector2 from, Vector2 rangeCheckFrom)
        {
            var result = new Prediction.AoeResult {HitCount = 0};
            var enemies =
                HeroManager.Enemies.Where(
                    p =>
                        p.LSIsValidTarget() &&
                        Prediction.GetFastUnitPosition(p, delay, 0, from).LSDistance(rangeCheckFrom) < range);

            if (enemies.Count() > 0)
            {
                var posSummary = Vector2.Zero;
                enemies.AsParallel()
                    .ForAll(p => posSummary += Prediction.GetFastUnitPosition(p, delay, missileSpeed, from));
                var center = posSummary/enemies.Count();
                float flyTime = 0;
                if (missileSpeed != 0)
                    flyTime = from.LSDistance(center)/missileSpeed;

                posSummary = Vector2.Zero;
                var predictionResults = new List<Tuple<Prediction.Result, float>>();

                foreach (var enemy in enemies)
                {
                    var prediction = GetPrediction(enemy, width, delay + flyTime, 0, range, false, enemy.GetWaypoints(),
                        enemy.AvgMovChangeTime(), enemy.LastMovChangeTime(), enemy.AvgPathLenght(),
                        enemy.LastAngleDiff(), from, rangeCheckFrom);
                    if (prediction.HitChance > EloBuddy.SDK.Enumerations.HitChance.Medium)
                    {
                        posSummary += prediction.UnitPosition;
                        predictionResults.Add(new Tuple<Prediction.Result, float>(prediction, enemy.BoundingRadius));
                    }
                }

                if (predictionResults.Count > 0)
                {
                    center = posSummary/predictionResults.Count;
                    result.CastPosition = center;
                    foreach (var res in predictionResults)
                    {
                        if (
                            LeagueSharp.Common.Geometry.CircleCircleIntersection(center, res.Item1.UnitPosition, width,
                                res.Item2).Length > 1)
                            result.HitCount++;
                    }
                }

                predictionResults.Clear();
                GC.Collect(GC.GetGeneration(predictionResults));
            }

            return result;
        }
开发者ID:yMeliodasNTD,项目名称:PortAIO,代码行数:64,代码来源:CirclePrediction.cs

示例3: GetFirstWallPoint

        public static Vector2? GetFirstWallPoint(Vector2 from, Vector2 to, float step = 25)
        {
            var direction = (to - from).Normalized();

            for (float d = 0; d < from.LSDistance(to); d = d + step)
            {
                var testPoint = from + d * direction;
                var flags = NavMesh.GetCollisionFlags(testPoint.X, testPoint.Y);
                if (flags.HasFlag(CollisionFlags.Wall) || flags.HasFlag(CollisionFlags.Building))
                {
                    return from + (d - step) * direction;
                }
            }

            return null;
        }
开发者ID:yMeliodasNTD,项目名称:PortAIO,代码行数:16,代码来源:GeoAndExten.cs

示例4: CanReach

        public static bool CanReach(Vector2 start, Vector2 end, List<Geometry.Polygon> polygons, bool checkWalls = false)
        {
            if (start == end)
            {
                return false;
            }

            //TODO Disable if the distance to the start position is high
            if (checkWalls)
            {
                var nPoints = 2;
                var step = start.LSDistance(end) / nPoints;

                var direction = (end - start).LSNormalized();
                for (int i = 0; i <= nPoints; i++)
                {
                    var p = start + i * step * direction;
                    if (p.LSIsWall())
                    {
                        return false;
                    }
                }
            }

            foreach (var polygon in polygons)
            {
                for (int i = 0; i < polygon.Points.Count; i++)
                {
                    var a = polygon.Points[i];
                    var b = polygon.Points[i == polygon.Points.Count - 1 ? 0 : i + 1];

                    if (EvadeA.Utils.LineSegmentsCross(start, end, a, b))
                    {
                        return false;
                    }
                }
            }

            return true;
        }
开发者ID:Xelamats,项目名称:PortAIO,代码行数:40,代码来源:Utils.cs

示例5: FastPrediction

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

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

示例6: FastPrediction

        public static FastPredictionResult FastPrediction(Vector2 fromVector2,
            Obj_AI_Base unitAiBase,
            int delay,
            int speed)
        {
            var tickDelay = delay / 1000f + (fromVector2.LSDistance(unitAiBase) / speed);
            var moveSpeedF = tickDelay * unitAiBase.MoveSpeed;
            var path = unitAiBase.GetWaypoints();

            if (path.PathLength() > moveSpeedF)
            {
                return new FastPredictionResult
                {
                    IsMoving = true,
                    CurrentPosVector2 = unitAiBase.ServerPosition.LSTo2D(),
                    PredictedPosVector2 = path.CutPath((int) moveSpeedF)[0]
                };
            }

            if (path.Count == 0)
            {
                return new FastPredictionResult
                {
                    IsMoving = false,
                    CurrentPosVector2 = unitAiBase.ServerPosition.LSTo2D(),
                    PredictedPosVector2 = unitAiBase.ServerPosition.LSTo2D()
                };
            }

            return new FastPredictionResult
            {
                IsMoving = false,
                CurrentPosVector2 = path[path.Count - 1],
                PredictedPosVector2 = path[path.Count - 1]
            };
        }
开发者ID:Xelamats,项目名称:PortAIO,代码行数:36,代码来源:Collision.cs

示例7: PointInLineSegment

 public static bool PointInLineSegment(Vector2 segmentStart, Vector2 segmentEnd, Vector2 point)
 {
     var distanceStartEnd = segmentStart.LSDistance(segmentEnd, true);
     var distanceStartPoint = segmentStart.LSDistance(point, true);
     var distanceEndPoint = segmentEnd.LSDistance(point, true);
     return !(distanceEndPoint > distanceStartEnd || distanceStartPoint > distanceStartEnd);
 }
开发者ID:yashine59fr,项目名称:PortAIO,代码行数:7,代码来源:PredictionOktw.cs

示例8: 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(900 / 2f, 20), to, (float)Math.PI * (to.LSDistance(from) / 900), 410, 200 * (to.LSDistance(from) / 900)),
                         ClipperWrapper.DefineArc(from - new Vector2(900 / 2f, 20), to, (float)Math.PI * (to.LSDistance(from) / 900), 410, 320 * (to.LSDistance(from) / 900))));
     }
     return HeroManager.Allies.AsParallel().Any(p => ClipperWrapper.IsIntersects(ClipperWrapper.MakePaths(ClipperWrapper.DefineCircle(Prediction.GetFastUnitPosition(p, delay, missileSpeed), p.BoundingRadius)), spellHitBox));
 }
开发者ID:CONANLXF,项目名称:AIO,代码行数:21,代码来源:Collision.cs

示例9: IsBetween

 /// <summary>
 ///     Checks if the point is between 2 points
 /// </summary>
 /// <param name="b">The point to check.</param>
 /// <param name="a">The other point 1.</param>
 /// <param name="c">The other point 2.</param>
 /// <returns><c>true</c> if the point is between given 2 points</returns>
 internal static bool IsBetween(this Vector2 b, Vector2 a, Vector2 c)
 {
     return a.LSDistance(c) + c.LSDistance(b) - a.LSDistance(b) < float.Epsilon;
 }
开发者ID:CONANLXF,项目名称:AIO,代码行数:11,代码来源:Geometry.cs

示例10: GetMovementBlockPositionValue

        public static float GetMovementBlockPositionValue(Vector2 pos, Vector2 movePos)
        {
            float value = 0;// pos.LSDistance(movePos);

            foreach (KeyValuePair<int, Spell> entry in SpellDetector.spells)
            {
                Spell spell = entry.Value;
                var spellPos = spell.GetCurrentSpellPosition(true, ObjectCache.gamePing);
                var extraDist = 100 + spell.radius;

                value -= Math.Max(0, -(10 * ((float)0.8 * extraDist) / pos.LSDistance(spell.GetSpellProjection(pos))) + extraDist);
            }

            return value;
        }
开发者ID:CainWolf,项目名称:PortAIO,代码行数:15,代码来源:EvadeHelper.cs

示例11: GetCollisions

        /// <summary>
        /// Gets collided units & flags
        /// </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>
        /// <returns>Collision result as <see cref="Collision.Result"/></returns>
        public static Result GetCollisions(Vector2 from, Vector2 to, float range, float width, float delay, float missileSpeed = 0, bool isArc = false)
        {
            List<Obj_AI_Base> collidedUnits = new List<Obj_AI_Base>();
            var spellHitBox = ClipperWrapper.MakePaths(ClipperWrapper.DefineRectangle(from, to.LSExtend(from, -width), width));
            if (isArc)
            {
                spellHitBox = ClipperWrapper.MakePaths(new SPrediction.Geometry.Polygon(
                                ClipperWrapper.DefineArc(from - new Vector2(900 / 2f, 20), to, (float)Math.PI * (to.LSDistance(from) / 900), 410, 200 * (to.LSDistance(from) / 900)),
                                ClipperWrapper.DefineArc(from - new Vector2(900 / 2f, 20), to, (float)Math.PI * (to.LSDistance(from) / 900), 410, 320 * (to.LSDistance(from) / 900))));
            }
            Flags _colFlags = Flags.None;
            var collidedMinions = MinionManager.GetMinions(range + 100, MinionTypes.All, MinionTeam.NotAlly, MinionOrderTypes.None).AsParallel().Where(p => ClipperWrapper.IsIntersects(ClipperWrapper.MakePaths(ClipperWrapper.DefineCircle(Prediction.GetFastUnitPosition(p, delay, missileSpeed), p.BoundingRadius + 15)), spellHitBox));
            var collidedEnemies = HeroManager.Enemies.AsParallel().Where(p => ClipperWrapper.IsIntersects(ClipperWrapper.MakePaths(ClipperWrapper.DefineCircle(Prediction.GetFastUnitPosition(p, delay, missileSpeed), p.BoundingRadius)), spellHitBox));
            var collidedAllies = HeroManager.Allies.AsParallel().Where(p => ClipperWrapper.IsIntersects(ClipperWrapper.MakePaths(ClipperWrapper.DefineCircle(Prediction.GetFastUnitPosition(p, delay, missileSpeed), p.BoundingRadius)), spellHitBox));

            if (collidedMinions != null && collidedMinions.Count() != 0)
            {
                collidedUnits.AddRange(collidedMinions);
                _colFlags |= Flags.Minions;
            }

            if (collidedEnemies != null && collidedEnemies.Count() != 0)
            {
                collidedUnits.AddRange(collidedEnemies);
                _colFlags |= Flags.EnemyChampions;
            }

            if (collidedAllies != null && collidedAllies.Count() != 0)
            {
                collidedUnits.AddRange(collidedAllies);
                _colFlags |= Flags.AllyChampions;
            }

            if (CheckWallCollision(from, to))
                _colFlags |= Flags.Wall;

            if (CheckYasuoWallCollision(from, to, width))
                _colFlags |= Flags.YasuoWall;

            return new Result(collidedUnits, _colFlags);
        }
开发者ID:CONANLXF,项目名称:AIO,代码行数:50,代码来源:Collision.cs

示例12: Arc

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

示例13: CheckPathCollision

        public static bool CheckPathCollision(Obj_AI_Base unit, Vector2 movePos)
        {
            var path = unit.GetPath(ObjectCache.myHeroCache.serverPos2D.To3D(), movePos.To3D());

            if (path.Length > 0)
            {
                if (movePos.LSDistance(path[path.Length - 1].LSTo2D()) > 5 || path.Length > 2)
                {
                    return true;
                }
            }

            return false;
        }
开发者ID:CainWolf,项目名称:PortAIO,代码行数:14,代码来源:EvadeHelper.cs

示例14: gapCloseE

        public static void gapCloseE(Vector2 pos, List<AIHeroClient> ignore = null)
        {
            if (!E.IsReady())
                return;

            Vector2 pPos = Player.ServerPosition.LSTo2D();
            Obj_AI_Base bestEnem = null;


            float distToPos = Player.LSDistance(pos);
            if (((distToPos < Q.Range)) &&
                goesThroughWall(pos.To3D(), Player.Position))
                return;
            Vector2 bestLoc = pPos + (Vector2.Normalize(pos - pPos) * (Player.MoveSpeed * 0.35f));
            float bestDist = pos.LSDistance(pPos) - 50;
            try
            {
                foreach (Obj_AI_Base enemy in ObjectManager.Get<Obj_AI_Base>().Where(ob => enemyIsJumpable(ob, ignore)))
                {

                    float trueRange = E.Range + enemy.BoundingRadius;
                    float distToEnem = Player.LSDistance(enemy);
                    if (distToEnem < trueRange && distToEnem > 15)
                    {
                        Vector2 posAfterE = pPos + (Vector2.Normalize(enemy.Position.LSTo2D() - pPos) * E.Range);
                        float distE = pos.LSDistance(posAfterE);
                        if (distE < bestDist)
                        {
                            bestLoc = posAfterE;
                            bestDist = distE;
                            bestEnem = enemy;
                            // Console.WriteLine("Gap to best enem");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            if (bestEnem != null)
            {
                Console.WriteLine("should use gap");
                useENormal(bestEnem);
            }

        }
开发者ID:yashine59fr,项目名称:PortAIO,代码行数:48,代码来源:Yasuo.cs

示例15: Game_OnOnGameUpdate

        private static void Game_OnOnGameUpdate(EventArgs args)
        {
            PlayerPosition = ObjectManager.Player.ServerPosition.LSTo2D();

            //Set evading to false after blinking
            if (PreviousTickPosition.IsValid() &&
                PlayerPosition.LSDistance(PreviousTickPosition) > 200)
            {
                Evading = false;
            }

            PreviousTickPosition = PlayerPosition;

            //Remove the detected skillshots that have expired.
            DetectedSkillshots.RemoveAll(skillshot => !skillshot.IsActive());

            //Trigger OnGameUpdate on each skillshot.
            foreach (var skillshot in DetectedSkillshots)
            {
                skillshot.Game_OnGameUpdate();
            }

            //Evading disabled
            if (!getKeyBindItem(Config.Menu, "Enabled"))
            {
                Evading = false;
                EvadeToPoint = Vector2.Zero;
                PathFollower.Stop();
                return;
            }

            if (PlayerChampionName == "Olaf" && getCheckBoxItem(Config.misc, "DisableEvadeForOlafR") && ObjectManager.Player.HasBuff("OlafRagnarok"))
            {
                Evading = false;
                EvadeToPoint = Vector2.Zero;
                PathFollower.Stop();
                return;
            }

            //Avoid sending move/cast packets while dead.
            if (ObjectManager.Player.IsDead)
            {
                Evading = false;
                EvadeToPoint = Vector2.Zero;
                PathFollower.Stop();
                return;
            }

            //Avoid sending move/cast packets while channeling interruptable spells that cause hero not being able to move.
            if (ObjectManager.Player.IsCastingInterruptableSpell(true))
            {
                Evading = false;
                EvadeToPoint = Vector2.Zero;
                PathFollower.Stop();
                return;
            }

            if (ObjectManager.Player.Spellbook.IsAutoAttacking && !Orbwalking.IsAutoAttack(ObjectManager.Player.LastCastedSpellName()))
            {
                Evading = false;
                return;
            }

            /*Avoid evading while stunned or immobile.*/
            if (Utils.ImmobileTime(ObjectManager.Player) - Utils.TickCount > Game.Ping / 2 + 70)
            {
                Evading = false;
                return;
            }

            /*Avoid evading while dashing.*/
            if (ObjectManager.Player.LSIsDashing())
            {
                Evading = false;
                return;
            }

            //Don't evade while casting R as sion
            if (PlayerChampionName == "Sion" && ObjectManager.Player.HasBuff("SionR"))
            {
                PathFollower.Stop();
                return;
            }

            //Shield allies.
            foreach (var ally in ObjectManager.Get<AIHeroClient>())
            {
                if (ally.LSIsValidTarget(1000, false))
                {
                    var shieldAlly = Config.shielding["shield" + ally.ChampionName];
                    if (shieldAlly != null && shieldAlly.Cast<CheckBox>().CurrentValue)
                    {
                        var allySafeResult = IsSafe(ally.ServerPosition.LSTo2D());

                        if (!allySafeResult.IsSafe)
                        {
                            var dangerLevel = 0;

                            foreach (var skillshot in allySafeResult.SkillshotList)
                            {
//.........这里部分代码省略.........
开发者ID:CONANLXF,项目名称:AIO,代码行数:101,代码来源:Program.cs


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