コード例 #1
0
ファイル: RadarCanvas.cs プロジェクト: shmilyzxt/db-plugins
 private Brush GetNavCellBrush(NavCellFlags flags)
 {
     if (flags.HasFlag(NavCellFlags.AllowWalk))
     {
         return(new SolidColorBrush(Colors.NavajoWhite)
         {
             Opacity = 0.2
         });
     }
     if (flags.HasFlag(NavCellFlags.AllowProjectile))
     {
         return(new SolidColorBrush(Colors.DarkGray)
         {
             Opacity = 0.2
         });
     }
     if (flags.HasFlag(NavCellFlags.RoundedCorner0) || flags.HasFlag(NavCellFlags.RoundedCorner1) || flags.HasFlag(NavCellFlags.RoundedCorner2) || flags.HasFlag(NavCellFlags.RoundedCorner3))
     {
         return(new SolidColorBrush(Colors.DarkGreen)
         {
             Opacity = 0.2
         });
     }
     return(new SolidColorBrush(Colors.Black));
 }
コード例 #2
0
        public WorldSceneCell(NavCell navCell, Vector2 zoneMin)
        {
            MinX         = zoneMin.X + navCell.Min.X;
            MinY         = zoneMin.Y + navCell.Min.Y;
            MaxX         = zoneMin.X + navCell.Max.X;
            MaxY         = zoneMin.Y + navCell.Max.Y;
            NavCellFlags = navCell.Flags;
            IsWalkable   = NavCellFlags.HasFlag(NavCellFlags.AllowWalk);

            Z = Math.Max(navCell.Min.Z, navCell.Max.Z);
        }
コード例 #3
0
        public WorldSceneCell(NavCell navCell, Vector2 zoneMin)
        {
            MinX         = zoneMin.X + navCell.Min.X;
            MinY         = zoneMin.Y + navCell.Min.Y;
            MaxX         = zoneMin.X + navCell.Max.X;
            MaxY         = zoneMin.Y + navCell.Max.Y;
            NavCellFlags = navCell.Flags;
            IsWalkable   = NavCellFlags.HasFlag(NavCellFlags.AllowWalk);

            Z = navCell.Min.Z;
            if (Z < 0.1f)
            {
                Z = 0;
            }
        }
コード例 #4
0
ファイル: LOSInfo.cs プロジェクト: herbfunk/Funky
        ///<summary>
        ///Runs raycasting and intersection tests to validate LOS.
        ///</summary>
        public bool LOSTest(Vector3 PositionToTestFrom, Vector3 objposition, bool NavRayCast = true, bool searchGridRayCast = false, bool ServerObjectIntersection = true, NavCellFlags Flags = NavCellFlags.None, bool ContinueOnFailures = true)
        {
            LastLOSCheck=DateTime.Now;
              bool Failed=false;

              if (NavRayCast)
              {//This is a basic raycast test to see if we have clear view of the object.

                    if (PositionToTestFrom.Z > objposition.Z)
                        RayCast = Navigation.Navigation.CanRayCast(PositionToTestFrom, objposition);
                    else
                        RayCast = Navigation.Navigation.CanRayCast(objposition, PositionToTestFrom);

                    if (!RayCast.Value)
                    {
                         Failed=true;
                         if (!ContinueOnFailures) return false;
                    }

              }

             if (searchGridRayCast)
             {
                 Vector2 hitpos;

                 //Must check the Z difference.. (so we don't get false-positive result)
                 if (PositionToTestFrom.Z > objposition.Z)
                     SearchGridRayCast = !Navigator.SearchGridProvider.Raycast(PositionToTestFrom.ToVector2(), objposition.ToVector2(), out hitpos);
                 else
                     SearchGridRayCast = !Navigator.SearchGridProvider.Raycast(objposition.ToVector2(), PositionToTestFrom.ToVector2(), out hitpos);

                 if (!SearchGridRayCast.Value)
                 {
                     Failed = true;
                     if (!ContinueOnFailures) return false;
                 }
             }

              if (ServerObjectIntersection)
              {//This test uses the obstacle cache to check objects for intersection

                    if (FunkyBaseExtension.Difference(FunkyGame.Hero.Position.Z, objposition.Z) > 1f)
                    {
                        //Get actual height using MGP
                        objposition.Z = Navigation.Navigation.MGP.GetHeight(objposition.ToVector2());
                    }

                    ObjectIntersection=ObjectCache.Obstacles.Values.OfType<CacheServerObject>()
                         .Any(obstacle =>
                              obstacle.RAGUID!=Obj.RAGUID&&
                              obstacle.Obstacletype.HasValue&&
                              obstacle.Obstacletype.Value==ObstacleType.ServerObject &&
                              obstacle.TestIntersection(PositionToTestFrom, objposition,false));

                    if (!Failed&&ObjectIntersection.Value)
                    {
                         Failed=true;
                         if (!ContinueOnFailures) return false;
                    }
              }

              if (!Flags.Equals(NavCellFlags.None))
              {//Raycast test to validate it can preform the path -- walk/projectile
                  bool NavTest = Navigation.Navigation.CanRayCast(PositionToTestFrom, objposition, Flags);

                    if (Flags.HasFlag(NavCellFlags.AllowWalk)) NavCellWalk=NavTest;
                    if (Flags.HasFlag(NavCellFlags.AllowProjectile)) NavCellProjectile=NavTest;
                    if (!Failed&&!NavTest)
                    {
                         Failed=true;
                    }
              }

              //this.LastVectorTested=PositionToTestFrom;
              return !Failed;
        }
コード例 #5
0
ファイル: LOSInfo.cs プロジェクト: BUFORD/Funky
        ///<summary>
        ///Runs raycasting and intersection tests to validate LOS.
        ///</summary>
        public bool LOSTest(Vector3 PositionToTestFrom, bool NavRayCast = true, bool ServerObjectIntersection = true, NavCellFlags Flags = NavCellFlags.None, bool ContinueOnFailures = true)
        {
            LastLOSCheck = DateTime.Now;
            bool Failed = false;


            if (NavRayCast)
            {              //This is a basic raycast test to see if we have clear view of the object.
                //Navigator.SearchGridProvider.Update();
                Vector2 hitpos;
                Vector3 ObjectPosition = Obj.Position;

                //Must check the Z difference.. (so we don't get false-positive result)
                if (PositionToTestFrom.Z >= ObjectPosition.Z)
                {
                    RayCast = !Navigator.SearchGridProvider.Raycast(PositionToTestFrom.ToVector2(), ObjectPosition.ToVector2(), out hitpos);
                }
                else
                {
                    RayCast = !Navigator.SearchGridProvider.Raycast(ObjectPosition.ToVector2(), PositionToTestFrom.ToVector2(), out hitpos);
                }

                if (!RayCast.Value)
                {
                    Failed = true;
                    if (!ContinueOnFailures)
                    {
                        return(false);
                    }
                }
            }

            if (ServerObjectIntersection)
            {              //This test uses the obstacle cache to check objects for intersection
                Vector3 TargetTestLocation = Obj.Position;
                if (Funky.Difference(Bot.Character.Data.Position.Z, TargetTestLocation.Z) > 1f)
                {
                    //Get actual height using MGP
                    TargetTestLocation.Z = Navigation.MGP.GetHeight(TargetTestLocation.ToVector2());
                }

                ObjectIntersection = ObjectCache.Obstacles.Values.OfType <CacheServerObject>()
                                     .Any(obstacle =>
                                          obstacle.RAGUID != Obj.RAGUID &&
                                          obstacle.Obstacletype.HasValue &&
                                          obstacle.Obstacletype.Value != ObstacleType.Monster &&
                                          obstacle.TestIntersection(PositionToTestFrom, TargetTestLocation));

                if (!Failed && ObjectIntersection.Value)
                {
                    Failed = true;
                    if (!ContinueOnFailures)
                    {
                        return(false);
                    }
                }
            }


            if (!Flags.Equals(NavCellFlags.None))
            {              //Raycast test to validate it can preform the path -- walk/projectile
                bool NavTest = Navigation.CanRayCast(PositionToTestFrom, Obj.Position, Flags);

                if (Flags.HasFlag(NavCellFlags.AllowWalk))
                {
                    NavCellWalk = NavTest;
                }
                if (Flags.HasFlag(NavCellFlags.AllowProjectile))
                {
                    NavCellProjectile = NavTest;
                }
                if (!Failed && !NavTest)
                {
                    Failed = true;
                }
            }

            //this.LastVectorTested=PositionToTestFrom;
            return(!Failed);
        }
コード例 #6
0
ファイル: RadarCanvas.cs プロジェクト: mythsya/db-plugins
 private Brush GetNavCellBrush(NavCellFlags flags)
 {
     if (flags.HasFlag(NavCellFlags.AllowWalk))
     {
         return new SolidColorBrush(Colors.NavajoWhite) { Opacity = 0.2 };
     }
     if (flags.HasFlag(NavCellFlags.AllowProjectile))
     {
         return new SolidColorBrush(Colors.DarkGray) { Opacity = 0.2 };
     }
     if (flags.HasFlag(NavCellFlags.RoundedCorner0) || flags.HasFlag(NavCellFlags.RoundedCorner1) || flags.HasFlag(NavCellFlags.RoundedCorner2) || flags.HasFlag(NavCellFlags.RoundedCorner3))
     {
         return new SolidColorBrush(Colors.DarkGreen) { Opacity = 0.2 };
     }
     return new SolidColorBrush(Colors.Black);
 }