Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class LevelManager : MonoBehaviour {
- public GameObject currentCheckpoint;
- private PlayerController player;
- public GameObject deathParticle;
- public GameObject respawnParticle;
- public int pointPenaltyOnDeath;
- public float respawnDelay;
- public HealthManager healthManager;
- // Use this for initialization
- void Start () {
- player = FindObjectOfType<PlayerController>();
- healthManager = FindObjectsOfType<HealthManager>();
- }
- // Update is called once per frame
- void Update () {
- }
- public void RespawnPlayer()
- {
- StartCoroutine("RespawnPlayerCo");
- }
- public IEnumerator RespawnPlayerCo()
- {
- Instantiate (deathParticle, player.transform.position, player.transform.rotation);
- player.enabled = false;
- player.GetComponent<Renderer>().enabled = false;
- ScoreManager.AddPoints(-pointPenaltyOnDeath);
- Debug.Log ("Player Respawn");
- yield return new WaitForSeconds(respawnDelay);
- player.enabled = true;
- player.GetComponent<Renderer>().enabled = true;
- healthManager.FullHealth();
- healthManager.isDead = false;
- player.transform.position = currentCheckpoint.transform.position;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement