Exemplo n.º 1
0
        public static Vector2 getNearbyNodeOffset(Vector2 basePos, int positionNumber, int total, NetworkMap map)
        {
            var total1 = total;
            var num1   = positionNumber;

            if (total < 20)
            {
                var num2 = 30;
                var num3 = positionNumber / (float)total;
                total1 = num2;
                num1   = (int)(num3 * (double)num2);
            }
            var num4 = 300;

            for (var index = 0; index < num4; ++index)
            {
                var positionFromCycle = GetOffsetPositionFromCycle(num1 + index, total1);
                if (GeneratedPositionIsValid(positionFromCycle + basePos, map))
                {
                    return(positionFromCycle);
                }
                TestedPositions.Add(positionFromCycle + basePos);
            }
            Console.WriteLine("Node had to resort to random");
            return(map.getRandomPosition() - basePos);
        }
Exemplo n.º 2
0
        public static Vector2 getNearbyNodeOffset(Vector2 basePos, int positionNumber, int total, NetworkMap map, float extraDistance = 0.0f, bool forceUseThisPosition = false)
        {
            int total1 = total;
            int num1   = positionNumber;

            if (total < 20)
            {
                int   num2 = 30;
                float num3 = (float)positionNumber / (float)total;
                total1 = num2;
                num1   = (int)((double)num3 * (double)num2);
            }
            int num4 = 300;

            for (int index = 0; index < num4; ++index)
            {
                Vector2 positionFromCycle = Corporation.GetOffsetPositionFromCycle(num1 + index, total1, extraDistance);
                if (Corporation.GeneratedPositionIsValid(positionFromCycle + basePos, map, forceUseThisPosition))
                {
                    return(positionFromCycle);
                }
                Corporation.TestedPositions.Add(positionFromCycle + basePos);
            }
            return(map.getRandomPosition() - basePos);
        }
Exemplo n.º 3
0
        public static Vector2 getNearbyNodeOffsetOld(Vector2 basePos, int positionNumber, int total, NetworkMap map,
                                                     float ExtraSeperationDistance = 0.0f)
        {
            var     num1    = 60;
            var     num2    = 0;
            var     vector2 = Vector2.Zero;
            Vector2 location;

            do
            {
                var num3 = positionNumber + num2;
                var num4 = total;
                while (num3 >= num4)
                {
                    num3 -= num4;
                    num4 += total;
                }
                if (num3 > 0)
                {
                    vector2 = Utils.PolarToCartesian(num3 / (float)num4 * 6.283185f, 1f);
                }
                else
                {
                    vector2.X = 1f;
                }
                vector2.Y *= Y_ASPECT_RATIO_BIAS;
                double num5 = COMPUTER_SEPERATION;
                vector2  = new Vector2(vector2.X * COMPUTER_SEPERATION, vector2.Y * COMPUTER_SEPERATION);
                location = basePos + vector2;
                ++num2;
                TestedPositions.Add(vector2);
            } while ((location.X < 0.0 || location.X > 1.0 || (location.Y < 0.0 || location.Y > 1.0) ||
                      map.collides(location, 0.075f)) && num2 < num1);
            if (num2 >= num1)
            {
                if (ExtraSeperationDistance <= 0.0)
                {
                    return(getNearbyNodeOffsetOld(basePos, positionNumber, total, map, COMPUTER_SEPERATION));
                }
                if (ExtraSeperationDistance <= (double)COMPUTER_SEPERATION)
                {
                    return(getNearbyNodeOffsetOld(basePos, positionNumber, total, map,
                                                  COMPUTER_SEPERATION + COMPUTER_SEPERATION));
                }
                Console.WriteLine("Node had to resort to random");
                vector2 = map.getRandomPosition() - basePos;
            }
            return(vector2);
        }
Exemplo n.º 4
0
        public static Vector2 getNearbyNodeOffsetOld(Vector2 basePos, int positionNumber, int total, NetworkMap map, float ExtraSeperationDistance = 0.0f)
        {
            int     num1    = 60;
            int     num2    = 0;
            Vector2 vector2 = Vector2.Zero;
            Vector2 location;

            do
            {
                int num3 = positionNumber + num2;
                int num4 = total;
                while (num3 >= num4)
                {
                    num3 -= num4;
                    num4 += total;
                }
                if (num3 > 0)
                {
                    vector2 = Utils.PolarToCartesian((float)num3 / (float)num4 * 6.283185f, 1f);
                }
                else
                {
                    vector2.X = 1f;
                }
                vector2.Y *= Corporation.Y_ASPECT_RATIO_BIAS;
                float num5 = Corporation.COMPUTER_SEPERATION + ExtraSeperationDistance;
                vector2  = new Vector2(vector2.X * Corporation.COMPUTER_SEPERATION, vector2.Y * Corporation.COMPUTER_SEPERATION);
                location = basePos + vector2;
                ++num2;
                Corporation.TestedPositions.Add(vector2);
            }while (((double)location.X < 0.0 || (double)location.X > 1.0 || ((double)location.Y < 0.0 || (double)location.Y > 1.0) || map.collides(location, 0.075f)) && num2 < num1);
            if (num2 >= num1)
            {
                if ((double)ExtraSeperationDistance <= 0.0)
                {
                    return(Corporation.getNearbyNodeOffsetOld(basePos, positionNumber, total, map, Corporation.COMPUTER_SEPERATION));
                }
                if ((double)ExtraSeperationDistance <= (double)Corporation.COMPUTER_SEPERATION)
                {
                    return(Corporation.getNearbyNodeOffsetOld(basePos, positionNumber, total, map, Corporation.COMPUTER_SEPERATION + Corporation.COMPUTER_SEPERATION));
                }
                vector2 = map.getRandomPosition() - basePos;
            }
            return(vector2);
        }
Exemplo n.º 5
0
 public static Vector2 getNearbyNodeOffsetOld(Vector2 basePos, int positionNumber, int total, NetworkMap map,
     float ExtraSeperationDistance = 0.0f)
 {
     var num1 = 60;
     var num2 = 0;
     var vector2 = Vector2.Zero;
     Vector2 location;
     do
     {
         var num3 = positionNumber + num2;
         var num4 = total;
         while (num3 >= num4)
         {
             num3 -= num4;
             num4 += total;
         }
         if (num3 > 0)
             vector2 = Utils.PolarToCartesian(num3/(float) num4*6.283185f, 1f);
         else
             vector2.X = 1f;
         vector2.Y *= Y_ASPECT_RATIO_BIAS;
         double num5 = COMPUTER_SEPERATION;
         vector2 = new Vector2(vector2.X*COMPUTER_SEPERATION, vector2.Y*COMPUTER_SEPERATION);
         location = basePos + vector2;
         ++num2;
         TestedPositions.Add(vector2);
     } while ((location.X < 0.0 || location.X > 1.0 || (location.Y < 0.0 || location.Y > 1.0) ||
               map.collides(location, 0.075f)) && num2 < num1);
     if (num2 >= num1)
     {
         if (ExtraSeperationDistance <= 0.0)
             return getNearbyNodeOffsetOld(basePos, positionNumber, total, map, COMPUTER_SEPERATION);
         if (ExtraSeperationDistance <= (double) COMPUTER_SEPERATION)
             return getNearbyNodeOffsetOld(basePos, positionNumber, total, map,
                 COMPUTER_SEPERATION + COMPUTER_SEPERATION);
         Console.WriteLine("Node had to resort to random");
         vector2 = map.getRandomPosition() - basePos;
     }
     return vector2;
 }
Exemplo n.º 6
0
 public static Vector2 getNearbyNodeOffset(Vector2 basePos, int positionNumber, int total, NetworkMap map)
 {
     var total1 = total;
     var num1 = positionNumber;
     if (total < 20)
     {
         var num2 = 30;
         var num3 = positionNumber/(float) total;
         total1 = num2;
         num1 = (int) (num3*(double) num2);
     }
     var num4 = 300;
     for (var index = 0; index < num4; ++index)
     {
         var positionFromCycle = GetOffsetPositionFromCycle(num1 + index, total1);
         if (GeneratedPositionIsValid(positionFromCycle + basePos, map))
             return positionFromCycle;
         TestedPositions.Add(positionFromCycle + basePos);
     }
     Console.WriteLine("Node had to resort to random");
     return map.getRandomPosition() - basePos;
 }