Texture2D[] PickTileMapSet(Room.roomType type) { Texture2D[] ret = sideTiles; switch (type) { case Room.roomType.side: ret = sideTiles; break; case Room.roomType.normal: ret = normalTiles; break; case Room.roomType.drop: ret = dropTiles; break; case Room.roomType.landing: ret = landingTiles; break; case Room.roomType.dropThrough: ret = dropThroughTiles; break; } return(ret); }
void AddRoom(int posX, int posY, Vector2 checkPos, Room.roomType roomType) { rooms[posX, posY] = new Room(checkPos, roomType); roomStats roomStats = new roomStats(); roomStats.x = posX; roomStats.y = posY; roomStats.checkPos = checkPos; roomPos.Add(roomStats); }
public Room.roomType getCurrentRoomTypeInf() { Room.roomType type = Room.roomType.binaryOption; for (int i = 0; i < this.GetComponentsInChildren <Room>(false).Length; i++) { type = this.GetComponentsInChildren <Room>()[i].MyRoomType; } return(type); }
public void Setup(Texture2D _tex, Vector2 _gridPos, Room.roomType _type, bool _doorTop, bool _doorBot, bool _doorLeft, bool _doorRight) { tex = _tex; gridPos = _gridPos; type = _type; doorTop = _doorTop; doorBot = _doorBot; doorLeft = _doorLeft; doorRight = _doorRight; MakeDoors(); GenerateRoomTiles(); CheckMobs(); }
//comprueba que la sala sea válida y despues la crea // @Params : //x: indice de la casilla x donde queremos que cree la sala //y: indice de la casilla y donde queremos que cree la sala public Room createRoom(int x, int y, Room.roomType roomType) { int roomWidth = Random.Range(minRoom, maxRoom); int roomHeigth = roomWidth; Room roomAux = null; if (primeritoDia == false) { roomWidth = 7; roomHeigth = roomWidth; primeritoDia = true; } x = (int)(x - (roomWidth / 2)); y = (int)(y - (roomHeigth / 2)); if ((x + roomWidth) < width && (y + roomHeigth) < heigth && x > 0 && y > 0) { if (!checkRoomSpace(x, y, roomWidth, roomHeigth)) { return(null); } roomAux = new Room(roomWidth, roomHeigth, prefabRoomList, roomType); for (int i = x; i < x + roomWidth; i++) { for (int j = y; j < y + roomHeigth; j++) { roomAux.addTile(level[i, j], depth); } } levelRooms.Add(roomAux); roomsAvailable.Add(roomAux); surface.BuildNavMesh(); return(roomAux); } else { return(createCorridor(roomType)); } }
int TypeNumber(Room.roomType type) //converts data for PrintPath { switch (type) { case Room.roomType.normal: return(1); case Room.roomType.drop: return(2); case Room.roomType.landing: return(3); case Room.roomType.dropThrough: return(4); default: return(0); } }
//Orden de crear nueva sala: //Primero decide de que sala y en que direccion crearlo. // segundo lo crea //Comprueba que la sala se puede crear con elcheckRoomSpace // si la pued ecrear llama a acreate Room y la crea public Room createCorridor(Room.roomType roomType) { if (roomsAvailable.Count == 0) { return(null); } int roomIndex = Random.Range(0, roomsAvailable.Count - 1); Room room = (Room)roomsAvailable[roomIndex]; CorridorDir dir = generateDir(room); Room roomAux = null; int longui = Random.Range(minCorridor, maxCorridor); int x; int y; GameObject tile; TileScript myTile; switch (dir) { case CorridorDir.BOTTOM: y = 0; x = (int)(room.width / 2); tile = room.tiles[x, y]; myTile = tile.GetComponent <TileScript>(); x = myTile.indexX; y = myTile.indexY - 1; for (int i = y; i > y - longui; i--) { if (i >= 0 && i < heigth) { tile = level[x, i]; myTile = tile.GetComponent <TileScript>(); if (myTile.tileType == TileScript.type.GROUND) { if (x > 0 && x < width - 1) // si no estamos en un extremo { if (level[x + 2, i].GetComponent <TileScript>().tileType != TileScript.type.CORRIDOR && level[x - 1, i].GetComponent <TileScript>().tileType != TileScript.type.CORRIDOR) { myTile.changeType(TileScript.type.CORRIDOR, prefabCorridor, depth); level[x + 1, i].GetComponent <TileScript>().changeType(TileScript.type.CORRIDOR, prefabCorridor, depth); // lo hacemos el doble de gordo el camino } } else { myTile.changeType(TileScript.type.CORRIDOR, prefabCorridor, depth); } } else { return(createCorridor(roomType)); } } else { return(createCorridor(roomType)); } } roomAux = createRoom(x, y - longui, roomType); if (roomAux != null) { roomAux.top = true; } break; case CorridorDir.TOP: y = (int)room.heigth - 1; x = (int)(room.width / 2); tile = room.tiles[x, y]; myTile = tile.GetComponent <TileScript>(); x = myTile.indexX; y = myTile.indexY + 1; for (int i = y; i < y + longui; i++) { if (i >= 0 && i < heigth) { tile = level[x, i]; myTile = tile.GetComponent <TileScript>(); if (myTile.tileType == TileScript.type.GROUND) { if (x > 0 && x < width - 1) { if (level[x + 1, i].GetComponent <TileScript>().tileType != TileScript.type.CORRIDOR && level[x - 2, i].GetComponent <TileScript>().tileType != TileScript.type.CORRIDOR) { myTile.changeType(TileScript.type.CORRIDOR, prefabCorridor, depth); level[x - 1, i].GetComponent <TileScript>().changeType(TileScript.type.CORRIDOR, prefabCorridor, depth); // lo hacemos el doble de gordo el camino } } else { myTile.changeType(TileScript.type.CORRIDOR, prefabCorridor, depth); } } else { return(createCorridor(roomType)); } } else { return(createCorridor(roomType)); } } roomAux = createRoom(x, y + longui, roomType); if (roomAux != null) { roomAux.bottom = true; } break; case CorridorDir.RIGTH: y = (int)(room.heigth / 2); x = (int)room.width - 1; tile = room.tiles[x, y]; myTile = tile.GetComponent <TileScript>(); x = myTile.indexX + 1; y = myTile.indexY; for (int i = x; i < x + longui; i++) { if (i >= 0 && i < width) { tile = level[i, y]; tile.transform.Rotate(0.0f, 90.0f, 0.0f); myTile = tile.GetComponent <TileScript>(); if (myTile.tileType == TileScript.type.GROUND) { if (y > 0 && y < heigth - 1) { if (level[i, y + 2].GetComponent <TileScript>().tileType != TileScript.type.CORRIDOR && level[i, y - 1].GetComponent <TileScript>().tileType != TileScript.type.CORRIDOR) { myTile.changeType(TileScript.type.CORRIDOR, prefabCorridor, depth); level[i, y + 1].GetComponent <TileScript>().changeType(TileScript.type.CORRIDOR, prefabCorridor, depth); } } else { myTile.changeType(TileScript.type.CORRIDOR, prefabCorridor, depth); } } else { return(createCorridor(roomType)); } } else { return(createCorridor(roomType)); } } roomAux = createRoom(x + longui, y, roomType); if (roomAux != null) { roomAux.left = true; } break; case CorridorDir.LEFT: y = (int)(room.heigth / 2); x = 0; tile = room.tiles[x, y]; myTile = tile.GetComponent <TileScript>(); x = myTile.indexX - 1; y = myTile.indexY; for (int i = x; i > x - longui; i--) { if (i >= 0 && i < width) { tile = level[i, y]; tile.transform.Rotate(0.0f, 90.0f, 0.0f); myTile = tile.GetComponent <TileScript>(); if (myTile.tileType == TileScript.type.GROUND) { if (y > 0 && y < heigth - 1) { if (level[i, y + 1].GetComponent <TileScript>().tileType != TileScript.type.CORRIDOR && level[i, y - 2].GetComponent <TileScript>().tileType != TileScript.type.CORRIDOR) { myTile.changeType(TileScript.type.CORRIDOR, prefabCorridor, depth); level[i, y - 1].GetComponent <TileScript>().changeType(TileScript.type.CORRIDOR, prefabCorridor, depth); } } else { myTile.changeType(TileScript.type.CORRIDOR, prefabCorridor, depth); } } else { return(createCorridor(roomType)); } } else { return(createCorridor(roomType)); } } roomAux = createRoom(x - longui, y, roomType); if (roomAux != null) { roomAux.rigth = true; } break; } surface.BuildNavMesh(); return(roomAux); }