public DoorInstance(OrthogonalLine doorLine, Vector2Int facingDirection, RoomBase connectedRoom, RoomInstanceGrid2D connectedRoomInstance)
 {
     this.doorLine              = doorLine;
     this.facingDirection       = facingDirection;
     this.connectedRoom         = connectedRoom;
     this.connectedRoomInstance = connectedRoomInstance;
     this.isHorizontal          = FacingDirection == Vector2Int.up || FacingDirection == Vector2Int.down;
 }
Example #2
0
 public RoomInstance(RoomBase room, bool isCorridor, ConnectionBase connection, GameObject roomTemplatePrefab, GameObject roomTemplateInstance, Vector3Int position, Polygon2D outlinePolygon)
 {
     this.room                 = room;
     this.connection           = connection;
     this.roomTemplatePrefab   = roomTemplatePrefab;
     this.roomTemplateInstance = roomTemplateInstance;
     this.position             = position;
     this.outlinePolygon       = outlinePolygon;
     this.isCorridor           = isCorridor;
 }
Example #3
0
        /// <summary>
        ///     Setups room shapes for a given room.
        /// </summary>
        /// <param name="room"></param>
        protected List <GameObject> GetRoomTemplates(RoomBase room)
        {
            var roomTemplates = room.GetRoomTemplates();

            if (roomTemplates == null || roomTemplates.Count == 0)
            {
                return(GetRoomTemplates(config.LevelGraph.DefaultRoomTemplateSets, config.LevelGraph.DefaultIndividualRoomTemplates));
            }

            return(roomTemplates);
        }
Example #4
0
        /// <summary>
        /// Adds a given room together with a list of available room templates.
        /// </summary>
        /// <param name="room">Room that is added to the level description.</param>
        /// <param name="roomTemplates">Room templates that are available for the room.</param>
        public void AddRoom(RoomBase room, List <GameObject> roomTemplates)
        {
            if (room == null)
            {
                throw new ArgumentNullException(nameof(room));
            }
            if (roomTemplates == null)
            {
                throw new ArgumentNullException(nameof(roomTemplates));
            }
            if (roomTemplates.Count == 0)
            {
                throw new ArgumentException($"There must be at least one room template for each room. Room: {room}", nameof(roomTemplates));
            }

            levelDescription.AddRoom(room, GetBasicRoomDescription(roomTemplates));
        }
Example #5
0
        /// <summary>
        /// Adds a given connection together with a corridor room between the two rooms.
        /// </summary>
        /// <param name="connection">Connection that is added to the level description</param>
        /// <param name="corridorRoom">Room that represents the corridor room between the two rooms from the connection</param>
        /// <param name="corridorRoomTemplates">Room templates that are available for the corridor</param>
        public void AddCorridorConnection(ConnectionBase connection, RoomBase corridorRoom, List <GameObject> corridorRoomTemplates)
        {
            if (connection == null)
            {
                throw new ArgumentNullException(nameof(connection));
            }
            if (corridorRoom == null)
            {
                throw new ArgumentNullException(nameof(corridorRoom));
            }
            if (corridorRoomTemplates.Count == 0)
            {
                throw new ArgumentException($"There must be at least one room template for each corridor room. Room: {corridorRoom}", nameof(corridorRoom));
            }

            connections.Add(connection);
            corridorToConnectionMapping.Add(corridorRoom, connection);

            var corridorRoomDescription = GetCorridorRoomDescription(corridorRoomTemplates);

            levelDescription.AddRoom(corridorRoom, corridorRoomDescription);
            levelDescription.AddConnection(connection.From, corridorRoom);
            levelDescription.AddConnection(connection.To, corridorRoom);
        }
 /// <summary>
 /// Gets information about a room instance that corresponds to a given room.
 /// </summary>
 /// <param name="room"></param>
 /// <returns></returns>
 public RoomInstance GetRoomInstance(RoomBase room)
 {
     return(roomInstances[room]);
 }
 public RoomInstanceGrid2D(RoomBase room, bool isCorridor, ConnectionBase connection, GameObject roomTemplatePrefab, GameObject roomTemplateInstance, Vector3Int position, Polygon2D outlinePolygon) : base(room, isCorridor, connection, roomTemplatePrefab, roomTemplateInstance, position, outlinePolygon)
 {
 }
 public DoorInstanceGrid2D(OrthogonalLine doorLine, Vector2Int facingDirection, RoomBase connectedRoom, RoomInstanceGrid2D connectedRoomInstance) : base(doorLine, facingDirection, connectedRoom, connectedRoomInstance)
 {
 }