// // // public void Initialize() {//Generate Rooms player = PlayerManager.Instance.player; currentRoom = GameObject.FindObjectOfType <GeneriqueRooms>().gameObject; currentRoomG = currentRoom.GetComponent <GeneriqueRooms>(); //GenerateRooms(); GenerateRoomsWithPath(path3); Debug.Log("Room Generated"); }
public void InstantiateRoom(Vector2Int roomPos) { RoomType roomType = RoomType.None; roomType = roomsArray[roomPos.x, roomPos.y].roomType; currentRoom.GetComponent <GeneriqueRooms>().Close(); EnemyManager.Instance.enemiesAlive.Clear(); GameObject.Destroy(currentRoom); switch (roomType) { case RoomType.Enemy: currentRoom = GameObject.Instantiate(Resources.Load <GameObject>(PrefabsDir.ennemyRoomDir)); //Instantiate the prefab currentRoom.GetComponent <GeneriqueRooms>().Initialize(roomsArray[roomPos.x, roomPos.y], SetDoors(roomPos)); //Initialize the room and give it the data pckg currentRoomG = currentRoom.GetComponent <GeneriqueRooms>(); break; case RoomType.Boss: currentRoom = GameObject.Instantiate(Resources.Load <GameObject>(PrefabsDir.bossRoomDir)); currentRoom.GetComponent <GeneriqueRooms>().Initialize(roomsArray[roomPos.x, roomPos.y], SetDoors(roomPos)); currentRoomG = currentRoom.GetComponent <GeneriqueRooms>(); break; case RoomType.Shop: currentRoom = GameObject.Instantiate(Resources.Load <GameObject>(PrefabsDir.ennemyRoomDir)); currentRoom.GetComponent <GeneriqueRooms>().Initialize(roomsArray[roomPos.x, roomPos.y], SetDoors(roomPos)); currentRoomG = currentRoom.GetComponent <GeneriqueRooms>(); break; case RoomType.Spawn: currentRoom = GameObject.Instantiate(Resources.Load <GameObject>(PrefabsDir.spawnRoomDir)); currentRoom.GetComponent <GeneriqueRooms>().Initialize(roomsArray[roomPos.x, roomPos.y], SetDoors(roomPos)); currentRoomG = currentRoom.GetComponent <GeneriqueRooms>(); break; case RoomType.None: break; default: break; } Debug.Log("RoomPos: " + currentRoom.GetComponent <GeneriqueRooms>().roomData.pos); }
void ChangeRoom(Player player) { GeneriqueRooms currentGeneriqueRoom = currentRoom.GetComponent <GeneriqueRooms>(); if (player.transform.position.x >= 21 && player.transform.position.x <= 23 && player.transform.position.y >= 22 && player.transform.position.y <= 25) { //North Door Activated if (!currentGeneriqueRoom.north.activeSelf) //Check if door is open { InstantiateRoom(currentGeneriqueRoom.roomData.pos + new Vector2Int(0, 1)); player.transform.position = new Vector3(playerSpawnSouth.x, playerSpawnSouth.y, 0);//Set player position } } if (player.transform.position.x >= 0.5f && player.transform.position.x <= 1 && player.transform.position.y >= 11 && player.transform.position.y <= 13) { //West Door Activated if (!currentGeneriqueRoom.west.activeSelf) //Check if door is open { InstantiateRoom(currentGeneriqueRoom.roomData.pos - new Vector2Int(1, 0)); player.transform.position = new Vector3(playerSpawnEast.x, playerSpawnEast.y, 0);//Set player position } } if (player.transform.position.x >= 21 && player.transform.position.x <= 23 && player.transform.position.y >= 0.5f && player.transform.position.y <= 2) { //South Door Activated if (!currentGeneriqueRoom.south.activeSelf) //Check if door is open { InstantiateRoom(currentGeneriqueRoom.roomData.pos - new Vector2Int(0, 1)); player.transform.position = new Vector3(playerSpawnNorth.x, playerSpawnNorth.y, 0);//Set player position } } if (player.transform.position.x >= 43 && player.transform.position.x <= 43.5f && player.transform.position.y >= 11 && player.transform.position.y <= 13) { //East Door Activated if (!currentGeneriqueRoom.east.activeSelf) //Check if door is open { InstantiateRoom(currentGeneriqueRoom.roomData.pos + new Vector2Int(1, 0)); player.transform.position = new Vector3(playerSpawnWest.x, playerSpawnWest.y, 0);//Set player position } } }