SetupRoom() public method

public SetupRoom ( IntRange widthRange, IntRange heightRange, int columns, int rows ) : void
widthRange IntRange
heightRange IntRange
columns int
rows int
return void
示例#1
0
    void PlaceStartRoom()
    {
        Room startRoom = ScriptableObject.CreateInstance <Room>();

        startRoom.SetupRoom(roomWidth, roomHeight);
        rooms.Add(startRoom);
    }
示例#2
0
    void MakeRooms()
    {
        tempSeed = seed;

        if (maxNumberOfRooms <= 0)
        {
            return;
        }

        int width  = 15;
        int height = 15;

        Vector2 pos = new Vector2(0, 0);

        GameObject roomGO = Instantiate(roomTemplate, pos, Quaternion.identity, roomHolder.transform) as GameObject;
        Room       room   = roomGO.GetComponent <Room>();

        room.SetupRoom(pos, width, height, tempSeed, randomFillPercent);
        AddRoomToMap(room.GetRoomNodeLayout(), pos);

        bool flag = true;

        while (flag)
        {
            tempSeed = tempSeed.GetHashCode().ToString();
            pos     += new Vector2(15, 0);
            if (pos.x >= mapWidth)
            {
                pos.x  = 0;
                pos.y += 15;
            }

            if (pos.y >= mapHeight - 15)
            {
                flag = false;
                return;
            }

            roomGO = Instantiate(roomTemplate, pos, Quaternion.identity, roomHolder.transform) as GameObject;
            room   = roomGO.GetComponent <Room>();
            room.SetupRoom(pos, width, height, tempSeed, randomFillPercent);
            AddRoomToMap(room.GetRoomNodeLayout(), pos);
        }
    }
    // create a Room object (not instantiated in game yet just the object)
    public Room CreateRoom()
    {
        Room room = new Room();

        Vector3 randomPos = new Vector3(Random.Range(1, mapSizeX), 0f, Random.Range(1, mapSizeY));

        room.SetupRoom(maxRoomSize, maxRoomSize, randomPos);

        return(room);
    }
示例#4
0
    /// <summary>
    /// Creates and Sets up the Room
    /// </summary>
    void CreateRoom()
    {
        room = new Room();
        room.SetupRoom(roomWidth, roomHeight, columns, rows);

        Vector3    playerPos      = new Vector3(room.xPos, room.yPos, 0);
        GameObject playerInstance = Instantiate(player, playerPos, Quaternion.identity) as GameObject;

        cam.target = playerInstance.transform;
    }
示例#5
0
    protected void GenerateRemainingRooms(Board board)
    {
        int failedRoomAttempts = 0;
        int roomsToGenerate    = numRooms.Random;

        InitRngIdentifiers(roomsToGenerate);

        //Make and shuffle room ids

        for (int i = 1; i < roomsToGenerate; i++)
        {
            if (failedRoomAttempts >= failedRoomsAllowed)
            {
                Debug.Log("Failed room total reached");
                break;
            }
            Room stemRoom = SelectStemRoom();
            if (stemRoom.CanMakeMoreDoors())
            {
                Doorway possibleDoorway = stemRoom.PossibleDoorway();

                Corridor corridorAttempt = new Corridor();
                corridorAttempt.SetupCorridor(possibleDoorway, board, 0, identifier);

                Room roomAttempt = RandomRoom();
                roomAttempt.SetupRoom(corridorAttempt.door2, identifier);

                bool valid = roomAttempt.TestRoomValidity(board);

                //Do testing
                if (valid)
                {
                    roomAttempt.PostValiditySetup();
                    corridorAttempt.door2.room = roomAttempt;
                    stemRoom.doorways.Add(possibleDoorway);
                    corridors.Add(corridorAttempt);
                    rooms.Add(roomAttempt);
                    roomRngIdentifiers.RemoveAt(0);
                }
                else
                {
                    i--;
                    failedRoomAttempts++;
                }
            }
            else
            {
                i--;
                failedRoomAttempts++;
            }
        }
    }
示例#6
0
    //Função ficou bem mal escrita. Reescrever
    void GenerateOtherRooms()
    {
        //Ver quantos tipos de sala tem
        int       numRoomTypes = System.Enum.GetNames(typeof(RoomType)).Length;
        IntRandom intRoomType  = new IntRandom(0, numRoomTypes);
        RoomType  roomType;

        int  contador   = 0;
        int  xMerge     = 0;
        int  yMerge     = 0;
        bool foundSpace = false;

        while (contador < maxIterations)
        {
            foundSpace = false;

            roomType = (RoomType)intRoomType.Random;

            rooms = new Room();
            rooms.SetupRoom(columns, rows, smoothness, wallQuant, minLenght, maxLenght, roomType, chanceOfCorridor);
            secTiles = rooms.tiles;

            for (int i = 2; i < columns - (rooms.highestX - rooms.lowestX) - 2 && !foundSpace; i++)
            {
                for (int j = 2; j < rows - (rooms.highestY - rooms.lowestY) - 2 && !foundSpace; j++)
                {
                    if (CheckForSpace(i, j))
                    {
                        Debug.Log("FOUND");
                        foundSpace = true;
                        xMerge     = i;
                        yMerge     = j;
                    }
                    //yield return new WaitForEndOfFrame();
                    //yield return null;
                }
            }

            if (foundSpace)
            {
                Merge(xMerge - rooms.lowestX, yMerge - rooms.lowestY);
            }
            contador++;
        }

        AddDoor();

        InstantiateTiles();

        SpawnPlayer();
    }
示例#7
0
 Room CreateRoom(Vector2 rPos)
 {
     if (isSpaceAvailable(rPos))
     {
         //Room newRoom = new Room(mDefaultRoom, rPos, mRoomCount++) as Room; // room count used to set the room id, and then increment room count so next set id will be different
         GameObject newRoomObj = new GameObject();
         Room       newRoom    = newRoomObj.AddComponent <Room>() as Room;
         newRoom.SetupRoom(mDefaultRoom, rPos, mRoomCount++);
         DungeonRooms.Add(newRoom);
         return(newRoom);
     }
     else
     {
         return(null);
     }
 }
    IEnumerator GenerateRooms()
    {
        for (byte roomCount = 0; roomCount < roomsAmount + 1; roomCount++)
        {
            yield return(new WaitForSecondsRealtime(0.1f));

            if (roomCount == 0)
            {
                GameObject roomObj = new GameObject
                {
                    name = "Room" + roomCount,
                    tag  = "Room"
                };

                Room room = roomObj.AddComponent <Room>();
                Map.roomObjs.Add(room);

                room.SetupRoom(roomCount, 16, 16, transform.position, roomType.playerStart, RoomMaxWidth, RoomMaxHeight);
                CreateRoom(Map.roomObjs[roomCount]);
            }
            else
            {
                byte corridor_length = minCorridorLength;
                int  roombehind      = roomCount - 1; // комната сзади

                byte height = System.Convert.ToByte(randomGenerator.Next(RoomMinHeight, RoomMaxHeight));
                byte width  = System.Convert.ToByte(randomGenerator.Next(RoomMinWidth, RoomMaxWidth)); //Рандоманая высота и ширина

                Direction4D randDirection = RandomDirection((float)randomGenerator.NextDouble());      //Рандомное направление

                if (branchChance > (float)randomGenerator.NextDouble() && roomCount > 5)               //Дополнительное разветвление
                {
                    roombehind -= 1;
                }
                if (roomCount == roomsAmount)
                {
                    TryCreateRoom(roomCount, roombehind, width, height, randDirection, roomType.last);
                }
                else
                {
                    TryCreateRoom(roomCount, roombehind, width, height, randDirection, roomType.common);
                }
            }
        }
        yield return(0);
    }
示例#9
0
    public void GenerateMap()
    {
        if (seed == null)
        {
            seed = "";
        }

        if (useRandomSeed)
        {
            seed = unchecked (System.DateTime.Now.Ticks.GetHashCode()).ToString();
        }

        wallHolder   = new GameObject("Wall Holder");
        floorHolder  = new GameObject("Floor Holder");
        roomHolder   = new GameObject("Room Holder");
        pseudoRandom = new System.Random(seed.GetHashCode());
        borders      = new Dictionary <Vector2, Direction>();

        SetupTileArray();

        //GenerateMapTemplate();

        //generates a full (all wall) larger map
        mainMapGO = Instantiate(roomTemplate, Vector3.zero, Quaternion.identity) as GameObject; //gameobject for the main map
        mainMap   = mainMapGO.GetComponent <Room>();
        mainMap.SetupRoom(Vector3.zero, mapWidth, mapHeight, seed, 100);
        mainMap.name = "Main map";
        tiles        = mainMap.GetRoomNodeLayout();
        borderWalls  = mainMap.GetBorderWalls();

        //generates the cavernous rooms using the Room script
        MakeRooms();

        mainMap.FindLargestReigon(); //makes sure all parts of the map are reachable

        for (int i = 0; i < smoothness; i++)
        {
            mainMap.SmoothMap();
        }

        //instantiation
        InstantiateNodes();       //for debugging
        //UpdateBorderWalls();
        //InstantiateBorders();
        //InstantiateTiles();       //instantiate the tiles one at a time, until the map is fully instantiated
    }
示例#10
0
    void PlaceRoom(Room connectedRoom, int recursionDepth)
    {
        if (recursionDepth > numRooms.Random && spawnedBossRoom)
        {
            return;
        }
        if (recursionDepth > numRooms.m_Max && !spawnedBossRoom)
        {
            PlaceBossRoom(connectedRoom);
            return;
        }

        List <Direction> directions = GetRandomValidCorridorDirections(connectedRoom, Random.Range(1, 5));

        if (directions.Count == 0)
        {
            return;
        }

        Debug.Break();

        foreach (Direction direction in directions)
        {
            Vector2 roomPos           = FindValidRoomPlacement(connectedRoom, direction);
            Vector2 maxRoomDimensions = FindMaxRoomSize(roomPos);

            if (roomPos == nullVector || maxRoomDimensions == nullVector)
            {
                break;
            }

            Room room = ScriptableObject.CreateInstance <Room>();
            room.SetupRoom(roomPos, roomWidth, roomHeight, (int)maxRoomDimensions.x, (int)maxRoomDimensions.y, direction);
            rooms.Add(room);

            Corridor corridor = PlaceCorridor(connectedRoom, room, direction);

            if (corridor != null)
            {
                room.AddCorridor(corridor);
                connectedRoom.AddCorridor(corridor);
                PlaceRoom(room, recursionDepth + 1);
            }
        }
    }
示例#11
0
    //Gerar a primeira sala centralizada
    void GenerateFirstRoom()
    {
        //Ver quantos tipos de sala tem
        int       numRoomTypes = System.Enum.GetNames(typeof(RoomType)).Length;
        IntRandom intRoomType  = new IntRandom(0, numRoomTypes);
        RoomType  roomType;

        //Escolher uma aleatória
        roomType = (RoomType)intRoomType.Random;
        Debug.Log("Primeira sala. Tipo escolhido: " + roomType.ToString());

        //Gerando
        rooms = new Room();
        rooms.SetupRoom(columns, rows, smoothness, wallQuant, minLenght, maxLenght, roomType, 0);
        secTiles = rooms.tiles;

        //O deslocamento do grid secundário será de metade das (colunas/fileiras - lowestX/lowestY) para centralizar, menos um ajuste de coluna/20 para considerar a largura da sala
        int deltaX = (columns / 2) - rooms.lowestX - (columns / 10);
        int deltaY = (rows / 2) - rooms.lowestY - (rows / 10);

        Merge(deltaX, deltaY);
    }
    void GenerateRoom(byte number, Room prevRoom, byte width, byte height, Direction4D dir, roomType type)      //Дверь входящая в комнату
    {
        GameObject roomObj;

        switch (type)
        {
        case roomType.playerStart:
        {
            roomObj = new GameObject
            {
                name = "Start Room " + number,
                tag  = "Room"
            };
            break;
        }

        case roomType.common:
        {
            roomObj = new GameObject
            {
                name = "Room " + number,
                tag  = "Room"
            };
            break;
        }

        case roomType.shop:
        {
            roomObj = new GameObject
            {
                name = "Shop " + number,
                tag  = "Shop"
            };
            break;
        }

        case roomType.last:
        {
            roomObj = new GameObject
            {
                name = "Last Room",
                tag  = "Room"
            };
            break;
        }

        case roomType.secret:
        {
            roomObj = new GameObject
            {
                name = "Secret Room " + number,
                tag  = "Room"
            };
            break;
        }

        case roomType.nextlevel:
        {
            roomObj = new GameObject
            {
                name = "Next Level Room " + number,
                tag  = "Room"
            };
            break;
        }

        default:
        {
            roomObj = new GameObject
            {
                name = "Room " + number,
                tag  = "Room"
            };
            break;
        }
        }

        Room room = roomObj.AddComponent <Room>();

        Map.roomObjs.Add(room);

        room.SetupRoom(number, width, height, transform.position, prevRoom, type, RoomMaxWidth, RoomMaxHeight);  //room count - roombehind
        room.SetupCorridor(DoorInvert(dir), minCorridorLength, randomGenerator);                                 //Обычно count-1 - пред.комната
                                                                                                                 //Но иногда приходится идти на несколько комнат назад
        CreateRoom(room);
    }
示例#13
0
	void CreateRoomsAndCorridors()
	{
		while (needRoomsAndCorridorsCreation == true) 
		{
			// Create the rooms array with a random size.
			rooms = new Room[numRooms.Random];

			//Non IntRange representation of how many rooms there are
			int numbRooms = rooms.Length;

			// There should be one less corridor than there is rooms.
			corridors = new Corridor[rooms.Length - 1];
			// There will be a specified number of appending corridor
			aCorridors = new Corridor[rooms.Length - 2];
			//Make dead end corridor array
			deadEndCorridorsArray = new Corridor[corridors.Length];
			// Create the first room and corridor.
			rooms [0] = new Room ();
			corridors [0] = new Corridor ();

			// Setup the first room, there is no previous corridor so we do not use one.
			rooms [0].SetupRoom (roomWidth, roomHeight, columns, rows);

			// Setup the first corridor using the first room.
			corridors [0].SetupCorridor (rooms [0], corridorLength, roomWidth, roomHeight, columns, rows, true);

			// Set up second room. Check for overlap is not necessary
			rooms [1] = new Room ();
			rooms [1].SetupRoom (roomWidth, roomHeight, columns, rows, corridors [0]);

			// Set up the rest of the rooms and corridors, checking for overlaps

			for (int i = 2; i < rooms.Length; i++) {
				bool goodRoomPlacement = false;
				bool goodCorridorPlacement = false;
				bool goodAppCorridorPlacement = false;
				bool goodDeadEndCorridorPlacement = false;
				//bool goodCorridorNotOverlapRoomPlacement = false;
				bool goodRoomNotOverlapCorridorPlacement = false;
				//bool roomOverlapsCorridor = false;
				//bool roomOverlapsAppCorridor = false;
				//bool roomOverlapsDeadEndCorridor = false;
				bool makeDeadEndCorridor = true;

				//If generation has tried different corridor/room placements exceeding the number of rooms there are
				if (triedCounter >= numbRooms * 2) {
					//Then reload the level
					//reloadLevelNeeded = true;
					//SceneManager.LoadScene (3);
					break;
				}
            




				// If room overlaps with any other rooms, create entirely new corridor leaving from the last created room
				while (!goodRoomPlacement && !goodCorridorPlacement && !goodDeadEndCorridorPlacement && !goodAppCorridorPlacement && !goodRoomNotOverlapCorridorPlacement) {
					bool appendCorridor = false;
					// Create test corridor and room
					Corridor corridorToBePlaced = new Corridor ();
					Corridor corridorToAppend = new Corridor ();
					if (numAppend < rooms.Length - 1)
						appendCorridor = true;

					//If a room in the array is null then there was an error with generation. Restart the scene
					if (rooms [i - 1] == null) {
						//reloadLevelNeeded = true;
						//SceneManager.LoadScene (3);
						break;
					}

					//Set tried counter to 0 and enter into while loop with placementNeeded as true
					triedCounter = 0;
					placementNeeded = true;
					//Stays in this loop until a good placement or the amount of tries has been exceeded
					while (placementNeeded == true) {
						triedCounter++;
						if (triedCounter >= numbRooms * 2)
							break;
						//Create the corridor


						//Make the corridor
						corridorToBePlaced.SetupCorridor (rooms [i - 1], corridorLength, roomWidth, roomHeight, columns, rows, false);

						//Stay in this loop until the corridor is longer than the minimum length or until tries are exhausted
						while (corridorToBePlaced.corridorLength < minCorridorLength) {
							triedCounter++;

							corridorToBePlaced.SetupCorridor (rooms [i - 1], corridorLength, roomWidth, roomHeight, columns, rows, false);
							if (triedCounter >= numbRooms * 2)
								break;
						}
						if (triedCounter >= numbRooms * 2)
							break;
						if (corridorToBePlaced.corridorLength < minCorridorLength) {
							//Do nothing
						} else {
							//Check to see if it overlaps any rooms/corridors
							for (int j = 0; j < i; j++) {
								//Check if it overlaps a regular corridor
								if (corridors [j] != null) {
									if (doCorridorsOverlapCorridor (corridors [j], corridorToBePlaced))
										break;
								}
								//Check if it overlaps with an appended corridor
								if (j < aCorridors.Length) {
									if (aCorridors [j] != null) {
										if (doCorridorsOverlapCorridor (aCorridors [j], corridorToBePlaced))
											break;
									}
								}
								//check if it overlaps with another dead end corridor
								if (deadEndCorridorsArray [j] != null) {
									if (doCorridorsOverlapCorridor (deadEndCorridorsArray [j], corridorToBePlaced))
										break;
								}
								// If last room has been checked and room to be placed doesn't overlap with it...
								if (j == (i - 1)) {
									//Dead end corridorto be placed doesn't overlap with any existing rooms, so exit while loop
									goodCorridorPlacement = true;
									//Exit the loop since a good placement has been achieved
									placementNeeded = false;
								}								
							}
						}
					}
					if (triedCounter >= numbRooms * 2)
						break;
				
					//triedCounter++;
					Room roomToBePlaced = new Room ();

					if (appendCorridor) {
						triedCounter = 0;
						placementNeeded = true;

						while (placementNeeded == true) {
							triedCounter++;
							if (triedCounter >= numbRooms * 2)
								break;
							//Create the Corridor


							//create the corridor 
							corridorToAppend.SetUpAppendedCorridor (corridorToBePlaced, corridorLength, roomWidth, roomHeight, columns, rows, corridorToBePlaced.EndPositionX, corridorToBePlaced.EndPositionY);

							//Stay in this loop until the corridor is longer than the minimum length or until tries are exhausted
							while (corridorToAppend.corridorLength < minCorridorLength) {
								triedCounter++;

								corridorToAppend.SetUpAppendedCorridor (corridorToBePlaced, corridorLength, roomWidth, roomHeight, columns, rows, corridorToBePlaced.EndPositionX, corridorToBePlaced.EndPositionY);
								if (triedCounter >= numbRooms * 2)
									break;
							}
							if (triedCounter >= numbRooms * 2)
								break;
							//Checks to see if the appended corridor overlaps with the dead end corridor that is to be placed
							//if(doCorridorsOverlapCorridor(deadEndCorridor,corridorToAppend))
							//	break;
						
							if (corridorToAppend.corridorLength < minCorridorLength) {
								//break;
							} else {
								//Check to see if it overlaps with any rooms/corridors
								for (int j = 0; j < i; j++) {
									//checks to see if the appending corridor overlaps with rooms
									if (doCorridorsOverlapRooms (rooms [j], corridorToAppend)) {
										break;
									}
									//checks to see if the appending corridor overlaps with regular corridors
									if (corridors [j] != null) {
										if (doCorridorsOverlapCorridor (corridors [j], corridorToAppend))
											break;
									}
									//checks to see if it overlaps with the other appending corridors
									if (j < aCorridors.Length) {
										if (aCorridors [j] != null) {
											if (doCorridorsOverlapCorridor (aCorridors [j], corridorToAppend))
												break;
										}
									}
									//checks to see if it overlaps with any dead end corridors
									if (deadEndCorridorsArray [j] != null) {
										if (doCorridorsOverlapCorridor (deadEndCorridorsArray [j], corridorToAppend))
											break;
									}

									if (j == (i - 1)) {
										// Room to be placed doesn't overlap with any existing rooms, so exit while loop
										goodAppCorridorPlacement = true;
										placementNeeded = false;
									}
								}
							}
						}
						if (goodAppCorridorPlacement == false)
							break;
						if (triedCounter >= numbRooms * 2)
							break;
						triedCounter = 0;
						placementNeeded = true;
						//Stays in this loop until a good placement or the amount of tries has been exceeded
						while (placementNeeded == true) {
							triedCounter++;
							if (triedCounter >= numbRooms * 2)
								break;
							//Create Room
							roomToBePlaced.SetupRoom (roomWidth, roomHeight, columns, rows, corridorToAppend);
							//if(doRoomsOverlapCorridor(deadEndCorridor,roomToBePlaced))
							//{
							//	break;
							//}
							//Check to see if it overlaps any corridors
							for (int j = 0; j < i; j++) {
								//checks to see if the room overlaps with regular corridors
								if (corridors [j] != null) {
									if (doRoomsOverlapCorridor (corridors [j], roomToBePlaced))
										break;
								}
								//checks to see if it overlaps any appending corridors
								if (j < aCorridors.Length) {
									if (aCorridors [j] != null) {
										if (doRoomsOverlapCorridor (aCorridors [j], roomToBePlaced))
											break;
									}
								}
								//checks to see if it overlaps with any dead end corridors
								if (deadEndCorridorsArray [j] != null) {
									if (doRoomsOverlapCorridor (deadEndCorridorsArray [j], roomToBePlaced))
										break;
								}
								if (j == (i - 1)) {
									// Room to be placed doesn't overlap with any existing rooms, so exit while loop
									goodRoomNotOverlapCorridorPlacement = true;
									placementNeeded = false;
								}
							}
						}
						if (goodRoomNotOverlapCorridorPlacement == false)
							break;
						if (triedCounter >= numbRooms * 2)
							break;
					} else {
						triedCounter = 0;
						placementNeeded = true;
						//Stays in this loop until a good placement or the amount of tries has been exceeded
						while (placementNeeded == true) {
							triedCounter++;
							if (triedCounter >= numbRooms * 2)
								break;
							//Create Room
							roomToBePlaced.SetupRoom (roomWidth, roomHeight, columns, rows, corridorToAppend);
							//if(doRoomsOverlapCorridor(deadEndCorridor,roomToBePlaced))
							//{
							//	break;
							//}
							//Check to see if it overlaps any corridors
							for (int j = 0; j < i; j++) {
								if (corridors [j] != null) {
									if (doRoomsOverlapCorridor (corridors [j], roomToBePlaced))
										break;
								}
								if (j < aCorridors.Length) {
									if (aCorridors [j] != null) {
										if (doRoomsOverlapCorridor (aCorridors [j], roomToBePlaced))
											break;
									}
								}
								if (deadEndCorridorsArray [j] != null) {
									if (doRoomsOverlapCorridor (deadEndCorridorsArray [j], roomToBePlaced))
										break;
								}
								if (j == (i - 1)) {
									// Room to be placed doesn't overlap with any existing rooms, so exit while loop
									goodRoomNotOverlapCorridorPlacement = true;
									placementNeeded = false;
								}
							}
						}
						if (goodRoomNotOverlapCorridorPlacement == false)
							break;
						if (triedCounter >= numbRooms * 2)
							break;
					}

					// Loop over all other rooms created, except for one to be placed
					for (int j = 0; j < i; j++) {

						// If room to be placed overlaps with j-th room...
						if (doRoomsOverlap (rooms [j], roomToBePlaced)) {
							/* No need to check other rooms, so break from
							 * for loop and setup a new corridor and room */
							break;
						} 


						// If last room has been checked and room to be placed doesn't overlap with it...
						if (j == (i - 1)) {
							// Room to be placed doesn't overlap with any existing rooms, so exit while loop
							goodRoomPlacement = true;
						}
					}
					//If there are no good room placements then break here and start over
					if (goodRoomPlacement == false)
						break;
				
					//Break out of loop if genertion has tried generating corridors/rooms more than the number of rooms
					if (triedCounter >= numbRooms * 2)
						break;

					Corridor deadEndCorridor = new Corridor ();
					roll = Random.Range (0, 100);
					if (roll <= DeadEndChance) {
						makeDeadEndCorridor = true;
						triedCounter = 0;
						placementNeeded = true;
						//Stays in this loop until a good placement or the amount of tries has been exceeded
						while (placementNeeded == true) {
							triedCounter++;
							if (triedCounter >= numbRooms * 2)
								break;
							//Make the corridor

							deadEndCorridor.SetupDeadEndCorridor (corridorToAppend, corridorLength, roomWidth, roomHeight, columns, rows, corridorToBePlaced.startXPos, corridorToBePlaced.startYPos);
							bool deadEndOverlaps = false;

							if (doCorridorsOverlapCorridor (corridorToBePlaced, deadEndCorridor))
								deadEndOverlaps = true;
							
							if (doCorridorsOverlapRooms (roomToBePlaced, deadEndCorridor))
								deadEndOverlaps = true;

							//If dead end corridor overlaps
							if (deadEndOverlaps == true) {
								
							} 
							//else if the dead end corridor does not overlap with currently placing corridor or room
							//then check with the rest of the arrays
							else {
								//Check placement with all other corridors/rooms
								for (int j = 0; j < i; j++) {
									//Check if it overlaps a room
									if (doCorridorsOverlapRooms (rooms [j], deadEndCorridor)) {
										break;
									}
									//Check if it overlaps a regular corridor
									if (corridors [j] != null) {
										if (doCorridorsOverlapCorridor (corridors [j], deadEndCorridor))
											break;
									}
									//Check if it overlaps with an appended corridor
									if (j < aCorridors.Length) {
										if (aCorridors [j] != null) {
											if (doCorridorsOverlapCorridor (aCorridors [j], deadEndCorridor))
												break;
										}
									}
									//check if it overlaps with another dead end corridor
									if (deadEndCorridorsArray [j] != null) {
										if (doCorridorsOverlapCorridor (deadEndCorridorsArray [j], deadEndCorridor))
											break;
									}
									// If last room has been checked and room to be placed doesn't overlap with it...
									if (j == (i - 1)) {
										//Dead end corridorto be placed doesn't overlap with any existing rooms, so exit while loop
										goodDeadEndCorridorPlacement = true;
										placementNeeded = false;
									}								
								}
							}
						}
					} else {
						goodDeadEndCorridorPlacement = true;
					}
					if (triedCounter >= numbRooms * 2)
						break;
				



					// Room doesn't overlap with any other rooms, so add corridor and room to their arrays
					if (goodRoomPlacement && goodCorridorPlacement && goodDeadEndCorridorPlacement && goodAppCorridorPlacement && goodRoomNotOverlapCorridorPlacement) {
						//If room is good, then reset the tried counter
						triedCounter = 0;

						//Put the well placed corridor in the corridors array
						corridors [i - 1] = corridorToBePlaced;

						//Put the well placed appended corridor in the their array
						if (appendCorridor) {
							if (numAppend < aCorridors.Length) {
								aCorridors [numAppend] = corridorToAppend;
								numAppend++;
							}
						}
						//Put the well placed room in the room array
						rooms [i] = roomToBePlaced;

						//Put the well placed dead end corridor in their array 
						if (makeDeadEndCorridor)
							deadEndCorridorsArray [i - 1] = deadEndCorridor;
						
					}

					//Instantiates player in the i-th/2 room created
					//Cast as int so condition is always reachable
					/*
					if (i == (int)(rooms.Length * .5f)) {


						Vector3 playerTeleportPlatPos = new Vector3 (rooms [0].xPos-38f, rooms [0].yPos, 0);//Puts the teleporter in the hub
						ChildOfBoardHolder =  Instantiate (playerTeleportPlat, playerTeleportPlatPos, Quaternion.identity) as GameObject;
						ChildOfBoardHolder.transform.SetParent (boardHolder.transform);

					}
					/*
					if (i == (int)(rooms.Length - 1)) {
						if (rooms [rooms.Length - 1] != null) {
							Vector3 teleporterPos = new Vector3 (rooms [rooms.Length - 1].xPos, rooms [rooms.Length - 1].yPos, 0);
							ChildOfBoardHolder =  Instantiate (teleporter, teleporterPos, Quaternion.identity) as GameObject;
							ChildOfBoardHolder.transform.SetParent (boardHolder.transform);
						}
					}*/
				}
			}

			//Need to check if any rooms or corridors are null, indicating bad generation
			for (int i = 0; i < rooms.Length; i++) {
				if (rooms [i] == null) {
					numAppend = 0;
					triedCounter = 0;
					needRoomsAndCorridorsCreation = true;
					break;
				} else if (i == rooms.Length - 1 && rooms [i] != null)
					needRoomsAndCorridorsCreation = false;

			}
			for (int i = 0; i < corridors.Length; i++) {
				
				if (corridors [i] == null) {
					numAppend = 0;
					triedCounter = 0;
					needRoomsAndCorridorsCreation = true;
					break;
				} else if (i == corridors.Length - 1 && corridors [i] != null) {
					needRoomsAndCorridorsCreation = false;
				}
			}
			for (int i = 0; i < aCorridors.Length; i++) {
				if (aCorridors [i] == null) {
					numAppend = 0;
					triedCounter = 0;
					needRoomsAndCorridorsCreation = true;
					break;
				} else if (i == aCorridors.Length - 1 && aCorridors [i] != null)
					needRoomsAndCorridorsCreation = false;

			}
		}
	}