public void PlayGame() { rb.bodyType = RigidbodyType2D.Dynamic; Finish finish = FindObjectOfType <Finish>(); if (finish.dynamicRB == true) { finish.GetComponent <Rigidbody2D>().bodyType = RigidbodyType2D.Dynamic; } }
private void GenerateContent() { //instantiate player Player newPlayer = Instantiate(playerPrefab, transform) as Player; newPlayer.name = "Player"; while (GetWall(startCoordinate - new Coordinate(0, 1)) != null) { startCoordinate -= new Coordinate(0, 1); } newPlayer.transform.position = new Vector3(startCoordinate.x * 1.6f - size.x * 0.7f + 0.2f, startCoordinate.y * 1.6f - size.y * 0.7f + 0.2f, 0.0f); //instantiate finish Finish newFinish = Instantiate(finishPrefab, transform) as Finish; newFinish.name = "Finish"; newFinish.GetComponent <Finish>().hasFinished = false; newFinish.transform.position = new Vector3(endCoordinate.x * 1.6f - size.x * 0.7f + 0.2f, endCoordinate.y * 1.6f - size.y * 0.7f + 0.2f, 0.0f); //start spawning enemy once 3 rooms are completed if (saveGame.RoomsCompleted() > 3) { //instantiate enemy for (int x = 0; x < path.Count; x++) { if (!(path[x].coordinates.x < 3)) { if (CanPlaceEnemy(path[x].coordinates)) { Enemy newEnemy = Instantiate(EnemyPrefab, transform) as Enemy; newEnemy.name = "Enemy"; int groundY = path[x].coordinates.y; while (GetWall(new Coordinate(path[x].coordinates.x, groundY) - new Coordinate(0, 1)) != null) { groundY -= 1; } newEnemy.transform.position = new Vector3(path[x].coordinates.x * 1.6f - size.x * 0.7f + 0.2f, groundY * 1.6f - size.y * 0.7f + 0.2f, 0.0f); return; } } } } }