Example #1
0
        public bool AreOverlapping(BuildingCoordinates b1, BuildingCoordinates b2, out int[] combined)
        {
            List <int> coordinateList = new List <int>();

            Rectangle r1 = b1.GetRectangle();
            Rectangle r2 = b2.GetRectangle();

            bool intersects = r1.IntersectsWith(r2);

            if (intersects)
            {
                // Left side of first building
                coordinateList.Add(b1.X1);
                coordinateList.Add(b1.Y1);

                combined = null;
            }
            else
            {
                // Now calculate the X, Y, X, Y, ... coordinate list
                coordinateList.Add(b1.X1);
                coordinateList.Add(b1.Y1);
                coordinateList.Add(b1.X2);
                coordinateList.Add(b1.Y2);

                coordinateList.Add(b2.X1);
                coordinateList.Add(b2.Y1);
                coordinateList.Add(b2.X2);
                coordinateList.Add(b2.Y2);

                combined = coordinateList.ToArray();
            }

            return(intersects);
        }
Example #2
0
        public Rectangle GetScaledRectangle(int canvasWidth, int canvasHeight, int XMax, int YMax)
        {
            BuildingCoordinates b = GetScaledCoordinates(canvasWidth, canvasHeight, XMax, YMax);

            return(b.GetRectangle());
        }