// Use this for initialization void Awake() { activated = true; playerController = GameObject.Find("Player").GetComponent <PlayerController> (); NumGen ng = NumGen.getInatance(); row = ng.getX(); col = ng.getY(); //map = new GameObject[row, col]; //ob_map = new GameObject[row, col]; Room r1 = new Room(room_num); Obstical obstical; if (room_num == 5) { obstical = new Obstical(GameVars.num_exit, row, col); } else { obstical = new Obstical(GameVars.num_Room_Random, row, col); } Create(row, col, obstical.grid); Create(row, col, r1.grid); if (transform.position.x == 0 && gameObject.name == "Room4(Clone)") { AddPlayerSpawn(); } BoxCollider2D collider = gameObject.AddComponent <BoxCollider2D>(); collider.size = new Vector2((row * tileSize) - tileSize * 2, (col * tileSize) - tileSize * 2); collider.isTrigger = true; Vector2 v = new Vector2(((row * tileSize) / 2) - tileSize / 2, ((col * tileSize) / 2) - tileSize / 2); collider.center = v; }
// Use this for initialization void Awake() { NumGen ng = NumGen.getInatance(); numTiles_inRow = ng.getX(); numTiles_inCol = ng.getY(); map = new GameObject[row, col]; grid = new int[row, col]; for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { grid[i, j] = 0; //map[i,j] = (GameObject)Instantiate(prefab,new Vector3(i*.32f*4,j*.32f*4,0),Quaternion.identity); } } int x = 0; int y = Random.Range(0, col); grid [x, y] = -1; CreatMap(x, y); for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { float position_x = transform.position.x + i * tileWidth * numTiles_inRow; float position_y = transform.position.y + j * tileHeight * numTiles_inCol; if (grid[i, j] != 0) { if (grid[i, j] == 3) { map[i, j] = (GameObject)Instantiate(room3, new Vector3(position_x, position_y, 0), Quaternion.identity); map[i, j].transform.parent = transform; } if (grid[i, j] == 2) { map[i, j] = (GameObject)Instantiate(room1, new Vector3(position_x, position_y, 0), Quaternion.identity); map[i, j].transform.parent = transform; } if (grid[i, j] == 5) { map[i, j] = (GameObject)Instantiate(roomFinal, new Vector3(position_x, position_y, 0), Quaternion.identity); map[i, j].transform.parent = transform; } if (grid[i, j] == 4) { map[i, j] = (GameObject)Instantiate(room4, new Vector3(position_x, position_y, 0), Quaternion.identity); map[i, j].transform.parent = transform; } if (grid[i, j] == -1) { map[i, j] = (GameObject)Instantiate(room1, new Vector3(position_x, position_y, 0), Quaternion.identity); map[i, j].transform.parent = transform; } if (grid[i, j] == 1) { map[i, j] = (GameObject)Instantiate(room1, new Vector3(position_x, position_y, 0), Quaternion.identity); map[i, j].transform.parent = transform; } } if (grid[i, j] == 0) { map[i, j] = (GameObject)Instantiate(room0, new Vector3(position_x, position_y, 0), Quaternion.identity); map[i, j].transform.parent = transform; } map[i, j].GetComponent <RoomGen>().roomDifficulty = (int)(i + Random.Range(1, 2)) * Random.Range(5, 10); } } }