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


C# WoWPoint.RayCast方法代码示例

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


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

示例1: FindLocationOriginal

        /// <summary>
        /// locates safe point away from enemies
        /// </summary>
        /// <param name="ptOrigin">start point for search</param>
        /// <param name="minSafeDist">min distance to be safe</param>
        /// <returns></returns>
        public WoWPoint FindLocationOriginal(WoWPoint ptOrigin)
        {
            WoWPoint destinationLocation = new WoWPoint();
            List<WoWPoint> mobLocations = new List<WoWPoint>();
            int arcIncrement = 360 / RaysToCheck;

            mobLocations = AllEnemyMobLocations;

            double minSafeDistSqr = MinSafeDistance * MinSafeDistance;

            double degreesFacing = (Me.RenderFacing * 180f) / Math.PI;
            // Logger.WriteDebug( Color.Cyan, "Facing {0:F0}d {1:F2}r Searching for {2:F1} yard mob free area", degreesFacing, Me.RenderFacing, MinSafeDistance);
            for (int arcIndex = 0; arcIndex < RaysToCheck ; arcIndex++)
            {
                float degreesFrom = 180;
                if ((arcIndex & 1) == 0)
                    degreesFrom += (arcIndex >> 1) * arcIncrement;
                else
                    degreesFrom -= (arcIndex >> 1) * arcIncrement;

                for (float distFromOrigin = MinScanDistance; distFromOrigin <= MaxScanDistance ; distFromOrigin += IncrementScanDistance )
                {
                    float heading = (float)(degreesFrom * Math.PI / 180f);
                    heading -= Me.RenderFacing;
                    destinationLocation = ptOrigin.RayCast((float)(degreesFrom * Math.PI / 180f), distFromOrigin);
                    double mobDistSqr = destinationLocation.Distance2DSqr(NearestMobLoc(destinationLocation, mobLocations));

                    if (mobDistSqr <= minSafeDistSqr)
                        continue;

                    //if (Navigator.CanNavigateFully(Me.Location, destinationLocation))
                    if (Navigator.GeneratePath(Me.Location, destinationLocation).Length <= 0)
                    {
                        // Logger.WriteDebug( Color.Cyan, "Mob-free location failed path check for degrees={0:F1} dist={1:F1}", degreesFrom, distFromOrigin);
                        continue;
                    }

                    if (!Styx.WoWInternals.World.GameWorld.IsInLineOfSight(Me.Location, destinationLocation))
                    {
                        // Logger.WriteDebug( Color.Cyan, "Mob-free location failed line of sight check for degrees={0:F1} dist={1:F1}", degreesFrom, distFromOrigin);
                        continue;
                    }

                    if (MobToRunFrom != null)
                    {
                        if (!Styx.WoWInternals.World.GameWorld.IsInLineOfSpellSight(destinationLocation, MobToRunFrom.Location))
                        {
                            // Logger.WriteDebug( Color.Cyan, "Mob-free location failed line of sight check for degrees={0:F1} dist={1:F1}", degreesFrom, distFromOrigin);
                            continue;
                        }
                    }

                    Logger.WriteDebug(Color.Cyan, "Found mob-free location ({0:F1} yd radius) at degrees={1:F1} dist={2:F1}", MinSafeDistance, degreesFrom, distFromOrigin);
                    return destinationLocation;
                }
            }

            Logger.WriteDebug(Color.Cyan, "No mob-free location ({0:F1} yd radius) found within {1:F1} yds", MinSafeDistance, MaxScanDistance );
            return WoWPoint.Empty;
        }
开发者ID:Asphodan,项目名称:Alphabuddy,代码行数:66,代码来源:Kite.cs

示例2: FindLocation

        public WoWPoint FindLocation(WoWPoint ptOrigin)
        {
            DateTime startFind = DateTime.Now;
            int countPointsChecked = 0;
            int countFailToPointNav = 0;
            int countFailRange = 0;
            int countFailSafe = 0;
            int countFailToPointLoS = 0;
            int countFailToMobLoS = 0;
            double furthestNearMobDistSqr = 0f;
            WoWPoint ptFurthest = WoWPoint.Empty;
            bool reallyCheckRangeToLineOfSightMob = CheckRangeToLineOfSightMob && Me.GotTarget;
            WoWPoint ptAdjOrigin = ptOrigin;
            ptAdjOrigin.Z += 1f;

            WoWPoint ptDestination = new WoWPoint();
            List<WoWPoint> mobLocations = new List<WoWPoint>();
            float arcIncrement = ((float)Math.PI * 2) / RaysToCheck;

            mobLocations = AllEnemyMobLocationsToCheck;
            double minSafeDistSqr = MinSafeDistance * MinSafeDistance;

            float baseDestinationFacing = MobToRunFrom == null ?
                                            Me.RenderFacing + (float)Math.PI
                                            : Styx.Helpers.WoWMathHelper.CalculateNeededFacing(MobToRunFrom.Location, Me.Location);

            // Logger.WriteDebug( Color.Cyan, "SafeArea: search near {0:F0}d @ {1:F1} yds for mob free area", RadiansToDegrees(baseDestinationFacing), MinSafeDistance);

            for (int arcIndex = 0; arcIndex < RaysToCheck; arcIndex++)
            {
                // rather than tracing around the circle, toggle between clockwise and counter clockwise for each test
                // .. so we favor a position furthest away from mob
                float checkFacing = baseDestinationFacing;
                if ((arcIndex & 1) == 0)
                    checkFacing += arcIncrement * (arcIndex >> 1);
                else
                    checkFacing -= arcIncrement * ((arcIndex >> 1) + 1);

                for (float distFromOrigin = MinScanDistance; distFromOrigin <= MaxScanDistance; distFromOrigin += IncrementScanDistance)
                {
                    countPointsChecked++;

                    ptDestination = ptOrigin.RayCast(checkFacing, distFromOrigin);
                    if (!Navigator.CanNavigateFully(Me.Location, ptDestination))
                    {
                        // Logger.WriteDebug( Color.Cyan, "Safe Location failed navigation check for degrees={0:F1} dist={1:F1}", RadiansToDegrees(checkFacing), distFromOrigin);
                        countFailToPointNav++;
                        continue;
                    }

                    WoWPoint ptNearest = NearestMobLoc(ptDestination, mobLocations);
                    if (ptNearest == WoWPoint.Empty)
                    {
                        if (furthestNearMobDistSqr < minSafeDistSqr)
                        {
                            furthestNearMobDistSqr = minSafeDistSqr;
                            ptFurthest = ptDestination;     // set best available if others fail
                        }
                    }
                    else
                    {
                        double mobDistSqr = ptDestination.Distance2DSqr(ptNearest);
                        if (furthestNearMobDistSqr < mobDistSqr)
                        {
                            furthestNearMobDistSqr = mobDistSqr;
                            ptFurthest = ptDestination;     // set best available if others fail
                        }
                        if (mobDistSqr <= minSafeDistSqr)
                        {
                            countFailSafe++;
                            continue;
                        }
                    }

                    if (reallyCheckRangeToLineOfSightMob && RangeToLineOfSightMob < ptDestination.Distance(LineOfSightMob.Location) - LineOfSightMob.MeleeDistance())
                    {
                        countFailRange++;
                        continue;
                    }

                    if (CheckLineOfSightToSafeLocation)
                    {
                        WoWPoint ptAdjDest = ptDestination;
                        ptAdjDest.Z += 1f;
                        if (!Styx.WoWInternals.World.GameWorld.IsInLineOfSight(ptAdjOrigin, ptAdjDest))
                        {
                            // Logger.WriteDebug( Color.Cyan, "Mob-free location failed line of sight check for degrees={0:F1} dist={1:F1}", degreesFrom, distFromOrigin);
                            countFailToPointLoS++;
                            continue;
                        }
                    }

                    if (CheckSpellLineOfSightToMob && LineOfSightMob != null)
                    {
                        if (!Styx.WoWInternals.World.GameWorld.IsInLineOfSpellSight(ptDestination, LineOfSightMob.Location))
                        {
                            if (!Styx.WoWInternals.World.GameWorld.IsInLineOfSight(ptDestination, LineOfSightMob.Location))
                            {
                                // Logger.WriteDebug( Color.Cyan, "Mob-free location failed line of sight check for degrees={0:F1} dist={1:F1}", degreesFrom, distFromOrigin);
                                countFailToMobLoS++;
//.........这里部分代码省略.........
开发者ID:Asphodan,项目名称:Alphabuddy,代码行数:101,代码来源:Kite.cs

示例3: FindLocation

        public WoWPoint FindLocation(WoWPoint ptOrigin)
        {
            DateTime startFind = DateTime.UtcNow;
            int countPointsChecked = 0;
            int countFailDiff = 0;
            int countFailTrace = 0;
            int countFailToPointNav = 0;
            int countFailRange = 0;
            int countFailSafe = 0;
            int countFailToPointLoS = 0;
            int countFailToMobLoS = 0;
            TimeSpan spanTrace = TimeSpan.Zero;
            TimeSpan spanNav = TimeSpan.Zero;
            double furthestNearMobDistSqr = 0f;
            WoWPoint ptFurthest = WoWPoint.Empty;
            float facingFurthest = 0f;

            bool reallyCheckRangeToLineOfSightMob = CheckRangeToLineOfSightMob && Me.GotTarget();
            WoWPoint ptAdjOrigin = ptOrigin;
            // ptAdjOrigin.Z += 1f;   // comment out origin adjustment since using GetTraceLinePos()

            WoWPoint ptDestination = new WoWPoint();
            List<WoWPoint> mobLocations = new List<WoWPoint>();
            float arcIncrement = ((float)Math.PI * 2) / RaysToCheck;

            mobLocations = AllEnemyMobLocationsToCheck;
            double minSafeDistSqr = MinSafeDistance * MinSafeDistance;

            #if OLD_WAY
            float baseDestinationFacing = MobToRunFrom == null ?
                                            Me.RenderFacing + (float)Math.PI
                                            : Styx.Helpers.WoWMathHelper.CalculateNeededFacing(MobToRunFrom.Location, Me.Location);
            #else
            float baseDestinationFacing;
            if (PreferredDirection == Disengage.Direction.None && MobToRunFrom != null)
                baseDestinationFacing = Styx.Helpers.WoWMathHelper.CalculateNeededFacing(MobToRunFrom.Location, Me.Location);
            else if (PreferredDirection == Disengage.Direction.Frontwards)
                baseDestinationFacing = Me.RenderFacing;
            else // if (PreferredDirection == Disengage.Direction.Backwards)
                baseDestinationFacing = Me.RenderFacing + (float)Math.PI;
            #endif
            Logger.WriteDebug( Color.Cyan, "SafeArea: facing {0:F0} degrees, looking for safespot towards {1:F0} degrees",
                WoWMathHelper.RadiansToDegrees(Me.RenderFacing),
                WoWMathHelper.RadiansToDegrees(baseDestinationFacing)
                );

            for (int arcIndex = 0; arcIndex < RaysToCheck; arcIndex++)
            {
                // rather than tracing around the circle, toggle between clockwise and counter clockwise for each test
                // .. so we favor a position furthest away from mob
                float checkFacing = baseDestinationFacing;
                if ((arcIndex & 1) == 0)
                    checkFacing += arcIncrement * (arcIndex >> 1);
                else
                    checkFacing -= arcIncrement * ((arcIndex >> 1) + 1);

                checkFacing = WoWMathHelper.NormalizeRadian(checkFacing);
                for (float distFromOrigin = MinScanDistance; distFromOrigin <= MaxScanDistance; distFromOrigin += IncrementScanDistance)
                {
                    countPointsChecked++;

                    ptDestination = ptOrigin.RayCast(checkFacing, distFromOrigin);

                    Logger.WriteDebug("SafeArea: checking {0:F1} degrees at {1:F1} yds", WoWMathHelper.RadiansToDegrees(checkFacing), distFromOrigin);

                    DateTime start = DateTime.UtcNow;
                    bool failTrace = Movement.MeshTraceline(Me.Location, ptDestination);
                    spanTrace += DateTime.UtcNow - start;

                    bool failNav;
                    if (DirectPathOnly)
                    {
                        failNav = failTrace;
                        spanNav = spanTrace;
                    }
                    else
                    {
                        start = DateTime.UtcNow;
                        failNav = !Navigator.CanNavigateFully(Me.Location, ptDestination);
                        spanNav += DateTime.UtcNow - start;
                    }

                    if (failTrace)
                        countFailTrace++;

                    if (failTrace != failNav)
                        countFailDiff++;

                    if (failNav)
                    {
                        // Logger.WriteDebug( Color.Cyan, "Safe Location failed navigation check for degrees={0:F1} dist={1:F1}", RadiansToDegrees(checkFacing), distFromOrigin);
                        countFailToPointNav++;
                        continue;
                    }

                    WoWPoint ptNearest = NearestMobLoc(ptDestination, mobLocations);
                    if (ptNearest == WoWPoint.Empty)
                    {
                        if (furthestNearMobDistSqr < minSafeDistSqr)
                        {
//.........这里部分代码省略.........
开发者ID:aash,项目名称:Singular,代码行数:101,代码来源:Kite.cs

示例4: getSaveLocation

        public static WoWPoint getSaveLocation(WoWPoint Location, int minDist, int maxDist, int traceStep)
        {
            Logging.WriteNavigator("{0} - Navigation: Looking for save Location around {1}.", TimeNow, Location);

            float _PIx2 = 3.14159f * 2f;

            for (int i = 0, x = minDist; i < traceStep && x < maxDist; i++)
            {
                WoWPoint p = Location.RayCast((i * _PIx2) / traceStep, x);

                p.Z = getGroundZ(p);
                WoWPoint pLoS = p;
                pLoS.Z = p.Z + 0.5f;

                if (p.Z != float.MinValue && StyxWoW.Me.Location.Distance(p) > 1)
                {
                    if (getHighestSurroundingSlope(p) < 1.2f && GameWorld.IsInLineOfSight(pLoS, Location) /*&& Navigator.CanNavigateFully(StyxWoW.Me.Location, Location)*/)
                    {
                        Logging.WriteNavigator("{0} - Navigation: Moving to {1}. Distance: {2}", TimeNow, p, Location.Distance(p));
                        return p;
                    }
                }

                if (i == (traceStep - 1))
                {
                    i = 0;
                    x++;
                }
            }
            Logging.Write(System.Drawing.Color.Red, "{0} - No valid points returned by RayCast...", TimeNow);
            return WoWPoint.Empty;
        }
开发者ID:nikolascoppi,项目名称:jwyles-scripts,代码行数:32,代码来源:CritterKillSquad_1.0.7.cs

示例5: getHighestSurroundingSlope

 /// <summary>
 /// Credits to funkescott.
 /// </summary>
 /// <returns>Highest slope of surrounding terrain, returns 100 if the slope can't be determined</returns>
 public static float getHighestSurroundingSlope(WoWPoint p)
 {
     Logging.WriteNavigator("{0} - Navigation: Sloapcheck on Point: {1}", TimeNow, p);
     float _PIx2 = 3.14159f * 2f;
     float highestSlope = -100;
     float slope = 0;
     int traceStep = 15;
     float range = 0.5f;
     WoWPoint p2;
     for (int i = 0; i < traceStep; i++)
     {
         p2 = p.RayCast((i * _PIx2) / traceStep, range);
         p2.Z = getGroundZ(p2);
         slope = Math.Abs(getSlope(p, p2));
         if (slope > highestSlope)
         {
             highestSlope = (float)slope;
         }
     }
     Logging.WriteNavigator("{0} - Navigation: Highslope {1}", TimeNow, highestSlope);
     return Math.Abs(highestSlope);
 }
开发者ID:nikolascoppi,项目名称:jwyles-scripts,代码行数:26,代码来源:CritterKillSquad_1.0.7.cs

示例6: TryGetHeight

 WoWPoint TryGetHeight(WoWPoint point, Height ht)
 {
     float PIx2 = (float)Math.PI * 2f;
     int step = 20;
     for (int d = 5; d <= 50; d += 5)
     {
         for (int i = 0; i < 20; i++)
         {
             WoWPoint newPoint = point.RayCast((i * PIx2) / step, d);
             try
             {
                 newPoint.Z = ht == Height.High ? Navigator.FindHeights(newPoint.X, newPoint.Y).Max() :
                     Navigator.FindHeights(newPoint.X, newPoint.Y).Min();
                 return newPoint;
             }
             catch { }
         }
     }
     return point;
 }
开发者ID:dartemage,项目名称:zaprecorder2,代码行数:20,代码来源:RoutesBuddy.cs


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