Ejemplo n.º 1
0
 public void Construct(IMapRoomFactory mapRoomFactory,
                       IMapDataFactory mapDataFactory,
                       IHallwayFactory hallwayFactory,
                       IPhysicalMapRoomFactory physMapRoomFactory,
                       IMapRoomTools mapRoomTools,
                       IPointTriangulation pointTriangulation)
 {
     this.mapRoomFactory     = mapRoomFactory;
     this.mapDataFactory     = mapDataFactory;
     this.hallwayFactory     = hallwayFactory;
     this.physMapRoomFactory = physMapRoomFactory;
     this.mapRoomTools       = mapRoomTools;
     this.pointTriangulation = pointTriangulation;
 }
Ejemplo n.º 2
0
 public MapRoomFactory(IMapRoomTools mapRoomTools)
 {
     this.mapRoomTools = mapRoomTools;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates lines between rooms connected by line segments.
        /// </summary>
        /// <param name="connectingLineSegments">Graph line segments</param>
        /// <param name="rooms">Rooms with found connections in point triangulation connected tree</param>
        /// <param name="sizeOfHallways">Girth of the hallways</param>
        /// <param name="mapRoomTools">Room tools</param>
        /// <returns></returns>
        public List <Line> CreateHallwayLinesFromSegments(List <Line> connectingLineSegments, List <MapRoom> rooms, int sizeOfHallways, IMapRoomTools mapRoomTools)
        {
            List <Line> hallwayLines = new List <Line>();

            // Buffer size to make hallway lines within room boundries
            int hallwayBuffer = sizeOfHallways / 2;

            foreach (Line segment in connectingLineSegments)
            {
                MapRoom r0;
                MapRoom r1;
                r0 = mapRoomTools.FindRoomContainingPoint(rooms, segment.p0);
                r1 = mapRoomTools.FindRoomContainingPoint(rooms, segment.p1);

                Point midPoint = mapRoomTools.MidPointBetweenMapRooms(r0, r1);

                Vector2 startPoint;
                Vector2 endPoint;

                if (mapRoomTools.IsPointBetweenXBoundariesOfGivenRooms(midPoint, r0, r1, hallwayBuffer)) // Straight hallway
                {
                    // Create lines from mid point then up and down to rooms.
                    startPoint = new Vector2(midPoint.X, r0.centerPoint.y);
                    endPoint   = new Vector2(midPoint.X, r1.centerPoint.y);

                    hallwayLines.AddRange(CreateHallwayLinesOfSetWidth(startPoint, endPoint, sizeOfHallways, false));
                }
                else if (mapRoomTools.IsPointBetweenYBoundariesOfGivenRooms(midPoint, r0, r1, hallwayBuffer)) // Straight hallway
                {
                    // Create lines from mid point then left and right to rooms.
                    startPoint = new Vector2(r0.centerPoint.x, midPoint.Y);
                    endPoint   = new Vector2(r1.centerPoint.x, midPoint.Y);

                    hallwayLines.AddRange(CreateHallwayLinesOfSetWidth(startPoint, endPoint, sizeOfHallways, true));
                }
                else // Right angle bend in hallway
                {
                    // Meeting point between lines
                    endPoint = new Vector2(r0.centerPoint.x, r1.centerPoint.y);

                    // Is bend in the 'north east' quad?
                    bool northEastBend = false;
                    if (r0.centerPoint.x > r1.centerPoint.x && r0.centerPoint.y < r1.centerPoint.y)
                    {
                        northEastBend = true;
                    }

                    startPoint = new Vector2(r0.centerPoint.x, r0.centerPoint.y);
                    hallwayLines.AddRange(CreateHallwayLinesOfSetWidth(startPoint, endPoint, sizeOfHallways, false, northEastBend));

                    startPoint = new Vector2(r1.centerPoint.x, r1.centerPoint.y);
                    hallwayLines.AddRange(CreateHallwayLinesOfSetWidth(startPoint, endPoint, sizeOfHallways, true, northEastBend));
                }
            }

            return(hallwayLines);
        }