333GameStudio

Player health(js)

Apr 22nd, 2015
462
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma strict
  2.  
  3. var Health = 100;
  4. var player : GameObject;
  5. var healthgreen : GameObject;
  6. var healthyellow : GameObject;
  7.  
  8. function ApplyDammage (TheDammage : int)
  9. {
  10.     Health -= TheDammage;
  11.    
  12.     if(Health <= 0)
  13.     {
  14.         Dead();
  15.     }
  16.     {
  17.     if(Health <= 80)
  18.     {
  19.     healthgreen.SetActive(true);
  20.     }
  21.     }
  22.         {
  23.     if(Health <= 20)
  24.     {
  25.     healthyellow.SetActive(true);
  26.     }
  27.     }
  28.    
  29.    
  30.    
  31. }
  32.  
  33. function Dead (){
  34. player.animation.Play();
  35. yield WaitForSeconds(1.5);
  36. player.animation.Stop();
  37. yield WaitForSeconds(4);
  38.     Application.LoadLevel("test");
  39.    
  40. }
Advertisement
Add Comment
Please, Sign In to add comment