示例#1
0
    /// <summary>
    /// Keeps randomly picking a room, with a specified room type, that has more exits to avoid a dead end.
    /// </summary>
    /// <param name="prefab">Room prefab reference.</param>
    /// <param name="pickRandomRoomType">The room type to match.</param>
    public void AvoidDeadEnd(ref Room prefab, Room.RoomTypes pickRandomRoomType)
    {
        int additionalSeed = 1;

        while (prefab.GetComponentsInChildren <RoomConnector>().Length < 2)
        {
            prefab = rnd.GetRandomByRoomType(Rooms, pickRandomRoomType);
            additionalSeed++;
        }
    }
示例#2
0
    /// <summary>
    /// Returns an array of the room types that the parameter type can connect to.
    /// </summary>
    /// <returns>The connections possible to the parameter type.</returns>
    public Room.RoomTypes[] GetPossibleConnectionBetweenRoomsByRoomType(Room.RoomTypes roomType)
    {
        switch (roomType)
        {
        case Room.RoomTypes.Hall:
            return(hallConnectionRules);

        case Room.RoomTypes.Corridor:
            return(corridorConnectionRules);

        case Room.RoomTypes.Junction:
            return(junctionConnectionRules);

        default:
            return(null);
        }
    }
示例#3
0
    /// <summary>
    /// Retrieves a random element from the passed in list of rooms based on the specified type.
    /// </summary>
    /// <param name="rooms">Rooms to choose from.</param>
    /// <param name="roomTypeToMatch">The room type that needs to match the selected room.</param>
    /// <param name="additionalSeed">Optional parameter which is added to the random seed generator.</param>
    /// <returns>Returns a random room from the rooms list matching the room type.</returns>
    public Room GetRandomByRoomType(IEnumerable <Room> rooms, Room.RoomTypes roomTypeToMatch)
    {
        var matchingRooms = rooms.Where(m => m.GetRoomType() == roomTypeToMatch).ToArray();

        return(GetRandom(matchingRooms));
    }