Advertisement
Guest User

Untitled

a guest
Jun 5th, 2015
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class LevelManager : MonoBehaviour {
  5.  
  6. public GameObject currentCheckpoint;
  7.  
  8. private PlayerController player;
  9.  
  10. public GameObject deathParticle;
  11. public GameObject respawnParticle;
  12.  
  13. public int pointPenaltyOnDeath;
  14.  
  15. public float respawnDelay;
  16.  
  17. public HealthManager healthManager;
  18.  
  19. // Use this for initialization
  20. void Start () {
  21. player = FindObjectOfType<PlayerController>();
  22.  
  23. healthManager = FindObjectsOfType<HealthManager>();
  24. }
  25.  
  26. // Update is called once per frame
  27. void Update () {
  28. }
  29.  
  30. public void RespawnPlayer()
  31. {
  32. StartCoroutine("RespawnPlayerCo");
  33. }
  34.  
  35. public IEnumerator RespawnPlayerCo()
  36. {
  37. Instantiate (deathParticle, player.transform.position, player.transform.rotation);
  38. player.enabled = false;
  39. player.GetComponent<Renderer>().enabled = false;
  40. ScoreManager.AddPoints(-pointPenaltyOnDeath);
  41. Debug.Log ("Player Respawn");
  42. yield return new WaitForSeconds(respawnDelay);
  43. player.enabled = true;
  44. player.GetComponent<Renderer>().enabled = true;
  45. healthManager.FullHealth();
  46. healthManager.isDead = false;
  47. player.transform.position = currentCheckpoint.transform.position;
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement