public EnemyGenerator(Room.Grid <Cell> room, Vector3 roomPosition, int roomNum, int totalRooms, Enemy[] enemyPrefabs) { this.room = room; this.roomPosition = roomPosition; currCell = room.getCellAtCoord(0, 0); this.roomNum = roomNum; this.totalRooms = totalRooms; this.enemyPrefabs = enemyPrefabs; }
// Awake is called when the script instance is being loaded. private void Awake() { roomWidth = 10; roomHeight = 8; roomArray = new Room.Grid <Cell> [numRooms]; roomTemplates = new List <int[, ]>(); numTemplateRooms = 16; // Create the rooms templates for (int i = 0; i < numTemplateRooms; i++) { buildTemplateRoom(i); } roomXShift = roomWidth * cellSize; int randomIndex = 0; int lastIndex = 0; Vector3 roomPosition = new Vector3(); for (int i = 0; i < numRooms; i++) { room = new Room.Grid <Cell>(roomWidth, roomHeight, cellSize, tilePalletName, i); randomIndex = Random.Range(0, roomTemplates.Count); while (randomIndex == lastIndex) { randomIndex = Random.Range(0, roomTemplates.Count); } //build a room based on a randomly chosen template. room.buildRoom(roomTemplates[randomIndex], roomPosition); roomArray[i] = room; genEnemies(roomPosition, i, roomArray.Length); //generate enemies on the current room w/ difficulty i out of total rooms genBackground(roomPosition); //generate background elements on the current room // After building the room shift the position of the next room by the room width multiplied by the cell size. roomPosition += new Vector3(roomXShift, 0, 0); lastIndex = randomIndex; } Room.Cell finishPoint = roomArray[numRooms - 1].GetCellByType(Room.CellType.End_Point); if (finishPoint != null) { Sprite sprite = Resources.Load <Sprite>("sign"); finishPoint.createFinishLine(sprite); } }
public bgElementGenerator(Room.Grid <Cell> room, Vector3 roomPosition) { this.room = room; this.roomPosition = roomPosition; currCell = room.getCellAtCoord(0, 0); }