void GenerateLevel() { levelCompleted = false; LaunchPlayer launcher = FindObjectOfType <LaunchPlayer>(); if (launcher) { launcher.transform.parent = null; launcher.transform.position = launcher.generateRandomSpawnLocation(); } else { launcher = Instantiate(launchPadPrefab, transform) as LaunchPlayer; launcher.transform.parent = null; launcher.transform.position = launcher.generateRandomSpawnLocation(); } if (Player) { Player.GetComponent <Rigidbody>().velocity = new Vector3(0, Player.GetComponent <Rigidbody>().velocity.y, 0); Player.transform.position = launcher.transform.position + Vector3.up * 10; } }
void Start() { playerRB = GetComponent <Rigidbody2D>(); launcher = FindObjectOfType <LaunchPlayer>(); manager = FindObjectOfType <GameManager>(); manager.gamePaused = false; upgrades.DeactivateShop(); if (!manager.seenTutorial) { gameOptions.ShowTutorial(); } }
private void OnTriggerEnter(Collider other) { if (other.CompareTag("Player")) { if (CheckLevelCompleteStatus()) { // level complete no need to call this method again; return; } other.GetComponent <PlayerParticleController>().OnPlayerLaunched(); LaunchRigidBody = other.GetComponent <Rigidbody>(); Vector3 spawnedPos = generateRandomSpawnLocation(); Vector3 newLookRot = Quaternion.LookRotation(transform.position - spawnedPos, Vector3.up).eulerAngles; newLookRot.x = newLookRot.z = 0; GameObject newSpawnPlace = Instantiate(launchPadPrefab, spawnedPos, Quaternion.Euler(newLookRot)); LaunchPlayer launcher = newSpawnPlace.GetComponent <LaunchPlayer>(); // previous launchPad is removed from the scene if (launcher) { launcher.previousLauncher = this; } if (previousLauncher) { LevelManager.RemovePreviousObstacles(); previousLauncher.DestroyObjectAnditsItems(); } newSpawnPlace.name = "PlayerFallPlace"; randomLocation = newSpawnPlace.GetComponentInChildren <LandLocationCollider>().generateRandomPoint(); Launch(randomLocation); SpawnPickableItems(newSpawnPlace.transform.position); UI_Manager.Instance.UpdateLandingText(Vector3.Distance(other.transform.position, transform.position)); OnLanded(other.gameObject); newSpawnPlace.transform.position = spawnedPos; } }