public void Load(RoomSettings roomSettings) { // delete old room (if any) if (currentRoomTransform == null) { currentRoomTransform = transform.Find(HOLDER_NAME); } if (currentRoomTransform != null) { DestroyImmediate(currentRoomTransform.gameObject); } // create new room currentRoom = RoomGenerator.Generate(roomSettings); // create holder currentRoomTransform = new GameObject(HOLDER_NAME).transform; currentRoomTransform.parent = transform; tileMap = new Transform[currentRoom.size.x, currentRoom.size.y]; // create entities for (int x = 0; x < currentRoom.size.x; x++) { for (int y = 0; y < currentRoom.size.y; y++) { // tile for every position in room InstantiateTile(x, y); ITile tile = currentRoom.GetTile(x, y); switch (tile.type) { case TileType.Obstacle: InstantiateObstacle((Obstacle)tile); break; default: break; } } } SetupNavmeshMasks(); floor.localScale = tileSize * new Vector3(currentRoom.size.x, currentRoom.size.y); }
public void GenerateAndLoad(RoomSettings settings) { Load(RoomGenerator.Generate(settings)); }