示例#1
0
        public GPArea(Vector3 startingLocation)
        {
            //Creation and Cache base
                     centerGPRect=new GPRectangle(startingLocation, 3);
                     GPRectangle centerClone=centerGPRect.Clone();

                     //Get all valid points (besides current point) from our current location GPR
                     GridPoint[] SearchPoints=centerGPRect.Points.Keys.Where(gp => !gp.Ignored).ToArray();
                     gridpointrectangles_=new List<GPRectangle>();
                     if (SearchPoints.Length>1)
                     {								//we should check our surrounding points to see if we can even move into any of them first!
                          for (int i=1; i<SearchPoints.Length-1; i++)
                          {
                                GridPoint curGP=SearchPoints[i];
                                Vector3 thisV3=(Vector3)curGP;
                                thisV3.Z+=(Bot.Character.fCharacterRadius/2f);

                                //Its a valid point for direction testing!
                                float DirectionDegrees=Navigation.FindDirection(Bot.NavigationCache.LastSearchVector, thisV3, false);
                                DirectionPoint P=new DirectionPoint((Vector3)curGP, DirectionDegrees, 125f);

                                if (P.Range>5f)
                                {
                                     gridpointrectangles_.Add(new GPRectangle(P, centerGPRect));
                                }
                          }
                          gridpointrectangles_.Add(centerClone);
                          gridpointrectangles_=gridpointrectangles_.OrderByDescending(gpr => gpr.Count).ToList();
                     }
        }
示例#2
0
        ///<summary>
        ///Using a direction point. Center will be established at the DirectionPoint center, with an area covering the start/end points.
        ///</summary>
        public GPRectangle(DirectionPoint Direction)
            : base()
        {
            // Logging.WriteVerbose("StartPoint: {0} EndPoint {1} Range: {2}", Direction.StartingPoint.ToString(), Direction.EndingPoint.ToString(), Direction.Range);

                     CreationVector=(Vector3)Direction.Center;
                     GridPoint center_=Direction.Center;
                     searchablepoints_=new List<GridPoint>();
                     searchablepoints_.Add(center_);//this is our first "surrounding" point to expand upon..
                     this.centerpoint=Direction.Center;

                     int expansion=(int)(Math.Round(Math.Sqrt(Direction.Range), MidpointRounding.AwayFromZero)); //Get the radius value and square it to get # of expansions we want..
                     //Logging.WriteVerbose("Expansion count == {0}, Diameter == {1}", expansion, Diameter);

                     //This will expand by finding new surrounding points
                     for (int i=0; i<expansion; i++)
                     {
                          if (searchablepoints_.Count==0) break; //no remaining searchable points..

                          this.FullyExpand();
                     }

                     this.UpdateQuadrants();

                     UpdateObjectCount();
                     lastRefreshedObjectContents=DateTime.Now;
        }