public RoomTypeDataTransferObject(RoomTypeData data)
 {
     Id                   = data.Id;
     Name                 = data.Name;
     NumberOfBeds         = data.NumberOfBeds;
     HasBalcony           = data.HasBalcony;
     IsDisabilityFriendly = data.IsDisabilityFriendly;
     RoomData             = data.RoomData.Select(x => new RoomDataTransferObject(x)).ToList();
 }
示例#2
0
 public RoomData ToRoomData()
 {
     return(new RoomData
     {
         Id = Id,
         RoomNumber = RoomNumber,
         RoomTypeDataId = RoomTypeDataId,
         RoomTypeData = RoomTypeData.ToRoomTypeData(),
         Price = Price,
         OnPromotion = OnPromotion,
         OnPromotionPrice = OnPromotionPrice,
         IsOccupied = IsOccupied,
         BookedFrom = BookedFrom,
         BookedTo = BookedTo,
         Guests = Guests.Select(x => x.ToGuestData()).ToList()
     });
 }
示例#3
0
    public RoomTypeData getRoomType(string roomtype_code)
    {
        RoomTypeData RoomType_data = new RoomTypeData();

        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle();

        oracleObj.SelectCommand = "Select * From Room_Type Where Room_Type_CODE='" + roomtype_code + "'";
        DataView allData = (DataView)oracleObj.Select(DataSourceSelectArguments.Empty);

        foreach (DataRowView rowData in allData)
        {
            RoomType_data.RoomType_Code     = rowData["Room_Type_CODE"].ToString();
            RoomType_data.RoomType_ThaiName = rowData["Room_Type_THAINAME"].ToString();
            RoomType_data.RoomType_EngName  = rowData["Room_Type_ENGNAME"].ToString();
        }

        return(RoomType_data);
    }
示例#4
0
    public List <RoomTypeData> getRoomType()
    {
        List <RoomTypeData> RoomTypeData = new List <RoomTypeData>();

        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle();

        oracleObj.SelectCommand = "Select * From Room_Type Order By Room_Type_CODE";
        DataView allData = (DataView)oracleObj.Select(DataSourceSelectArguments.Empty);

        foreach (DataRowView rowData in allData)
        {
            RoomTypeData RoomType_data = new RoomTypeData();
            RoomType_data.RoomType_Code     = rowData["Room_Type_CODE"].ToString();
            RoomType_data.RoomType_ThaiName = rowData["Room_Type_THAINAME"].ToString();
            RoomType_data.RoomType_EngName  = rowData["Room_Type_ENGNAME"].ToString();
            RoomTypeData.Add(RoomType_data);
        }

        return(RoomTypeData);
    }
    /// <summary>
    /// Generates a dungeon floor map
    /// </summary>
    /// <returns></returns>
    public void GenerateNewDungeon()
    {
        Init();

        bool criticalPathComplete = false;

        while (!criticalPathComplete)
        {
            criticalPathComplete = GenerateCriticalPath();
        }

        PopulateExtraRooms();
        //PrintLayout();

        for (int y = 0; y < layout.GetLength(1); y++)
        {
            for (int x = 0; x < layout.GetLength(0); x++)
            {
                if (layout[y, x] == null || layout[y, x].Equals("") || layout[y, x].Equals("X"))
                {
                    roomTypeData.Add(new RoomTypeData(x, y, RoomType.EMPTY));
                }
                else
                {
                    List <Vector2Int> validNeighboringRooms = GetValidNeighboringRooms(x, y);
                    switch (validNeighboringRooms.Count)
                    {
                    case 0:
                        Debug.LogWarning("Somehow the above if statement didn't catch this??");
                        roomTypeData.Add(new RoomTypeData(x, y, RoomType.EMPTY));
                        break;

                    case 1:
                        roomTypeData.Add(new RoomTypeData(x, y, RoomType.ONEDOOR));
                        break;

                    case 2:
                        roomTypeData.Add(new RoomTypeData(x, y, RoomType.TWODOOR));
                        break;

                    case 3:
                        roomTypeData.Add(new RoomTypeData(x, y, RoomType.THREEDOOR));
                        break;

                    case 4:
                        roomTypeData.Add(new RoomTypeData(x, y, RoomType.FOURDOOR));
                        break;

                    default:
                        Debug.LogError("Something went horribly wrong in populating RoomTypeData");
                        break;
                    }
                }
            }
        }

        // now we need to create a map using preconstructed room prefabs
        for (int i = 0; i < roomTypeData.Count; i++)
        {
            RoomTypeData thisRoomData      = roomTypeData[i];
            GameObject   roomPrefab        = GetRoomPrefab(thisRoomData.roomType);
            Vector3Int   roomGridPosition  = new Vector3Int(roomWidth * thisRoomData.x, roomHeight * thisRoomData.y, 0);
            Vector3      roomWorldPosition = GlobalGrid.GetGrid().CellToWorld(roomGridPosition);

            GameObject newRoom = Instantiate(roomPrefab, roomWorldPosition, Quaternion.identity);

            if (thisRoomData.roomType == RoomType.FOURDOOR)
            {
                // we don't have to align anything, since any orientation of a 4 door room will work.
                // give it a random rotation then move on
                newRoom.GetComponent <RoomDirection>().RotateRandom();
                continue;
            }
            else if (thisRoomData.roomType == RoomType.EMPTY)
            {
                // we don't care about the orientation of empty rooms
                continue;
            }

            Vector2[] adjacentRoomDirections = GetAdjacentRoomDirections(thisRoomData.x, thisRoomData.y);
            Vector2[] roomDoorDirections     = newRoom.GetComponent <RoomDirection>().GetDoorDirections();

            if (!Vector2ArraysAreEqual(adjacentRoomDirections, roomDoorDirections))
            {
                // we need to rotate the room up to 3 times
                bool rotationMatchFound = false;
                for (int j = 0; j < 3; j++)
                {
                    newRoom.GetComponent <RoomDirection>().RotateRoom90Degrees();
                    roomDoorDirections = newRoom.GetComponent <RoomDirection>().GetDoorDirections();
                    if (Vector2ArraysAreEqual(adjacentRoomDirections, roomDoorDirections))
                    {
                        rotationMatchFound = true;
                        break;
                    }
                }

                if (!rotationMatchFound && thisRoomData.roomType == RoomType.TWODOOR)
                {
                    Debug.Log("Resorting to alternate two door!");
                    // we need to try the alternate 2 door room
                    Destroy(newRoom);
                    roomPrefab         = twoDoorAlternatePrefabs[Random.Range(0, twoDoorAlternatePrefabs.Length)];
                    newRoom            = Instantiate(roomPrefab, roomWorldPosition, Quaternion.identity);
                    roomDoorDirections = newRoom.GetComponent <RoomDirection>().GetDoorDirections();

                    if (!Vector2ArraysAreEqual(adjacentRoomDirections, roomDoorDirections))
                    {
                        // we need to rotate the room up to 3 times
                        rotationMatchFound = false;
                        for (int k = 0; k < 3; k++)
                        {
                            newRoom.GetComponent <RoomDirection>().RotateRoom90Degrees();
                            roomDoorDirections = newRoom.GetComponent <RoomDirection>().GetDoorDirections();
                            if (Vector2ArraysAreEqual(adjacentRoomDirections, roomDoorDirections))
                            {
                                rotationMatchFound = true;
                                break;
                            }
                        }

                        if (!rotationMatchFound)
                        {
                            Debug.LogError("Could not figure out the rotation of this two door room after trying both types.");
                        }
                    }
                }
                else if (!rotationMatchFound)
                {
                    Debug.LogError("Serious problem here, we couldn't find a rotation that worked.");
                }
            }
        }
    }