Advertisement
daviddevel

Boss

Sep 29th, 2014
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class bossmorre : MonoBehaviour {
  5.  
  6. //iniciotestevar
  7. public float timeToInvencibility = 2;
  8. private float currentTimeToInvencibility = 0;
  9. public float timeToBlink = 0.05f;
  10. private float currentTimeToBlink = 0;
  11. private bool invencibility = false;
  12. public Renderer rendererboss;
  13.  
  14. //fimtestevar
  15.  
  16. bool isDead = false;
  17. int vida = 10;
  18. float tmr = 0;
  19. float aguardar = 5.0f;
  20.  
  21. void Update(){
  22. if (vida <= 0) {
  23. isDead = true;
  24. // tornar invisivel
  25. }
  26. if (isDead) {
  27.  
  28.  
  29. tmr += 1.0f * Time.deltaTime;
  30. if (tmr > aguardar) {
  31.  
  32.  
  33. Application.LoadLevel ("Level02");
  34. }
  35. }
  36.  
  37. //teste
  38. if (invencibility) {
  39.  
  40. currentTimeToBlink+= Time.deltaTime;
  41.  
  42. if(currentTimeToBlink > timeToBlink) {
  43. currentTimeToBlink =0;
  44. rendererboss.enabled = !rendererboss.enabled;
  45.  
  46. }
  47.  
  48.  
  49. currentTimeToInvencibility += Time.deltaTime;
  50. if (currentTimeToInvencibility > timeToInvencibility) {
  51. invencibility = false;
  52. rendererboss.enabled = true;
  53. currentTimeToInvencibility = 0;
  54.  
  55. }
  56.  
  57. }
  58.  
  59. }
  60.  
  61.  
  62.  
  63. void OnTriggerEnter2D(Collider2D col){
  64. if(col.transform.tag.ToLower()=="player" && !invencibility){
  65. vida--;
  66. //teste
  67. invencibility = true;
  68. }
  69. }
  70.  
  71. void OnGUI(){
  72. Rect rLbl = new Rect(0,0,200,200);
  73. // criar mensagem de tela concluida
  74. if(isDead){
  75. GUI.Label(rLbl,"Missão Completa");
  76. }
  77. }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement