Exemplo n.º 1
0
        public GPArea(Vector3 startingLocation)
        {
            //Creation and Cache base
            centerGPRect = new GPRectangle(startingLocation, 5);
            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)
            {
                Vector3 LastSearchVector3 = Bot.NavigationCache.LastSearchVector;
                // LastSearchVector3.Normalize();

                //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.Normalize();

                    //Its a valid point for direction testing!
                    float          DirectionDegrees = Navigation.FindDirection(LastSearchVector3, thisV3);
                    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();
            }
        }
Exemplo n.º 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, PointCollection baseCache)
            : base(baseCache)
        {
            // Logger.DBLog.InfoFormat("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..

            //Logger.DBLog.InfoFormat("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;
        }
Exemplo n.º 3
0
        public GPArea(Vector3 startingLocation)
        {
            //Creation and Cache base
            centerGPRect = new GPRectangle(startingLocation, 5);
            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)
            {
                Vector3 LastSearchVector3 = Bot.NavigationCache.LastSearchVector;
                // LastSearchVector3.Normalize();

                //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.Normalize();

                    //Its a valid point for direction testing!
                    float DirectionDegrees = Navigation.FindDirection(LastSearchVector3, thisV3);
                    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();
            }
        }
Exemplo n.º 4
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()
        {
            // Logger.DBLog.InfoFormat("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..
            //Logger.DBLog.InfoFormat("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;
        }