Пример #1
0
        public static Polygon getRandomBorderRoom(Rectangle room, Random mineRandom)
        {
            int lakeAreaWidth  = room.Width - 2;
            int lakeAreaHeight = room.Height - 2;
            int lakeXPosition  = room.X + 1;
            int lakeYPosition  = room.Y + 1;

            new Rectangle(lakeXPosition, lakeYPosition, lakeAreaWidth, lakeAreaHeight);
            Polygon lake         = new Polygon();
            Vector2 lastPosition = new Vector2(mineRandom.Next(lakeXPosition + 5, lakeXPosition + 8), mineRandom.Next(lakeYPosition + 5, lakeYPosition + 8));

            lake.Lines.Add(new Line(lastPosition, new Vector2(lastPosition.X + 1f, lastPosition.Y)));
            lastPosition.X += 1f;
            int topWidth       = room.Right - (int)lastPosition.X - lakeAreaWidth / 8;
            int lastDirection4 = 2;
            int m = 0;

            while (m < topWidth)
            {
                int whichWayToGo = mineRandom.Next(3);
                if ((whichWayToGo == 0 && lastPosition.Y > (float)room.Y && lastDirection4 != 1) || (lastDirection4 == 2 && lastPosition.Y >= (float)(lakeYPosition + lakeAreaHeight / 2)))
                {
                    lastPosition.Y -= 1f;
                    lastDirection4  = 0;
                }
                else if ((whichWayToGo == 1 && lastPosition.Y < (float)(lakeYPosition + lakeAreaHeight / 2) && lastDirection4 != 0) || (lastDirection4 == 2 && lastPosition.Y <= (float)room.Y))
                {
                    lastPosition.Y += 1f;
                    lastDirection4  = 1;
                }
                else
                {
                    lastPosition.X += 1f;
                    m++;
                    lastDirection4 = 2;
                }
                lake.addPoint(lastPosition);
            }
            int rightWidth = lakeAreaHeight - 4 - (int)(lastPosition.Y - (float)room.Y);

            lastPosition.Y += 1f;
            lastDirection4  = 2;
            lake.addPoint(lastPosition);
            int l = 0;

            while (l < rightWidth)
            {
                int whichWayToGo2 = mineRandom.Next(3);
                if ((whichWayToGo2 == 0 && lastPosition.X < (float)room.Right && lastDirection4 != 1) || (lastDirection4 == 2 && lastPosition.X <= (float)(lakeXPosition + lakeAreaWidth / 2 + 1)))
                {
                    lastPosition.X += 1f;
                    lastDirection4  = 0;
                }
                else if ((whichWayToGo2 == 1 && lastPosition.X > (float)(lakeXPosition + lakeAreaWidth / 2 + 1) && lastDirection4 != 0) || (lastDirection4 == 2 && lastPosition.X >= (float)room.Right))
                {
                    lastPosition.X -= 1f;
                    lastDirection4  = 1;
                }
                else
                {
                    lastPosition.Y += 1f;
                    l++;
                    lastDirection4 = 2;
                }
                lake.addPoint(lastPosition);
            }
            int bottomWidth = (int)lastPosition.X - (int)lake.Lines[0].Start.X + lakeAreaWidth / 4;

            lastPosition.X -= 1f;
            lastDirection4  = 2;
            lake.addPoint(lastPosition);
            int k = 0;

            while (k < bottomWidth)
            {
                int whichWayToGo3 = mineRandom.Next(3);
                if ((whichWayToGo3 == 0 && lastPosition.Y > (float)(lakeYPosition + lakeAreaHeight / 2) && lastDirection4 != 1 && !lake.containsPoint(new Vector2(lastPosition.X, lastPosition.Y - 1f))) || (lastDirection4 == 2 && lastPosition.Y >= (float)room.Bottom))
                {
                    lastPosition.Y -= 1f;
                    lastDirection4  = 0;
                }
                else if ((whichWayToGo3 == 1 && lastPosition.Y < (float)room.Bottom && lastDirection4 != 0) || (lastDirection4 == 2 && lastPosition.Y <= (float)(lakeYPosition + lakeAreaHeight / 2)))
                {
                    lastPosition.Y += 1f;
                    lastDirection4  = 1;
                }
                else
                {
                    lastPosition.X -= 1f;
                    k++;
                    lastDirection4 = 2;
                }
                lake.addPoint(lastPosition);
            }
            int leftWidth = (int)lastPosition.Y - (int)lake.Lines[0].Start.Y - 1;

            lastPosition.Y -= 1f;
            lastDirection4  = 2;
            lake.addPoint(lastPosition);
            int j = 0;

            while (j < leftWidth)
            {
                int whichWayToGo4 = mineRandom.Next(3);
                if ((whichWayToGo4 == 0 && lastPosition.X < (float)room.Center.X && !lake.containsPoint(new Vector2(lastPosition.X + 1f, lastPosition.Y)) && !lake.containsPoint(new Vector2(lastPosition.X, lastPosition.Y - 1f))) || (lastDirection4 == 2 && lastPosition.X <= (float)room.X))
                {
                    lastPosition.X += 1f;
                    lastDirection4  = 0;
                }
                else if ((whichWayToGo4 == 1 && lastPosition.X > (float)room.X && lastDirection4 != 0) || (lastDirection4 == 2 && lastPosition.X >= (float)room.Center.X))
                {
                    lastPosition.X -= 1f;
                    lastDirection4  = 1;
                }
                else
                {
                    lastPosition.Y -= 1f;
                    j++;
                    lastDirection4 = 2;
                }
                lake.addPoint(lastPosition);
            }
            if (lastPosition.X < (float)(int)lake.Lines[0].Start.X)
            {
                int leftover = (int)lake.Lines[0].Start.X + 1 - (int)lastPosition.X - 1;
                for (int i = 0; i < leftover; i++)
                {
                    lastPosition.X += 1f;
                    lake.addPoint(lastPosition);
                }
            }
            return(lake);
        }
Пример #2
0
        public static Polygon getEdgeBorder(Rectangle room, Random mineRandom, List <Rectangle> smoothZone, int horizontalInwardLimit, int verticalInwardLimit)
        {
            if (smoothZone == null)
            {
                smoothZone = new List <Rectangle>();
            }
            int lakeAreaWidth  = room.Width - 2;
            int lakeAreaHeight = room.Height - 2;
            int lakeXPosition  = room.X + 1;
            int lakeYPosition  = room.Y + 1;

            new Rectangle(lakeXPosition, lakeYPosition, lakeAreaWidth, lakeAreaHeight);
            Polygon lake         = new Polygon();
            Vector2 lastPosition = new Vector2(mineRandom.Next(lakeXPosition + 5, lakeXPosition + 8), mineRandom.Next(lakeYPosition + 5, lakeYPosition + 8));

            lake.Lines.Add(new Line(lastPosition, new Vector2(lastPosition.X + 1f, lastPosition.Y)));
            lastPosition.X += 1f;
            int        topWidth       = lakeAreaWidth - 12;
            List <int> lastDirection4 = new List <int>
            {
                2,
                2,
                2
            };
            int m = 0;

            while (m < topWidth)
            {
                int whichWayToGo = mineRandom.Next(3);
                if (lastDirection4.Last() != whichWayToGo && lastDirection4[lastDirection4.Count - 2] != lastDirection4.Last())
                {
                    whichWayToGo = lastDirection4.Last();
                }
                if (whichWayToGo == 0 && lastPosition.Y > (float)lakeYPosition && !lastDirection4.Contains(1))
                {
                    lastPosition.Y -= 1f;
                    lastDirection4.Add(0);
                }
                else if (whichWayToGo == 1 && lastPosition.Y < (float)(lakeYPosition + verticalInwardLimit) && !lastDirection4.Contains(0))
                {
                    lastPosition.Y += 1f;
                    lastDirection4.Add(1);
                }
                else
                {
                    lastPosition.X += 1f;
                    m++;
                    lastDirection4.Add(2);
                }
                lastDirection4.RemoveAt(0);
                lake.addPoint(lastPosition);
            }
            int rightWidth = lakeAreaHeight - 4 - (int)(lastPosition.Y - (float)room.Y);

            lastPosition.Y += 1f;
            lastDirection4  = new List <int>
            {
                2,
                2,
                2
            };
            lake.addPoint(lastPosition);
            int l = 0;

            while (l < rightWidth)
            {
                int whichWayToGo2 = mineRandom.Next(3);
                if (lastDirection4.Last() != whichWayToGo2 && lastDirection4[lastDirection4.Count - 2] != lastDirection4.Last())
                {
                    whichWayToGo2 = lastDirection4.Last();
                }
                if (l > 4 && whichWayToGo2 == 0 && lastPosition.X < (float)(lakeXPosition + lakeAreaWidth - 1) && !lastDirection4.Contains(1) && !Utility.pointInRectangles(smoothZone, (int)lastPosition.X, (int)lastPosition.Y))
                {
                    lastPosition.X += 1f;
                    lastDirection4.Add(0);
                }
                else if (l > 4 && whichWayToGo2 == 1 && lastPosition.X > (float)(lakeXPosition + lakeAreaWidth - horizontalInwardLimit + 1) && !lastDirection4.Contains(0) && !Utility.pointInRectangles(smoothZone, (int)lastPosition.X, (int)lastPosition.Y))
                {
                    lastPosition.X -= 1f;
                    lastDirection4.Add(1);
                }
                else
                {
                    lastPosition.Y += 1f;
                    l++;
                    lastDirection4.Add(2);
                }
                lastDirection4.RemoveAt(0);
                lake.addPoint(lastPosition);
            }
            int bottomWidth = (int)lastPosition.X - (int)lake.Lines[0].Start.X + 1;

            lastPosition.X -= 1f;
            lastDirection4  = new List <int>
            {
                2,
                2,
                2
            };
            lake.addPoint(lastPosition);
            int k = 0;

            while (k < bottomWidth)
            {
                int whichWayToGo3 = mineRandom.Next(3);
                if (lastDirection4.Last() != whichWayToGo3 && lastDirection4[lastDirection4.Count - 2] != lastDirection4.Last())
                {
                    whichWayToGo3 = lastDirection4.Last();
                }
                if (k > 4 && whichWayToGo3 == 0 && lastPosition.Y > (float)(lakeYPosition + lakeAreaHeight - verticalInwardLimit) && !lastDirection4.Contains(1) && !lake.containsPoint(new Vector2(lastPosition.X, lastPosition.Y - 1f)))
                {
                    lastPosition.Y -= 1f;
                    lastDirection4.Add(0);
                }
                else if (k > 4 && whichWayToGo3 == 1 && lastPosition.Y < (float)(lakeYPosition + lakeAreaHeight) && !lastDirection4.Contains(0))
                {
                    lastPosition.Y += 1f;
                    lastDirection4.Add(1);
                }
                else
                {
                    lastPosition.X -= 1f;
                    k++;
                    lastDirection4.Add(2);
                }
                lastDirection4.RemoveAt(0);
                lake.addPoint(lastPosition);
            }
            int leftWidth = (int)lastPosition.Y - (int)lake.Lines[0].Start.Y - 1;

            lastPosition.Y -= 1f;
            lastDirection4  = new List <int>
            {
                2,
                2,
                2
            };
            lake.addPoint(lastPosition);
            int j = 0;

            while (j < leftWidth)
            {
                int whichWayToGo4 = mineRandom.Next(3);
                if (lastDirection4.Last() != whichWayToGo4 && lastDirection4[lastDirection4.Count - 2] != lastDirection4.Last())
                {
                    whichWayToGo4 = lastDirection4.Last();
                }
                if (j > 4 && whichWayToGo4 == 0 && lastPosition.X < (float)(int)lake.Lines[0].Start.X && !lastDirection4.Contains(1) && !lake.containsPoint(new Vector2(lastPosition.X + 1f, lastPosition.Y)) && !lake.containsPoint(new Vector2(lastPosition.X, lastPosition.Y - 1f)) && !Utility.pointInRectangles(smoothZone, (int)lastPosition.X, (int)lastPosition.Y))
                {
                    lastPosition.X += 1f;
                    lastDirection4.Add(0);
                }
                else if (j > 4 && whichWayToGo4 == 1 && lastPosition.X > (float)(lakeXPosition + 1) && !lastDirection4.Contains(0) && !Utility.pointInRectangles(smoothZone, (int)lastPosition.X, (int)lastPosition.Y))
                {
                    lastPosition.X -= 1f;
                    lastDirection4.Add(1);
                }
                else
                {
                    lastPosition.Y -= 1f;
                    j++;
                    lastDirection4.Add(2);
                }
                lastDirection4.RemoveAt(0);
                lake.addPoint(lastPosition);
            }
            if (lastPosition.X < (float)(int)lake.Lines[0].Start.X)
            {
                int leftover = (int)lake.Lines[0].Start.X + 1 - (int)lastPosition.X - 1;
                for (int i = 0; i < leftover; i++)
                {
                    lastPosition.X += 1f;
                    lake.addPoint(lastPosition);
                }
            }
            return(lake);
        }
Пример #3
0
        public static Polygon getEdgeBorder(Rectangle room, Random mineRandom, List <Rectangle> smoothZone, int horizontalInwardLimit, int verticalInwardLimit)
        {
            if (smoothZone == null)
            {
                smoothZone = new List <Rectangle>();
            }
            int num  = room.Width - 2;
            int num2 = room.Height - 2;
            int num3 = room.X + 1;
            int num4 = room.Y + 1;

            new Rectangle(num3, num4, num, num2);
            Polygon polygon = new Polygon();
            Vector2 vector  = new Vector2((float)mineRandom.Next(num3 + 5, num3 + 8), (float)mineRandom.Next(num4 + 5, num4 + 8));

            polygon.Lines.Add(new Polygon.Line(vector, new Vector2(vector.X + 1f, vector.Y)));
            vector.X += 1f;
            int        num5 = num - 12;
            List <int> list = new List <int>
            {
                2,
                2,
                2
            };
            int i = 0;

            while (i < num5)
            {
                int num6 = mineRandom.Next(3);
                if (list.Last <int>() != num6 && list[list.Count - 2] != list.Last <int>())
                {
                    num6 = list.Last <int>();
                }
                if (num6 == 0 && vector.Y > (float)num4 && !list.Contains(1))
                {
                    vector.Y -= 1f;
                    list.Add(0);
                }
                else if (num6 == 1 && vector.Y < (float)(num4 + verticalInwardLimit) && !list.Contains(0))
                {
                    vector.Y += 1f;
                    list.Add(1);
                }
                else
                {
                    vector.X += 1f;
                    i++;
                    list.Add(2);
                }
                list.RemoveAt(0);
                polygon.addPoint(vector);
            }
            int num7 = num2 - 4 - (int)(vector.Y - (float)room.Y);

            vector.Y += 1f;
            list      = new List <int>
            {
                2,
                2,
                2
            };
            polygon.addPoint(vector);
            int j = 0;

            while (j < num7)
            {
                int num8 = mineRandom.Next(3);
                if (list.Last <int>() != num8 && list[list.Count - 2] != list.Last <int>())
                {
                    num8 = list.Last <int>();
                }
                if (j > 4 && num8 == 0 && vector.X < (float)(num3 + num - 1) && !list.Contains(1) && !Utility.pointInRectangles(smoothZone, (int)vector.X, (int)vector.Y))
                {
                    vector.X += 1f;
                    list.Add(0);
                }
                else if (j > 4 && num8 == 1 && vector.X > (float)(num3 + num - horizontalInwardLimit + 1) && !list.Contains(0) && !Utility.pointInRectangles(smoothZone, (int)vector.X, (int)vector.Y))
                {
                    vector.X -= 1f;
                    list.Add(1);
                }
                else
                {
                    vector.Y += 1f;
                    j++;
                    list.Add(2);
                }
                list.RemoveAt(0);
                polygon.addPoint(vector);
            }
            int num9 = (int)vector.X - (int)polygon.Lines[0].Start.X + 1;

            vector.X -= 1f;
            list      = new List <int>
            {
                2,
                2,
                2
            };
            polygon.addPoint(vector);
            int k = 0;

            while (k < num9)
            {
                int num10 = mineRandom.Next(3);
                if (list.Last <int>() != num10 && list[list.Count - 2] != list.Last <int>())
                {
                    num10 = list.Last <int>();
                }
                if (k > 4 && num10 == 0 && vector.Y > (float)(num4 + num2 - verticalInwardLimit) && !list.Contains(1) && !polygon.containsPoint(new Vector2(vector.X, vector.Y - 1f)))
                {
                    vector.Y -= 1f;
                    list.Add(0);
                }
                else if (k > 4 && num10 == 1 && vector.Y < (float)(num4 + num2) && !list.Contains(0))
                {
                    vector.Y += 1f;
                    list.Add(1);
                }
                else
                {
                    vector.X -= 1f;
                    k++;
                    list.Add(2);
                }
                list.RemoveAt(0);
                polygon.addPoint(vector);
            }
            int num11 = (int)vector.Y - (int)polygon.Lines[0].Start.Y - 1;

            vector.Y -= 1f;
            list      = new List <int>
            {
                2,
                2,
                2
            };
            polygon.addPoint(vector);
            int l = 0;

            while (l < num11)
            {
                int num12 = mineRandom.Next(3);
                if (list.Last <int>() != num12 && list[list.Count - 2] != list.Last <int>())
                {
                    num12 = list.Last <int>();
                }
                if (l > 4 && num12 == 0 && vector.X < (float)((int)polygon.Lines[0].Start.X) && !list.Contains(1) && !polygon.containsPoint(new Vector2(vector.X + 1f, vector.Y)) && !polygon.containsPoint(new Vector2(vector.X, vector.Y - 1f)) && !Utility.pointInRectangles(smoothZone, (int)vector.X, (int)vector.Y))
                {
                    vector.X += 1f;
                    list.Add(0);
                }
                else if (l > 4 && num12 == 1 && vector.X > (float)(num3 + 1) && !list.Contains(0) && !Utility.pointInRectangles(smoothZone, (int)vector.X, (int)vector.Y))
                {
                    vector.X -= 1f;
                    list.Add(1);
                }
                else
                {
                    vector.Y -= 1f;
                    l++;
                    list.Add(2);
                }
                list.RemoveAt(0);
                polygon.addPoint(vector);
            }
            if (vector.X < (float)((int)polygon.Lines[0].Start.X))
            {
                int num13 = (int)polygon.Lines[0].Start.X + 1 - (int)vector.X - 1;
                for (int m = 0; m < num13; m++)
                {
                    vector.X += 1f;
                    polygon.addPoint(vector);
                }
            }
            return(polygon);
        }
Пример #4
0
        public static Polygon getGentlerBorderForLakes(Rectangle room, Random mineRandom, Rectangle smoothZone)
        {
            int lakeAreaWidth  = room.Width - 2;
            int lakeAreaHeight = room.Height - 2;
            int lakeXPosition  = room.X + 1;
            int lakeYPosition  = room.Y + 1;

            new Rectangle(lakeXPosition, lakeYPosition, lakeAreaWidth, lakeAreaHeight);
            Polygon lake         = new Polygon();
            Vector2 lastPosition = new Vector2(mineRandom.Next(lakeXPosition + 5, lakeXPosition + 8), mineRandom.Next(lakeYPosition + 5, lakeYPosition + 8));

            lake.Lines.Add(new Line(lastPosition, new Vector2(lastPosition.X + 1f, lastPosition.Y)));
            lastPosition.X += 1f;
            int        topWidth       = lakeAreaWidth - 12;
            List <int> lastDirection4 = new List <int>
            {
                2,
                2,
                2
            };
            int m = 0;

            while (m < topWidth)
            {
                int whichWayToGo = mineRandom.Next(3);
                if (whichWayToGo == 0 && lastPosition.Y > (float)lakeYPosition && !lastDirection4.Contains(1) && !smoothZone.Contains((int)lastPosition.X, (int)lastPosition.Y))
                {
                    lastPosition.Y -= 1f;
                    lastDirection4.Add(0);
                }
                else if (whichWayToGo == 1 && lastPosition.Y < (float)(lakeYPosition + lakeAreaHeight / 2) && !lastDirection4.Contains(0) && !smoothZone.Contains((int)lastPosition.X, (int)lastPosition.Y))
                {
                    lastPosition.Y += 1f;
                    lastDirection4.Add(1);
                }
                else
                {
                    lastPosition.X += 1f;
                    m++;
                    lastDirection4.Add(2);
                }
                lastDirection4.RemoveAt(0);
                lake.addPoint(lastPosition);
            }
            int rightWidth = lakeAreaHeight - 4 - (int)(lastPosition.Y - (float)room.Y);

            lastPosition.Y += 1f;
            lastDirection4  = new List <int>
            {
                2,
                2,
                2
            };
            lake.addPoint(lastPosition);
            int l = 0;

            while (l < rightWidth)
            {
                int whichWayToGo2 = mineRandom.Next(3);
                if (whichWayToGo2 == 0 && lastPosition.X < (float)(lakeXPosition + lakeAreaWidth) && !lastDirection4.Contains(1) && !smoothZone.Contains((int)lastPosition.X, (int)lastPosition.Y))
                {
                    lastPosition.X += 1f;
                    lastDirection4.Add(0);
                }
                else if (whichWayToGo2 == 1 && lastPosition.X > (float)(lakeXPosition + lakeAreaWidth / 2 + 1) && !lastDirection4.Contains(0) && !smoothZone.Contains((int)lastPosition.X, (int)lastPosition.Y))
                {
                    lastPosition.X -= 1f;
                    lastDirection4.Add(1);
                }
                else
                {
                    lastPosition.Y += 1f;
                    l++;
                    lastDirection4.Add(2);
                }
                lastDirection4.RemoveAt(0);
                lake.addPoint(lastPosition);
            }
            int bottomWidth = (int)lastPosition.X - (int)lake.Lines[0].Start.X + 1;

            lastPosition.X -= 1f;
            lastDirection4  = new List <int>
            {
                2,
                2,
                2
            };
            lake.addPoint(lastPosition);
            int k = 0;

            while (k < bottomWidth)
            {
                int whichWayToGo3 = mineRandom.Next(3);
                if (whichWayToGo3 == 0 && lastPosition.Y > (float)(lakeYPosition + lakeAreaHeight / 2) && !lastDirection4.Contains(1) && !lake.containsPoint(new Vector2(lastPosition.X, lastPosition.Y - 1f)) && !smoothZone.Contains((int)lastPosition.X, (int)lastPosition.Y))
                {
                    lastPosition.Y -= 1f;
                    lastDirection4.Add(0);
                }
                else if (whichWayToGo3 == 1 && lastPosition.Y < (float)(lakeYPosition + lakeAreaHeight) && !lastDirection4.Contains(0) && !smoothZone.Contains((int)lastPosition.X, (int)lastPosition.Y))
                {
                    lastPosition.Y += 1f;
                    lastDirection4.Add(1);
                }
                else
                {
                    lastPosition.X -= 1f;
                    k++;
                    lastDirection4.Add(2);
                }
                lastDirection4.RemoveAt(0);
                lake.addPoint(lastPosition);
            }
            int leftWidth = (int)lastPosition.Y - (int)lake.Lines[0].Start.Y - 1;

            lastPosition.Y -= 1f;
            lastDirection4  = new List <int>
            {
                2,
                2,
                2
            };
            lake.addPoint(lastPosition);
            int j = 0;

            while (j < leftWidth)
            {
                int whichWayToGo4 = mineRandom.Next(3);
                if (whichWayToGo4 == 0 && lastPosition.X < (float)(int)lake.Lines[0].Start.X && !lastDirection4.Contains(1) && !lake.containsPoint(new Vector2(lastPosition.X + 1f, lastPosition.Y)) && !lake.containsPoint(new Vector2(lastPosition.X, lastPosition.Y - 1f)) && !smoothZone.Contains((int)lastPosition.X, (int)lastPosition.Y))
                {
                    lastPosition.X += 1f;
                    lastDirection4.Add(0);
                }
                else if (whichWayToGo4 == 1 && lastPosition.X > (float)(lakeXPosition + 1) && !lastDirection4.Contains(0) && !smoothZone.Contains((int)lastPosition.X, (int)lastPosition.Y))
                {
                    lastPosition.X -= 1f;
                    lastDirection4.Add(1);
                }
                else
                {
                    lastPosition.Y -= 1f;
                    j++;
                    lastDirection4.Add(2);
                }
                lastDirection4.RemoveAt(0);
                lake.addPoint(lastPosition);
            }
            if (lastPosition.X < (float)(int)lake.Lines[0].Start.X)
            {
                int leftover = (int)lake.Lines[0].Start.X + 1 - (int)lastPosition.X - 1;
                for (int i = 0; i < leftover; i++)
                {
                    lastPosition.X += 1f;
                    lake.addPoint(lastPosition);
                }
            }
            return(lake);
        }
Пример #5
0
        public static Polygon getRandomBorderRoom(Rectangle room, Random mineRandom)
        {
            int num  = room.Width - 2;
            int num2 = room.Height - 2;
            int num3 = room.X + 1;
            int num4 = room.Y + 1;

            new Rectangle(num3, num4, num, num2);
            Polygon polygon = new Polygon();
            Vector2 vector  = new Vector2((float)mineRandom.Next(num3 + 5, num3 + 8), (float)mineRandom.Next(num4 + 5, num4 + 8));

            polygon.Lines.Add(new Polygon.Line(vector, new Vector2(vector.X + 1f, vector.Y)));
            vector.X += 1f;
            int num5 = room.Right - (int)vector.X - num / 8;
            int num6 = 2;
            int i    = 0;

            while (i < num5)
            {
                int num7 = mineRandom.Next(3);
                if ((num7 == 0 && vector.Y > (float)room.Y && num6 != 1) || (num6 == 2 && vector.Y >= (float)(num4 + num2 / 2)))
                {
                    vector.Y -= 1f;
                    num6      = 0;
                }
                else if ((num7 == 1 && vector.Y < (float)(num4 + num2 / 2) && num6 != 0) || (num6 == 2 && vector.Y <= (float)room.Y))
                {
                    vector.Y += 1f;
                    num6      = 1;
                }
                else
                {
                    vector.X += 1f;
                    i++;
                    num6 = 2;
                }
                polygon.addPoint(vector);
            }
            int num8 = num2 - 4 - (int)(vector.Y - (float)room.Y);

            vector.Y += 1f;
            num6      = 2;
            polygon.addPoint(vector);
            int j = 0;

            while (j < num8)
            {
                int num9 = mineRandom.Next(3);
                if ((num9 == 0 && vector.X < (float)room.Right && num6 != 1) || (num6 == 2 && vector.X <= (float)(num3 + num / 2 + 1)))
                {
                    vector.X += 1f;
                    num6      = 0;
                }
                else if ((num9 == 1 && vector.X > (float)(num3 + num / 2 + 1) && num6 != 0) || (num6 == 2 && vector.X >= (float)room.Right))
                {
                    vector.X -= 1f;
                    num6      = 1;
                }
                else
                {
                    vector.Y += 1f;
                    j++;
                    num6 = 2;
                }
                polygon.addPoint(vector);
            }
            int num10 = (int)vector.X - (int)polygon.Lines[0].Start.X + num / 4;

            vector.X -= 1f;
            num6      = 2;
            polygon.addPoint(vector);
            int k = 0;

            while (k < num10)
            {
                int num11 = mineRandom.Next(3);
                if ((num11 == 0 && vector.Y > (float)(num4 + num2 / 2) && num6 != 1 && !polygon.containsPoint(new Vector2(vector.X, vector.Y - 1f))) || (num6 == 2 && vector.Y >= (float)room.Bottom))
                {
                    vector.Y -= 1f;
                    num6      = 0;
                }
                else if ((num11 == 1 && vector.Y < (float)room.Bottom && num6 != 0) || (num6 == 2 && vector.Y <= (float)(num4 + num2 / 2)))
                {
                    vector.Y += 1f;
                    num6      = 1;
                }
                else
                {
                    vector.X -= 1f;
                    k++;
                    num6 = 2;
                }
                polygon.addPoint(vector);
            }
            int num12 = (int)vector.Y - (int)polygon.Lines[0].Start.Y - 1;

            vector.Y -= 1f;
            num6      = 2;
            polygon.addPoint(vector);
            int l = 0;

            while (l < num12)
            {
                int num13 = mineRandom.Next(3);
                if ((num13 == 0 && vector.X < (float)room.Center.X && !polygon.containsPoint(new Vector2(vector.X + 1f, vector.Y)) && !polygon.containsPoint(new Vector2(vector.X, vector.Y - 1f))) || (num6 == 2 && vector.X <= (float)room.X))
                {
                    vector.X += 1f;
                    num6      = 0;
                }
                else if ((num13 == 1 && vector.X > (float)room.X && num6 != 0) || (num6 == 2 && vector.X >= (float)room.Center.X))
                {
                    vector.X -= 1f;
                    num6      = 1;
                }
                else
                {
                    vector.Y -= 1f;
                    l++;
                    num6 = 2;
                }
                polygon.addPoint(vector);
            }
            if (vector.X < (float)((int)polygon.Lines[0].Start.X))
            {
                int num14 = (int)polygon.Lines[0].Start.X + 1 - (int)vector.X - 1;
                for (int m = 0; m < num14; m++)
                {
                    vector.X += 1f;
                    polygon.addPoint(vector);
                }
            }
            return(polygon);
        }
Пример #6
0
        public static Polygon getGentlerBorderForLakes(Rectangle room, Random mineRandom, Rectangle smoothZone)
        {
            int num  = room.Width - 2;
            int num2 = room.Height - 2;
            int num3 = room.X + 1;
            int num4 = room.Y + 1;

            new Rectangle(num3, num4, num, num2);
            Polygon polygon = new Polygon();
            Vector2 vector  = new Vector2((float)mineRandom.Next(num3 + 5, num3 + 8), (float)mineRandom.Next(num4 + 5, num4 + 8));

            polygon.Lines.Add(new Polygon.Line(vector, new Vector2(vector.X + 1f, vector.Y)));
            vector.X += 1f;
            int        num5 = num - 12;
            List <int> list = new List <int>
            {
                2,
                2,
                2
            };
            int i = 0;

            while (i < num5)
            {
                int num6 = mineRandom.Next(3);
                if (num6 == 0 && vector.Y > (float)num4 && !list.Contains(1) && !smoothZone.Contains((int)vector.X, (int)vector.Y))
                {
                    vector.Y -= 1f;
                    list.Add(0);
                }
                else if (num6 == 1 && vector.Y < (float)(num4 + num2 / 2) && !list.Contains(0) && !smoothZone.Contains((int)vector.X, (int)vector.Y))
                {
                    vector.Y += 1f;
                    list.Add(1);
                }
                else
                {
                    vector.X += 1f;
                    i++;
                    list.Add(2);
                }
                list.RemoveAt(0);
                polygon.addPoint(vector);
            }
            int num7 = num2 - 4 - (int)(vector.Y - (float)room.Y);

            vector.Y += 1f;
            list      = new List <int>
            {
                2,
                2,
                2
            };
            polygon.addPoint(vector);
            int j = 0;

            while (j < num7)
            {
                int num8 = mineRandom.Next(3);
                if (num8 == 0 && vector.X < (float)(num3 + num) && !list.Contains(1) && !smoothZone.Contains((int)vector.X, (int)vector.Y))
                {
                    vector.X += 1f;
                    list.Add(0);
                }
                else if (num8 == 1 && vector.X > (float)(num3 + num / 2 + 1) && !list.Contains(0) && !smoothZone.Contains((int)vector.X, (int)vector.Y))
                {
                    vector.X -= 1f;
                    list.Add(1);
                }
                else
                {
                    vector.Y += 1f;
                    j++;
                    list.Add(2);
                }
                list.RemoveAt(0);
                polygon.addPoint(vector);
            }
            int num9 = (int)vector.X - (int)polygon.Lines[0].Start.X + 1;

            vector.X -= 1f;
            list      = new List <int>
            {
                2,
                2,
                2
            };
            polygon.addPoint(vector);
            int k = 0;

            while (k < num9)
            {
                int num10 = mineRandom.Next(3);
                if (num10 == 0 && vector.Y > (float)(num4 + num2 / 2) && !list.Contains(1) && !polygon.containsPoint(new Vector2(vector.X, vector.Y - 1f)) && !smoothZone.Contains((int)vector.X, (int)vector.Y))
                {
                    vector.Y -= 1f;
                    list.Add(0);
                }
                else if (num10 == 1 && vector.Y < (float)(num4 + num2) && !list.Contains(0) && !smoothZone.Contains((int)vector.X, (int)vector.Y))
                {
                    vector.Y += 1f;
                    list.Add(1);
                }
                else
                {
                    vector.X -= 1f;
                    k++;
                    list.Add(2);
                }
                list.RemoveAt(0);
                polygon.addPoint(vector);
            }
            int num11 = (int)vector.Y - (int)polygon.Lines[0].Start.Y - 1;

            vector.Y -= 1f;
            list      = new List <int>
            {
                2,
                2,
                2
            };
            polygon.addPoint(vector);
            int l = 0;

            while (l < num11)
            {
                int num12 = mineRandom.Next(3);
                if (num12 == 0 && vector.X < (float)((int)polygon.Lines[0].Start.X) && !list.Contains(1) && !polygon.containsPoint(new Vector2(vector.X + 1f, vector.Y)) && !polygon.containsPoint(new Vector2(vector.X, vector.Y - 1f)) && !smoothZone.Contains((int)vector.X, (int)vector.Y))
                {
                    vector.X += 1f;
                    list.Add(0);
                }
                else if (num12 == 1 && vector.X > (float)(num3 + 1) && !list.Contains(0) && !smoothZone.Contains((int)vector.X, (int)vector.Y))
                {
                    vector.X -= 1f;
                    list.Add(1);
                }
                else
                {
                    vector.Y -= 1f;
                    l++;
                    list.Add(2);
                }
                list.RemoveAt(0);
                polygon.addPoint(vector);
            }
            if (vector.X < (float)((int)polygon.Lines[0].Start.X))
            {
                int num13 = (int)polygon.Lines[0].Start.X + 1 - (int)vector.X - 1;
                for (int m = 0; m < num13; m++)
                {
                    vector.X += 1f;
                    polygon.addPoint(vector);
                }
            }
            return(polygon);
        }
Пример #7
0
        public static Polygon getEdgeBorder(Rectangle room, Random mineRandom, List <Rectangle> smoothZone, int horizontalInwardLimit, int verticalInwardLimit)
        {
            if (smoothZone == null)
            {
                smoothZone = new List <Rectangle>();
            }
            int       width     = room.Width - 2;
            int       height    = room.Height - 2;
            int       x         = room.X + 1;
            int       y         = room.Y + 1;
            Rectangle rectangle = new Rectangle(x, y, width, height);
            Polygon   polygon   = new Polygon();
            Vector2   vector2   = new Vector2((float)mineRandom.Next(x + 5, x + 8), (float)mineRandom.Next(y + 5, y + 8));

            polygon.Lines.Add(new Polygon.Line(vector2, new Vector2(vector2.X + 1f, vector2.Y)));
            ++vector2.X;
            int        num1    = width - 12;
            List <int> source1 = new List <int>()
            {
                2, 2, 2
            };
            int num2 = 0;

            while (num2 < num1)
            {
                int num3 = mineRandom.Next(3);
                if (source1.Last <int>() != num3 && source1[source1.Count - 2] != source1.Last <int>())
                {
                    num3 = source1.Last <int>();
                }
                if (num3 == 0 && (double)vector2.Y > (double)y && !source1.Contains(1))
                {
                    --vector2.Y;
                    source1.Add(0);
                }
                else if (num3 == 1 && (double)vector2.Y < (double)(y + verticalInwardLimit) && !source1.Contains(0))
                {
                    ++vector2.Y;
                    source1.Add(1);
                }
                else
                {
                    ++vector2.X;
                    ++num2;
                    source1.Add(2);
                }
                source1.RemoveAt(0);
                polygon.addPoint(vector2);
            }
            int num4 = height - 4 - (int)((double)vector2.Y - (double)room.Y);

            ++vector2.Y;
            List <int> source2 = new List <int>()
            {
                2, 2, 2
            };

            polygon.addPoint(vector2);
            int num5 = 0;

            while (num5 < num4)
            {
                int num3 = mineRandom.Next(3);
                if (source2.Last <int>() != num3 && source2[source2.Count - 2] != source2.Last <int>())
                {
                    num3 = source2.Last <int>();
                }
                if (num5 > 4 && num3 == 0 && ((double)vector2.X < (double)(x + width - 1) && !source2.Contains(1)) && !Utility.pointInRectangles(smoothZone, (int)vector2.X, (int)vector2.Y))
                {
                    ++vector2.X;
                    source2.Add(0);
                }
                else if (num5 > 4 && num3 == 1 && ((double)vector2.X > (double)(x + width - horizontalInwardLimit + 1) && !source2.Contains(0)) && !Utility.pointInRectangles(smoothZone, (int)vector2.X, (int)vector2.Y))
                {
                    --vector2.X;
                    source2.Add(1);
                }
                else
                {
                    ++vector2.Y;
                    ++num5;
                    source2.Add(2);
                }
                source2.RemoveAt(0);
                polygon.addPoint(vector2);
            }
            int num6 = (int)vector2.X - (int)polygon.Lines[0].Start.X + 1;

            --vector2.X;
            List <int> source3 = new List <int>()
            {
                2, 2, 2
            };

            polygon.addPoint(vector2);
            int num7 = 0;

            while (num7 < num6)
            {
                int num3 = mineRandom.Next(3);
                if (source3.Last <int>() != num3 && source3[source3.Count - 2] != source3.Last <int>())
                {
                    num3 = source3.Last <int>();
                }
                if (num7 > 4 && num3 == 0 && ((double)vector2.Y > (double)(y + height - verticalInwardLimit) && !source3.Contains(1)) && !polygon.containsPoint(new Vector2(vector2.X, vector2.Y - 1f)))
                {
                    --vector2.Y;
                    source3.Add(0);
                }
                else if (num7 > 4 && num3 == 1 && ((double)vector2.Y < (double)(y + height) && !source3.Contains(0)))
                {
                    ++vector2.Y;
                    source3.Add(1);
                }
                else
                {
                    --vector2.X;
                    ++num7;
                    source3.Add(2);
                }
                source3.RemoveAt(0);
                polygon.addPoint(vector2);
            }
            int num8 = (int)vector2.Y - (int)polygon.Lines[0].Start.Y - 1;

            --vector2.Y;
            List <int> source4 = new List <int>()
            {
                2, 2, 2
            };

            polygon.addPoint(vector2);
            int num9 = 0;

            while (num9 < num8)
            {
                int num3 = mineRandom.Next(3);
                if (source4.Last <int>() != num3 && source4[source4.Count - 2] != source4.Last <int>())
                {
                    num3 = source4.Last <int>();
                }
                if (num9 > 4 && num3 == 0 && ((double)vector2.X < (double)(int)polygon.Lines[0].Start.X && !source4.Contains(1)) && (!polygon.containsPoint(new Vector2(vector2.X + 1f, vector2.Y)) && !polygon.containsPoint(new Vector2(vector2.X, vector2.Y - 1f)) && !Utility.pointInRectangles(smoothZone, (int)vector2.X, (int)vector2.Y)))
                {
                    ++vector2.X;
                    source4.Add(0);
                }
                else if (num9 > 4 && num3 == 1 && ((double)vector2.X > (double)(x + 1) && !source4.Contains(0)) && !Utility.pointInRectangles(smoothZone, (int)vector2.X, (int)vector2.Y))
                {
                    --vector2.X;
                    source4.Add(1);
                }
                else
                {
                    --vector2.Y;
                    ++num9;
                    source4.Add(2);
                }
                source4.RemoveAt(0);
                polygon.addPoint(vector2);
            }
            if ((double)vector2.X < (double)(int)polygon.Lines[0].Start.X)
            {
                int num3 = (int)polygon.Lines[0].Start.X + 1 - (int)vector2.X - 1;
                for (int index = 0; index < num3; ++index)
                {
                    ++vector2.X;
                    polygon.addPoint(vector2);
                }
            }
            return(polygon);
        }
Пример #8
0
        public static Polygon getRandomBorderRoom(Rectangle room, Random mineRandom)
        {
            int       width     = room.Width - 2;
            int       height    = room.Height - 2;
            int       x         = room.X + 1;
            int       y         = room.Y + 1;
            Rectangle rectangle = new Rectangle(x, y, width, height);
            Polygon   polygon   = new Polygon();
            Vector2   vector2   = new Vector2((float)mineRandom.Next(x + 5, x + 8), (float)mineRandom.Next(y + 5, y + 8));

            polygon.Lines.Add(new Polygon.Line(vector2, new Vector2(vector2.X + 1f, vector2.Y)));
            ++vector2.X;
            int num1 = room.Right - (int)vector2.X - width / 8;
            int num2 = 2;
            int num3 = 0;

            while (num3 < num1)
            {
                int num4 = mineRandom.Next(3);
                if (num4 == 0 && (double)vector2.Y > (double)room.Y && num2 != 1 || num2 == 2 && (double)vector2.Y >= (double)(y + height / 2))
                {
                    --vector2.Y;
                    num2 = 0;
                }
                else if (num4 == 1 && (double)vector2.Y < (double)(y + height / 2) && num2 != 0 || num2 == 2 && (double)vector2.Y <= (double)room.Y)
                {
                    ++vector2.Y;
                    num2 = 1;
                }
                else
                {
                    ++vector2.X;
                    ++num3;
                    num2 = 2;
                }
                polygon.addPoint(vector2);
            }
            int num5 = height - 4 - (int)((double)vector2.Y - (double)room.Y);

            ++vector2.Y;
            int num6 = 2;

            polygon.addPoint(vector2);
            int num7 = 0;

            while (num7 < num5)
            {
                int num4 = mineRandom.Next(3);
                if (num4 == 0 && (double)vector2.X < (double)room.Right && num6 != 1 || num6 == 2 && (double)vector2.X <= (double)(x + width / 2 + 1))
                {
                    ++vector2.X;
                    num6 = 0;
                }
                else if (num4 == 1 && (double)vector2.X > (double)(x + width / 2 + 1) && num6 != 0 || num6 == 2 && (double)vector2.X >= (double)room.Right)
                {
                    --vector2.X;
                    num6 = 1;
                }
                else
                {
                    ++vector2.Y;
                    ++num7;
                    num6 = 2;
                }
                polygon.addPoint(vector2);
            }
            int num8 = (int)vector2.X - (int)polygon.Lines[0].Start.X + width / 4;

            --vector2.X;
            int num9 = 2;

            polygon.addPoint(vector2);
            int num10 = 0;

            while (num10 < num8)
            {
                int num4 = mineRandom.Next(3);
                if (num4 == 0 && (double)vector2.Y > (double)(y + height / 2) && (num9 != 1 && !polygon.containsPoint(new Vector2(vector2.X, vector2.Y - 1f))) || num9 == 2 && (double)vector2.Y >= (double)room.Bottom)
                {
                    --vector2.Y;
                    num9 = 0;
                }
                else if (num4 == 1 && (double)vector2.Y < (double)room.Bottom && num9 != 0 || num9 == 2 && (double)vector2.Y <= (double)(y + height / 2))
                {
                    ++vector2.Y;
                    num9 = 1;
                }
                else
                {
                    --vector2.X;
                    ++num10;
                    num9 = 2;
                }
                polygon.addPoint(vector2);
            }
            int num11 = (int)vector2.Y - (int)polygon.Lines[0].Start.Y - 1;

            --vector2.Y;
            int num12 = 2;

            polygon.addPoint(vector2);
            int num13 = 0;

            while (num13 < num11)
            {
                int num4 = mineRandom.Next(3);
                if (num4 == 0 && (double)vector2.X < (double)room.Center.X && (!polygon.containsPoint(new Vector2(vector2.X + 1f, vector2.Y)) && !polygon.containsPoint(new Vector2(vector2.X, vector2.Y - 1f))) || num12 == 2 && (double)vector2.X <= (double)room.X)
                {
                    ++vector2.X;
                    num12 = 0;
                }
                else if (num4 == 1 && (double)vector2.X > (double)room.X && num12 != 0 || num12 == 2 && (double)vector2.X >= (double)room.Center.X)
                {
                    --vector2.X;
                    num12 = 1;
                }
                else
                {
                    --vector2.Y;
                    ++num13;
                    num12 = 2;
                }
                polygon.addPoint(vector2);
            }
            if ((double)vector2.X < (double)(int)polygon.Lines[0].Start.X)
            {
                int num4 = (int)polygon.Lines[0].Start.X + 1 - (int)vector2.X - 1;
                for (int index = 0; index < num4; ++index)
                {
                    ++vector2.X;
                    polygon.addPoint(vector2);
                }
            }
            return(polygon);
        }
Пример #9
0
        public static Polygon getGentlerBorderForLakes(Rectangle room, Random mineRandom, Rectangle smoothZone)
        {
            int       width     = room.Width - 2;
            int       height    = room.Height - 2;
            int       x         = room.X + 1;
            int       y         = room.Y + 1;
            Rectangle rectangle = new Rectangle(x, y, width, height);
            Polygon   polygon   = new Polygon();
            Vector2   vector2   = new Vector2((float)mineRandom.Next(x + 5, x + 8), (float)mineRandom.Next(y + 5, y + 8));

            polygon.Lines.Add(new Polygon.Line(vector2, new Vector2(vector2.X + 1f, vector2.Y)));
            ++vector2.X;
            int        num1     = width - 12;
            List <int> intList1 = new List <int>()
            {
                2, 2, 2
            };
            int num2 = 0;

            while (num2 < num1)
            {
                int num3 = mineRandom.Next(3);
                if (num3 == 0 && (double)vector2.Y > (double)y && (!intList1.Contains(1) && !smoothZone.Contains((int)vector2.X, (int)vector2.Y)))
                {
                    --vector2.Y;
                    intList1.Add(0);
                }
                else if (num3 == 1 && (double)vector2.Y < (double)(y + height / 2) && (!intList1.Contains(0) && !smoothZone.Contains((int)vector2.X, (int)vector2.Y)))
                {
                    ++vector2.Y;
                    intList1.Add(1);
                }
                else
                {
                    ++vector2.X;
                    ++num2;
                    intList1.Add(2);
                }
                intList1.RemoveAt(0);
                polygon.addPoint(vector2);
            }
            int num4 = height - 4 - (int)((double)vector2.Y - (double)room.Y);

            ++vector2.Y;
            List <int> intList2 = new List <int>()
            {
                2, 2, 2
            };

            polygon.addPoint(vector2);
            int num5 = 0;

            while (num5 < num4)
            {
                int num3 = mineRandom.Next(3);
                if (num3 == 0 && (double)vector2.X < (double)(x + width) && (!intList2.Contains(1) && !smoothZone.Contains((int)vector2.X, (int)vector2.Y)))
                {
                    ++vector2.X;
                    intList2.Add(0);
                }
                else if (num3 == 1 && (double)vector2.X > (double)(x + width / 2 + 1) && (!intList2.Contains(0) && !smoothZone.Contains((int)vector2.X, (int)vector2.Y)))
                {
                    --vector2.X;
                    intList2.Add(1);
                }
                else
                {
                    ++vector2.Y;
                    ++num5;
                    intList2.Add(2);
                }
                intList2.RemoveAt(0);
                polygon.addPoint(vector2);
            }
            int num6 = (int)vector2.X - (int)polygon.Lines[0].Start.X + 1;

            --vector2.X;
            List <int> intList3 = new List <int>()
            {
                2, 2, 2
            };

            polygon.addPoint(vector2);
            int num7 = 0;

            while (num7 < num6)
            {
                int num3 = mineRandom.Next(3);
                if (num3 == 0 && (double)vector2.Y > (double)(y + height / 2) && (!intList3.Contains(1) && !polygon.containsPoint(new Vector2(vector2.X, vector2.Y - 1f))) && !smoothZone.Contains((int)vector2.X, (int)vector2.Y))
                {
                    --vector2.Y;
                    intList3.Add(0);
                }
                else if (num3 == 1 && (double)vector2.Y < (double)(y + height) && (!intList3.Contains(0) && !smoothZone.Contains((int)vector2.X, (int)vector2.Y)))
                {
                    ++vector2.Y;
                    intList3.Add(1);
                }
                else
                {
                    --vector2.X;
                    ++num7;
                    intList3.Add(2);
                }
                intList3.RemoveAt(0);
                polygon.addPoint(vector2);
            }
            int num8 = (int)vector2.Y - (int)polygon.Lines[0].Start.Y - 1;

            --vector2.Y;
            List <int> intList4 = new List <int>()
            {
                2, 2, 2
            };

            polygon.addPoint(vector2);
            int num9 = 0;

            while (num9 < num8)
            {
                int num3 = mineRandom.Next(3);
                if (num3 == 0 && (double)vector2.X < (double)(int)polygon.Lines[0].Start.X && (!intList4.Contains(1) && !polygon.containsPoint(new Vector2(vector2.X + 1f, vector2.Y))) && (!polygon.containsPoint(new Vector2(vector2.X, vector2.Y - 1f)) && !smoothZone.Contains((int)vector2.X, (int)vector2.Y)))
                {
                    ++vector2.X;
                    intList4.Add(0);
                }
                else if (num3 == 1 && (double)vector2.X > (double)(x + 1) && (!intList4.Contains(0) && !smoothZone.Contains((int)vector2.X, (int)vector2.Y)))
                {
                    --vector2.X;
                    intList4.Add(1);
                }
                else
                {
                    --vector2.Y;
                    ++num9;
                    intList4.Add(2);
                }
                intList4.RemoveAt(0);
                polygon.addPoint(vector2);
            }
            if ((double)vector2.X < (double)(int)polygon.Lines[0].Start.X)
            {
                int num3 = (int)polygon.Lines[0].Start.X + 1 - (int)vector2.X - 1;
                for (int index = 0; index < num3; ++index)
                {
                    ++vector2.X;
                    polygon.addPoint(vector2);
                }
            }
            return(polygon);
        }