public GameObject getRoomPF(Room.RoomDirection roomDirection)
    {
        switch (roomDirection)
        {
        case Room.RoomDirection.OneDoor:
            return(miniMapPartsResources.Find(x => x.GetComponent <MiniMapPart>().roomDirection == MiniMapPart.RoomDirMM.OneDoor));

        case Room.RoomDirection.TwoDoorLinear:
            return(miniMapPartsResources.Find(x => x.GetComponent <MiniMapPart>().roomDirection == MiniMapPart.RoomDirMM.TwoDoorLinear));

        case Room.RoomDirection.TwoDoorCurve:
            return(miniMapPartsResources.Find(x => x.GetComponent <MiniMapPart>().roomDirection == MiniMapPart.RoomDirMM.TwoDoorCurve));

        case Room.RoomDirection.ThreeDoor:
            return(miniMapPartsResources.Find(x => x.GetComponent <MiniMapPart>().roomDirection == MiniMapPart.RoomDirMM.ThreeDoor));

        case Room.RoomDirection.FourDoor:
            return(miniMapPartsResources.Find(x => x.GetComponent <MiniMapPart>().roomDirection == MiniMapPart.RoomDirMM.FourDoor));

        default:
            break;
        }

        return(miniMapPartsResources[0].gameObject);
    }
Beispiel #2
0
    /// <summary>
    /// returns a Random room
    /// </summary>
    /// <param name="neighbourRoomCount">Room Count</param>
    /// <param name="roomType">
    ///
    /// 0 = Start Room
    /// 1 = Enemy Room
    ///
    /// </param>
    /// <returns></returns>
    public GameObject returnRandomRoom(int neighbourRoomCount, int roomType, Vector2Int roomPos)
    {
        List <GameObject> rList    = new List <GameObject>();
        List <GameObject> roomList = new List <GameObject>();

        switch (roomType)
        {
        case 0:
            roomList = resourcesStartRoomList;
            break;

        case 1:
            roomList = resourcesEnemyRoomList;
            break;
        }

        foreach (GameObject room in roomList)
        {
            Room.RoomDirection roomDir = room.GetComponent <Room>().roomDirection;

            switch (neighbourRoomCount)
            {
            case 1:
                if (roomDir == Room.RoomDirection.OneDoor)
                {
                    rList.Add(room);
                }
                break;

            case 2:

                if (roomDir == Room.RoomDirection.TwoDoorLinear)
                {
                    if (roomPos.y + 1 < worldLength && roomPos.y - 1 >= 0)
                    {
                        if (map[roomPos.x, roomPos.y + 1] == 1 && (map[roomPos.x, roomPos.y - 1] == 1))
                        {
                            rList.Add(room);
                        }
                    }

                    if (roomPos.x + 1 < worldWidth && roomPos.x - 1 >= 0)
                    {
                        if (map[roomPos.x + 1, roomPos.y] == 1 && (map[roomPos.x - 1, roomPos.y] == 1))
                        {
                            rList.Add(room);
                        }
                    }
                }

                if (roomDir == Room.RoomDirection.TwoDoorCurve)
                {
                    if (roomPos.y + 1 < worldLength && roomPos.x + 1 < worldWidth)
                    {
                        if (map[roomPos.x, roomPos.y + 1] == 1 && (map[roomPos.x + 1, roomPos.y] == 1))
                        {
                            rList.Add(room);
                        }
                    }

                    if (roomPos.x + 1 < worldWidth && roomPos.y - 1 >= 0)
                    {
                        if (map[roomPos.x, roomPos.y - 1] == 1 && (map[roomPos.x + 1, roomPos.y] == 1))
                        {
                            rList.Add(room);
                        }
                    }

                    if (roomPos.x - 1 >= 0 && roomPos.y - 1 >= 0)
                    {
                        if (map[roomPos.x, roomPos.y - 1] == 1 && (map[roomPos.x - 1, roomPos.y] == 1))
                        {
                            rList.Add(room);
                        }
                    }

                    if (roomPos.y + 1 < worldLength && roomPos.x - 1 >= 0)
                    {
                        if (map[roomPos.x, roomPos.y + 1] == 1 && (map[roomPos.x - 1, roomPos.y] == 1))
                        {
                            rList.Add(room);
                        }
                    }
                }
                break;

            case 3:

                if (roomDir == Room.RoomDirection.ThreeDoor)
                {
                    rList.Add(room);
                }
                break;

            case 4:

                if (roomDir == Room.RoomDirection.FourDoor)
                {
                    rList.Add(room);
                }
                break;
            }
        }

        if (neighbourRoomCount == 2)
        {
            /*
             * if (roomPos.y + 1 < worldLength && roomPos.y - 1 >= 0)
             *  if (map[roomPos.x, roomPos.y + 1] == 1 && (map[roomPos.x, roomPos.y - 1] == 1)) q = Quaternion.identity;
             *
             * if (roomPos.x + 1 < worldWidth && roomPos.x - 1 >= 0)
             *  if (map[roomPos.x + 1, roomPos.y] == 1 && (map[roomPos.x - 1, roomPos.y] == 1)) q = Quaternion.Euler(0, 90, 0);
             */
        }

        if (rList.Count == 0)
        {
            Debug.Log("rList Count " + rList.Count + "Door Count: " + neighbourRoomCount);
        }

        return(rList[UnityEngine.Random.Range(0, rList.Count)]);
    }