コード例 #1
0
        private void Search()
        {
            bool BeyondFive = false;
            int  lowestx    = (int)Prover.Location.X;
            int  lowesty    = (int)Prover.Location.Y;
            int  highestx   = lowestx;
            int  highesty   = lowesty;
            int  currentx   = lowestx;
            int  currenty   = lowesty;

            PGC.ProbeForSpeciman(_myType, GameMain.newPoint2D(currentx, currenty));
            while (!BeyondFive)
            {
                BeyondFive = true;

                //ERROR. CODE BELOW DOESN'T WORK PROPERLY
                //right
                highestx++;
                for (int i = currentx; i < highestx; i++)
                {
                    if (GameMain.DistanceBetweenPoints(currentx, currenty, Prover.Location) <= 5f)
                    {
                        BeyondFive = false;
                        PGC.ProbeForSpeciman(_myType, GameMain.newPoint2D(currentx, currenty));
                    }
                    currentx = i + 1;
                }
                //up
                highesty++;
                for (int i = currenty; i < highesty; i++)
                {
                    if (GameMain.DistanceBetweenPoints(currentx, currenty, Prover.Location) <= 5f)
                    {
                        BeyondFive = false;
                        PGC.ProbeForSpeciman(_myType, GameMain.newPoint2D(currentx, i));
                    }
                    currenty = i + 1;
                }
                //left
                lowestx--;
                for (int i = currentx; i > lowestx; i--)
                {
                    if (GameMain.DistanceBetweenPoints(currentx, currenty, Prover.Location) <= 5f)
                    {
                        BeyondFive = false;
                        PGC.ProbeForSpeciman(_myType, GameMain.newPoint2D(i, currenty));
                    }
                    currentx = i - 1;
                }
                //down
                lowesty--;
                for (int i = currenty; i > lowesty; i--)
                {
                    if (GameMain.DistanceBetweenPoints(currentx, currenty, Prover.Location) <= 5f)
                    {
                        BeyondFive = false;
                        PGC.ProbeForSpeciman(_myType, GameMain.newPoint2D(i, currenty));
                    }
                    currenty = i - 1;
                }
            }
        }