void Spawn(float x, float y, string conexions, RoomCreator.RoomType type) { Vector2 spawnPos = new Vector2(x, y); RoomCreator.Conexions nameEnum = (RoomCreator.Conexions)Enum.Parse(typeof(RoomCreator.Conexions), conexions); Room room = roomScript.SetupRoom(nameEnum, spawnPos, type, boss); room.SetEnemies(enemiesPrefabs, turretsPrefabs); rooms.Add(spawnPos, room); }
void SpawnLevel() { int bossRoom = (int)UnityEngine.Random.Range(0, possibleBoss.Count); int initRoom = (int)UnityEngine.Random.Range(0, possibleInit.Count); if (possibleInit.Count > 0) { Vector2 playerRoom = possibleInit[initRoom]; Vector2 position = new Vector2(playerRoom.x * roomSize, playerRoom.y * roomSize) + Vector2.one * 8; GameObject.FindGameObjectWithTag("Player").transform.position = position; Vector3 cameraPosition = new Vector3(position.x, position.y, -10); GameObject.FindGameObjectWithTag("MainCamera").transform.position = cameraPosition; } for (int x = 0; x < roomWidth; x++) { for (int y = 0; y < roomHeight; y++) { if (grid[x, y]) { RoomCreator.RoomType type = RoomCreator.RoomType.normal; if (possibleBoss.Count > 0 && possibleBoss[bossRoom] == new Vector2(x, y)) { type = RoomCreator.RoomType.boss; } if (possibleInit.Count > 0 && possibleInit[initRoom] == new Vector2(x, y)) { type = RoomCreator.RoomType.initial; } Spawn(x * roomSize, y * roomSize, names[x, y], type); } } } float posX; float posY; do { do { posX = UnityEngine.Random.Range(0, roomWidth * 16); posY = UnityEngine.Random.Range(0, roomHeight * 16); } while (!rooms.ContainsKey(new Vector2(posX, posY))); } while(rooms[new Vector2(posX, posY)].GetRoomType() != RoomCreator.RoomType.normal); rooms[new Vector2(posX, posY)].SetRoomType(RoomCreator.RoomType.keyBoss); rooms[new Vector2(posX, posY)].SetKeyBoss(keyBoss); }
public Room(RoomType rt, Status s, Vector2 p, Conexions c, GameObject b) { roomType = rt; status = s; position = p; conexions = c; bossPrefab = b; if (roomType == RoomType.boss) { Vector3 pos = p; Quaternion quaternion = Quaternion.identity; int direction = 0; switch (c) { case Conexions.T: pos = new Vector3(p.x + 7.5f, p.y + 4, 0); quaternion = Quaternion.identity; direction = 0; break; case Conexions.B: pos = new Vector3(p.x + 7.5f, p.y + 12, 0); quaternion = Quaternion.Euler(new Vector3(0, 0, 180)); direction = 1; break; case Conexions.L: pos = new Vector3(p.x + 12, p.y + 7.5f, 0); quaternion = Quaternion.Euler(new Vector3(0, 0, 90)); direction = 2; break; case Conexions.R: pos = new Vector3(p.x + 4, p.y + 7.5f, 0); quaternion = Quaternion.Euler(new Vector3(0, 0, 270)); direction = 3; break; default: break; } bossEnemy = Instantiate(bossPrefab, pos, quaternion); bossEnemy.GetComponent <BossEnemy>().SetDirection(direction); bossEnemy.GetComponent <BossEnemy>().SetRoom(this); nEnemies = 1; } }
public void SetRoomType(RoomType r) { roomType = r; }