Example #1
0
        /// <summary>
        /// This is used to get the very top left corner of the grid.
        /// </summary>
        /// <returns></returns>
        private Point GetLowestPoint()
        {
            Point lowestNegative = new Point(1, 1);

            // Check the cells for lowest negative.
            Cells.ForEach(obj => lowestNegative.X = lowestNegative.X > obj.Location.X ? obj.Location.X : lowestNegative.X);
            Cells.ForEach(obj => lowestNegative.Y = lowestNegative.Y > obj.Location.Y ? obj.Location.Y : lowestNegative.Y);

            // Check the tunnels for lowest negative.
            Tunnels.ForEach(obj => {
                obj.AnglePoint.ForEach(obj2 => lowestNegative.X = lowestNegative.X > obj2.X ? obj2.X : lowestNegative.X);
                obj.AnglePoint.ForEach(obj2 => lowestNegative.Y = lowestNegative.Y > obj2.Y ? obj2.Y : lowestNegative.Y);
            });

            return(lowestNegative);
        }
Example #2
0
        private Point GetHighestPoint()
        {
            // Get the maximum coordinates of the cells and tunnels.
            Point highestPoint = new Point(1, 1);

            Cells.ForEach(obj => highestPoint.X = highestPoint.X < (obj.Location + obj.Size).X ? (obj.Location + obj.Size).X : highestPoint.X);
            Cells.ForEach(obj => highestPoint.Y = highestPoint.Y < (obj.Location + obj.Size).Y ? (obj.Location + obj.Size).Y : highestPoint.Y);

            Tunnels.ForEach(obj => {
                obj.AnglePoint.ForEach(obj2 => highestPoint.X = highestPoint.X < obj2.X ? obj2.X : highestPoint.X);
                obj.AnglePoint.ForEach(obj2 => highestPoint.Y = highestPoint.Y < obj2.Y ? obj2.Y : highestPoint.Y);
            });

            // Add some space.
            // TODO: For some reason, certain parts on the very right bottom would get cut off.
            // Apparently it has something to do with space. So, this is here is a temp fix.
            //highestPoint += increment;
            highestPoint += new Point(200, 200);

            return(highestPoint);
        }
Example #3
0
        /// <summary>
        /// This function is used to adjust the tunnel and cell coordinates.
        /// </summary>
        private void AdjustNegativePoint()
        {
            // First, we need to shift the cells and tunnels to get rid of
            // any negative coordinates.
            Point lowestNegative = GetLowestPoint();

            // Invert them and add 2, and then add them back to the cells and tunnels.
            // Only add the ones that are in a negative.
            if (lowestNegative.X < 0)
            {
                lowestNegative.X *= -1;
                lowestNegative.X += 2;
                Cells.ForEach(obj => obj.Location.X += lowestNegative.X);
                Tunnels.ForEach(obj => obj.AnglePoint.ForEach(obj2 => obj2.X += lowestNegative.X));
            }
            if (lowestNegative.Y < 0)
            {
                lowestNegative.Y *= -1;
                lowestNegative.Y += 2;
                Cells.ForEach(obj => obj.Location.Y += lowestNegative.Y);
                Tunnels.ForEach(obj => obj.AnglePoint.ForEach(obj2 => obj2.Y += lowestNegative.Y));
            }
        }