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


C# Vector3.Distance2D方法代码示例

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


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

示例1: CheckPositionForSkipping

        public static bool CheckPositionForSkipping(Vector3 Position)
        {
            foreach (var v in UsedSkipAheadAreaCache)
                     {
                          if (Position.Distance2D(v.Position)<=v.Radius)
                                return true;
                     }

                     bool valid=false;
                     if (SkipAheadAreaCache.Count>0)
                     {
                          int validIndex=-1;
                          for (int i=0; i<SkipAheadAreaCache.Count-1; i++)
                          {
                                SkipAheadNavigation v=SkipAheadAreaCache[i];
                                if (Position.Distance2D(v.Position)<=v.Radius)
                                {
                                     validIndex=i;
                                     valid=true;
                                     break;
                                }
                          }
                          if (valid&&validIndex>0)
                          {
                                UsedSkipAheadAreaCache.Add(SkipAheadAreaCache[validIndex].Clone());
                                SkipAheadAreaCache.RemoveRange(0, validIndex-1);
                                SkipAheadAreaCache.TrimExcess();
                          }
                     }
                     return valid;
        }
开发者ID:NEVEROYATNII,项目名称:Funky,代码行数:31,代码来源:MovementSkipAhead.cs

示例2: MoveTo

        public static async Task<bool> MoveTo(Vector3 location, string destinationName, float range = 10f)
        {
            while (ZetaDia.Me.IsFullyValid() && !ZetaDia.Me.IsInCombat && location.Distance2D(ZetaDia.Me.Position) > range)
            {
                Logger.LogVerbose("Moving to " + destinationName);
                PlayerMover.NavigateTo(location, destinationName);
                await Coroutine.Yield();
            }
            if (location.Distance2D(ZetaDia.Me.Position) <= range)
                Navigator.PlayerMover.MoveStop();

            return true;
        }
开发者ID:MGramolini,项目名称:Trinity,代码行数:13,代码来源:TrinityCoroutines.cs

示例3: GetNeededPoinits

        public static Point[] GetNeededPoinits(
            Vector3 startPosition,
            Vector3 endPosition,
            float startWidth,
            float endWidth = 0)
        {
            if (endWidth <= 0)
            {
                endWidth = startWidth;
            }

            endPosition = startPosition.Extend(endPosition, startPosition.Distance2D(endPosition) + endWidth / 2);

            var difference = startPosition - endPosition;
            var rotation = difference.Rotated(MathUtil.DegreesToRadians(90));
            rotation.Normalize();

            var start = rotation * startWidth;
            var end = rotation * endWidth;

            var rightStartPosition = startPosition + start;
            var leftStartPosition = startPosition - start;
            var rightEndPosition = endPosition + end;
            var leftEndPosition = endPosition - end;

            /*Vector2 leftStart, rightStart, leftEnd, rightEnd;
            Drawing.WorldToScreen(leftStartPosition, out leftStart);
            Drawing.WorldToScreen(rightStartPosition, out rightStart);
            Drawing.WorldToScreen(leftEndPosition, out leftEnd);
            Drawing.WorldToScreen(rightEndPosition, out rightEnd);

            Drawing.DrawLine(leftStart, rightStart, Color.Orange);
            Drawing.DrawLine(rightStart, rightEnd, Color.Orange);
            Drawing.DrawLine(rightEnd, leftEnd, Color.Orange);
            Drawing.DrawLine(leftEnd, leftStart, Color.Orange);*/

            var p1 = new Point((int) rightStartPosition.X, (int) rightStartPosition.Y);
            var p2 = new Point((int) leftStartPosition.X, (int) leftStartPosition.Y);
            var p3 = new Point((int) rightEndPosition.X, (int) rightEndPosition.Y);
            var p4 = new Point((int) leftEndPosition.X, (int) leftEndPosition.Y);
            return new[] {p1, p2, p4, p3};
        }
开发者ID:JumpAttacker,项目名称:EnsageSharp,代码行数:42,代码来源:Helper.cs

示例4: CancelHook

        public void CancelHook(object s, ElapsedEventArgs args)
        {
            e = Toolset.ClosestToMouse(me);
            if (e == null) return;
            if (e.HasModifier("modifier_spirit_breaker_charge_of_darkness")) return;

            double travelTime = HookPosition.Distance2D(me.Position) / 1600;
            Vector3 ePosition = new Vector3((float)((travelTime) * Math.Cos(e.RotationRad) * e.MovementSpeed + e.NetworkPosition.X),
                                           (float)((travelTime) * Math.Sin(e.RotationRad) * e.MovementSpeed + e.NetworkPosition.Y), 0);
            if (e != null && e.NetworkActivity == NetworkActivity.Move && ePosition.Distance2D(HookPosition) > minRangeHook + Menu.Item("x").GetValue<Slider>().Value)
            {
                me.Stop();
                time.Stop();
            }
            else
            {
                if (Q!=null)
                    time.Stop();
            }
        }
开发者ID:VickTheRock,项目名称:ReworkAllScripts,代码行数:20,代码来源:PudgeController.cs

示例5: IsPointOnLine

        private static bool IsPointOnLine(
            Vector3 point,
            Vector3 start,
            Vector3 end,
            float radius,
            bool forceRadius = true)
        {
            var endDistance = end.Distance2D(point);
            var startDistance = start.Distance2D(point);
            var distance = start.Distance2D(end);

            return Math.Abs(endDistance + startDistance - distance)
                   < (forceRadius ? radius : (end.Distance2D(start) < radius ? radius : 50));
        }
开发者ID:IdcNoob,项目名称:Ensage,代码行数:14,代码来源:TreeFactory.cs

示例6: SetUnavailableTrees

        public void SetUnavailableTrees(Vector3 start, Vector3 end, Chakram chakram)
        {
            var precision = chakram.Radius;
            var count = (int)Math.Ceiling(start.Distance2D(end) / precision);

            var ping = Game.Ping / 1000;
            var time = Game.RawGameTime;

            for (var i = 1; i <= count; i++)
            {
                var position = i == count ? end : start.Extend(end, precision * i);

                unavailableTrees.Add(
                    Tuple.Create(
                        position,
                        chakram.Radius,
                        chakram.CastPoint + ping + start.Distance2D(position) / chakram.Speed + time));
            }
        }
开发者ID:IdcNoob,项目名称:Ensage,代码行数:19,代码来源:TreeFactory.cs

示例7: TrinityIntersectsPath

        public static bool TrinityIntersectsPath(Vector3 start, Vector3 obstacle, Vector3 destination, float distanceToObstacle = -1, float distanceToDestination = -1)
        {
            var toObstacle = distanceToObstacle >= 0 ? distanceToObstacle : start.Distance2D(obstacle);
            var toDestination = distanceToDestination >= 0 ? distanceToDestination : start.Distance2D(destination);

            if (toDestination > 500)
                return false;

            var relativeAngularVariance = GetRelativeAngularVariance(start, obstacle, destination);

            // Angular Variance at 20yd distance
            const int angularVarianceBase = 45;

            // Halve/Double required angle every 20yd; 60* @ 15yd, 11.25* @ 80yd
            var angularVarianceThreshold = Math.Min(angularVarianceBase / (toDestination / 20), 90);

            //Logger.Log("DistToObj={0} DistToDest={1} relativeAV={2} AVThreshold={3} Result={4}", 
            //    toObstacle, toDestination, relativeAngularVariance, angularVarianceThreshold, 
            //    toObstacle < toDestination && relativeAngularVariance <= angularVarianceThreshold);

            if (toObstacle < toDestination)
            {
                // If the angle between lines (A) from start to obstacle and (B) from start to destination
                // are small enough then we know both targets are in the same-ish direction from start.
                if (relativeAngularVariance <= angularVarianceThreshold)
                {
                    return true;
                }                
            }
            return false;
        }
开发者ID:dachidahu,项目名称:AutoFollow,代码行数:31,代码来源:MathUtil.cs

示例8: IsPointOnLine

        private static bool IsPointOnLine(Vector3 point, Vector3 start, Vector3 end, float radius)
        {
            var endDistance = end.Distance2D(point);
            var startDistance = start.Distance2D(point);
            var distance = start.Distance2D(end);

            return Math.Abs(endDistance + startDistance - distance) < radius;
        }
开发者ID:IdcNoob,项目名称:Ensage,代码行数:8,代码来源:Predictions.cs

示例9: update_

        private void update_(Vector3 startV3)
        {
            //raycast to test how far we could go..
                     Vector3 MaxRangeTestVector3=MathEx.GetPointAt(startV3, Range, MathEx.ToRadians(DirectionDegrees));

                     Vector2 RaycastTestV2;
                     //we use main grid providers raycast to test since we are looking at how far we can travel and not if anything is blocking us.
                     if (Navigation.MGP.Raycast(startV3.ToVector2(), MaxRangeTestVector3.ToVector2(), out RaycastTestV2))
                     {//Set our endpoint at the Hit point
                          MaxRangeTestVector3=RaycastTestV2.ToVector3();
                          MaxRangeTestVector3.Z=Navigation.MGP.GetHeight(MaxRangeTestVector3.ToVector2()); //adjust height acordingly!
                     }
                     Range=Vector3.Distance2D(ref startV3, ref MaxRangeTestVector3);

                     //lets see if we can stand here at all?
                     if (!Navigation.MGP.CanStandAt(MaxRangeTestVector3))
                     {

                          //just because raycast set our max range, we need to see if we can use that cell as a walking point!
                          if (!Navigation.CanRayCast(startV3, MaxRangeTestVector3, Zeta.Internals.SNO.NavCellFlags.AllowWalk))
                          {
                                //loop to find a walkable range.
                                float currentRange=Range-2.5f;
                                float directionRadianFlipped=Navigation.FindDirection(MaxRangeTestVector3, startV3, true);
                                int maxTestAttempts=(int)(currentRange/2.5f);

                                for (int i=0; i<maxTestAttempts; i++)
                                {
                                     Vector3 newtestPoint=MathEx.GetPointAt(MaxRangeTestVector3, currentRange, directionRadianFlipped);
                                     newtestPoint.Z=Navigation.MGP.GetHeight(newtestPoint.ToVector2());//update Z
                                     if (Navigation.CanRayCast(startV3, newtestPoint, Zeta.Internals.SNO.NavCellFlags.AllowWalk))
                                     {
                                          MaxRangeTestVector3=newtestPoint;
                                          break;
                                     }

                                     if (currentRange-2.5f<=0f) break;
                                     currentRange=-2.5f;
                                }
                                Range=currentRange;
                          }

                     }

                     EndingPoint=MaxRangeTestVector3;
                     StartingPoint=startV3;
                     Range=startV3.Distance2D(MaxRangeTestVector3); //(float)GridPoint.GetDistanceBetweenPoints(StartingPoint, EndingPoint);
                     Center=MathEx.GetPointAt(startV3, Range/2, MathEx.ToRadians(DirectionDegrees));
        }
开发者ID:NEVEROYATNII,项目名称:Funky,代码行数:49,代码来源:DirectionPoint.cs

示例10: FindZigZagTargetLocation


//.........这里部分代码省略.........

                     float fHighestWeight=float.NegativeInfinity;
                     Vector3 vBestLocation=Vector3.Zero;

                     bool bFoundSafeSpotsFirstLoop=false;
                     float fAdditionalRange=0f;
                     //K: Direction is more important than distance

                     for (int iMultiplier=1; iMultiplier<=2; iMultiplier++)
                     {
                          if (iMultiplier==2)
                          {
                                if (bFoundSafeSpotsFirstLoop)
                                     break;
                                fAdditionalRange=150f;
                                if (bRandomizeStart)
                                     iFakeStart=30f+(rndNum.Next(16)*5);
                                else
                                     iFakeStart=(rndNum.Next(17)*5);
                          }
                          float fRunDistance=fDistanceOutreach;
                          for (float iDegreeChange=iFakeStart; iDegreeChange<=30f+fAdditionalRange; iDegreeChange+=5)
                          {
                                float iPosition=iDegreeChange;
                                //point to target is better, otherwise we have to avoid obstacle first
                                if (iPosition>105f)
                                     iPosition=90f-iPosition;
                                else if (iPosition>30f)
                                     iPosition-=15f;
                                else
                                     iPosition=15f-iPosition;
                                fPointToTarget=iPosition;

                                iPosition+=fDirectionToTarget;
                                if (iPosition<0)
                                     iPosition=360f+iPosition;
                                if (iPosition>=360f)
                                     iPosition=iPosition-360f;

                                vThisZigZag=MathEx.GetPointAt(Bot.Character.Position, fRunDistance, MathEx.ToRadians(iPosition));

                                if (fPointToTarget<=30f||fPointToTarget>=330f)
                                {
                                     vThisZigZag.Z=vTargetLocation.Z;
                                }
                                else if (fPointToTarget<=60f||fPointToTarget>=300f)
                                {
                                     //K: we are trying to find position that we can circle around the target
                                     //   but we shouldn't run too far away from target
                                     vThisZigZag.Z=(vTargetLocation.Z+Bot.Character.Position.Z)/2;
                                     fRunDistance=fDistanceOutreach-5f;
                                }
                                else
                                {
                                     //K: don't move too far if we are not point to target, we just try to move
                                     //   this can help a lot when we are near stairs
                                     fRunDistance=8f;
                                }

                                bCanRayCast=MGP.CanStandAt(vThisZigZag);

                                // Give weight to each zigzag point, so we can find the best one to aim for
                                if (bCanRayCast)
                                {
                                     bool bAnyAvoidance=false;

                                     // Starting weight is 1000f
                                     float fThisWeight=1000f;
                                     if (iMultiplier==2)
                                          fThisWeight-=80f;

                                     if (Bot.Character.ShouldFlee&&ObjectCache.Objects.IsPointNearbyMonsters(vThisZigZag, Bot.SettingsFunky.FleeMaxMonsterDistance))
                                          continue;

                                     if (ObjectCache.Obstacles.Navigations.Any(obj => obj.Obstacletype.Value!=ObstacleType.Monster&&obj.TestIntersection(Bot.Character.Position, vThisZigZag, false)))
                                          continue;

                                     float distanceToPoint=vThisZigZag.Distance2D(Bot.Character.Position);
                                     float distanceToTarget=vTargetLocation.Distance2D(Bot.Character.Position);

                                     fThisWeight+=(distanceToTarget*10f);

                                     // Use this one if it's more weight, or we haven't even found one yet, or if same weight as another with a random chance
                                     if (fThisWeight>fHighestWeight)
                                     {
                                          fHighestWeight=fThisWeight;

                                          vBestLocation=new Vector3(vThisZigZag.X, vThisZigZag.Y, MGP.GetHeight(vThisZigZag.ToVector2()));

                                          if (!bAnyAvoidance)
                                                bFoundSafeSpotsFirstLoop=true;
                                     }
                                }
                                // Can we raycast to the point at minimum?
                          }
                          // Loop through degrees
                     }
                     // Loop through multiplier
                     return vBestLocation;
        }
开发者ID:NEVEROYATNII,项目名称:Funky,代码行数:101,代码来源:Navigation.cs

示例11: Tick

        public static void Tick(EventArgs args)
        {
            if (!Game.IsInGame || Game.IsPaused || Game.IsWatchingGame)
                return;
            me = ObjectMgr.LocalHero;
            if (me == null)
                return;
            if (me.ClassID != ClassID.CDOTA_Unit_Hero_EarthSpirit)
                return;


            //SKILLS
            
            if (Qskill == null)
                Qskill = me.Spellbook.SpellQ;
            if (Wskill == null)
                Wskill = me.Spellbook.SpellW;
            if (Eskill == null)
                Eskill = me.Spellbook.SpellE;
            if (DRemnant == null)
                DRemnant = me.Spellbook.SpellD;
            if (Rskill == null)
                Rskill = me.Spellbook.SpellR;
            if (Fskill == null)
                Fskill = me.Spellbook.SpellF;

            // UNIT VARIABLES

            stone_for_combo = ObjectMgr.GetEntities<Unit>().Where(x => x.ClassID == ClassID.CDOTA_Unit_Earth_Spirit_Stone && me.Distance2D(x.NetworkPosition) < 200).FirstOrDefault();
            stone = ObjectMgr.GetEntities<Unit>().Where(x => x.ClassID == ClassID.CDOTA_Unit_Earth_Spirit_Stone && x.NetworkPosition.Distance2D(me.NetworkPosition) <= 1300).ToList();
            if (boulder_slow == null || stage_combo4 == 0)
                boulder_slow = ObjectMgr.GetEntities<Hero>().Where(x => x.Team != me.Team && x.IsVisible && !x.IsIllusion && x.NetworkPosition.Distance2D(me.NetworkPosition) < 200 && x.Modifiers.Any(y => y.Name == "modifier_earth_spirit_rolling_boulder_slow")).FirstOrDefault();
            if (stage == 2 && stunned == null)
                stunned = ObjectMgr.GetEntities<Hero>().Where(x => x.Modifiers.Any(y => y.Name == "modifier_stunned") && !x.IsIllusion && x.Team != me.Team && x.IsVisible).FirstOrDefault();

            //KEYS TOGGLE

            if ((Game.IsKeyDown(_hotkeys_config.Item("hotkeycombo1").GetValue<KeyBind>().Key)) && !Game.IsChatOpen && stunned == null)
                key_active = true;
            if ((Game.IsKeyDown(_hotkeys_config.Item("hotkeycombo3").GetValue<KeyBind>().Key)) && !Game.IsChatOpen)
                key_active_2 = true;
            if ((Game.IsKeyDown(_hotkeys_config.Item("hotkeycombo5").GetValue<KeyBind>().Key)) && !Game.IsChatOpen)
                key_active_4 = true;

            if (key_active == false)
            { stage = 0; key_active = false; stunned = null; }

            if (me.CanCast() && !me.IsChanneling() && key_active)
            {
                Mouse_Position = Game.MousePosition;
                if ((!Eskill.CanBeCasted() && !Qskill.CanBeCasted() && !Wskill.CanBeCasted() && (!DRemnant.CanBeCasted() && stone_for_combo == null) || ((!DRemnant.CanBeCasted() && stone_for_combo == null))) || (Game.IsKeyDown(_hotkeys_config.Item("hotkeycombo2").GetValue<KeyBind>().Key)))
                {
                    if (auto_atack_after_spell)
                    {
                        Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 1");
                        auto_atack_after_spell = false;
                    }
                    if (auto_atack)
                    {
                        Game.ExecuteCommand("dota_player_units_auto_attack 1");
                        auto_atack = false;
                    }
                    key_active = false;
                    stage = 0;
                    stunned = null;
                }
                if (stage == 0 && Utils.SleepCheck("auto_atack_change"))
                {
                    if (Game.GetConsoleVar("dota_player_units_auto_attack_after_spell").GetInt() == 1)
                    {
                        Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
                        auto_atack_after_spell = true;
                    }
                    else
                        auto_atack_after_spell = false;
                    if (Game.GetConsoleVar("dota_player_units_auto_attack").GetInt() == 1)
                    {
                        Game.ExecuteCommand("dota_player_units_auto_attack 0");
                        auto_atack = true;
                    }
                    else
                        auto_atack = false;
                    stage = 1;
                    Utils.Sleep(Game.Ping, "auto_atack_change");

                }
                else if (stage == 1 && Utils.SleepCheck("Qskill") && Utils.SleepCheck("auto_atack_change"))
                {
                    if (DRemnant.CanBeCasted() && Utils.SleepCheck("DRemnant") && stone_for_combo == null && (Qskill.CanBeCasted() && Wskill.CanBeCasted() && Eskill.CanBeCasted()))
                    {
                        DRemnant.UseAbility(me.NetworkPosition);
                        Utils.Sleep(500 - (int)Game.Ping, "DRemnant");
                    }
                    if (Qskill.CanBeCasted())
                    {
                        Qskill.UseAbility((Mouse_Position - me.NetworkPosition) * 200 / Mouse_Position.Distance2D(me) + me.NetworkPosition);
                        Utils.Sleep((int)Game.Ping + 50, "Qskill");
                    }
                    else
                        stage = 2;
//.........这里部分代码省略.........
开发者ID:jaddyknight,项目名称:EnsageSharp,代码行数:101,代码来源:ES_NINJA.cs

示例12: OnStart

        public override void OnStart()
        {
            _lastMoveResult = MoveResult.Moved;

            float x = MyPos.X + OffsetX;
            float y = MyPos.Y + OffsetY;

            Position = new Vector3(x, y, MainGridProvider.GetHeight(new Vector2(x, y)));

            if (Math.Abs(PathPrecision) < 1f)
                PathPrecision = 10f;
            Logger.Log("OffsetMove Initialized offset x={0} y={1} distance={2:0} position={3}", OffsetX, OffsetY, Position.Distance2D(MyPos), Position);

        }
开发者ID:mythsya,项目名称:db-plugins,代码行数:14,代码来源:OffsetMoveTag.cs

示例13: NavigateMove

        private MoveResult NavigateMove(Vector3 destination, string name = "", bool raycast = true)
        {
            try
            {
                if (lastDestination != destination)
                {
                    lastDestination = destination;
                    //Navigator.Clear();
                }
                const float pathPointLimit = 250;
                if (!ZetaDia.IsInTown && destination.Distance2D(Me.Position) > pathPointLimit)
                    destination = MathEx.CalculatePointFrom(Me.Position, destination, destination.Distance2D(Me.Position) - pathPointLimit);

                if (string.IsNullOrEmpty(name))
                {
                    name = destination.ToString();
                }
                //Logr.Debug(("Moving to {0}, distance: {1:0}", name, destination.Distance2D(ZetaDia.Me.Position));

                return NavHelper.NavigateTo(destination, name);
            }
            catch (Exception ex)
            {
                Logr.Log("DB Navigation Exception: {0}", ex);
                GridSegmentation.Reset();
                Navigator.Clear();

                return MoveResult.Failed;
            }
        }
开发者ID:mythsya,项目名称:db-plugins,代码行数:30,代码来源:FollowTag.cs

示例14: NavigateTo

            internal static MoveResult NavigateTo(Vector3 moveTarget, string destinationName="")
            {
                Vector3 MyPos=ZetaDia.Me.Position;

                     float distanceToTarget=moveTarget.Distance2D(ZetaDia.Me.Position);

                     bool MoveTargetIsInLoS=distanceToTarget<=90f&&!Navigator.Raycast(MyPos, moveTarget);

                     if (distanceToTarget<=5f||MoveTargetIsInLoS)
                     {
                          //Special cache for skipping locations visited.
                          if (Bot.SettingsFunky.SkipAhead)
                                SkipAheadCache.RecordSkipAheadCachePoint();

                          Navigator.PlayerMover.MoveTowards(moveTarget);
                          return MoveResult.Moved;
                     }

                     return Navigator.MoveTo(moveTarget, destinationName, true);
            }
开发者ID:NEVEROYATNII,项目名称:Funky,代码行数:20,代码来源:PlayerMover.cs

示例15: GetClosest

 private static void GetClosest(ref Vector3 returnPoint, Hero me,Dictionary<int,Vector3> points)
 {
     for (var i = 0; i <= 8; i++)
     {
         Vector3 vec;
         if (!points.TryGetValue(i, out vec)) continue;
         if (!returnPoint.IsZero)
         {
             if (_nearestPoint)
             {
                 if (vec.Distance2D(me) <= returnPoint.Distance2D(me))
                     returnPoint = vec;
             }
             else
             {
                 if (vec.Distance2D(_globalTarget) <= returnPoint.Distance2D(_globalTarget))
                     returnPoint = vec;
             }
         }
         else
         {
             returnPoint = vec;
         }
     }
 }
开发者ID:dendimonster,项目名称:EnsageSharp-1,代码行数:25,代码来源:Program.cs


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