Advertisement
irishstorm

health

Apr 2nd, 2013
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. // Author : Christopher Cullen
  2. // Date : 17/10/2012
  3. static public var health : int = 100;
  4. public var healthGUI : GUIStyle;
  5.  
  6. function Update ()
  7. {
  8. if(health < 0 )
  9. {
  10. health = 0;
  11. }
  12.  
  13. if(health > 100 )
  14. {
  15. health = 100;
  16. }
  17. }
  18.  
  19.  
  20. function ChangeHealthColour()
  21. {
  22. if(health >= 75 )
  23. {
  24. healthGUI.normal.textColor = Color.green;
  25. }
  26.  
  27. if(health <= 74 && health >= 26 )
  28. {
  29. healthGUI.normal.textColor = Color( 0.96, 0.60, 0);
  30. }
  31.  
  32. if(health <= 25 )
  33. {
  34. healthGUI.normal.textColor = Color.red;
  35. }
  36. }
  37.  
  38. // To use this add "Name of this script".ApplyHealth( a int , a string);
  39.  
  40. static function ApplyHealth(Health : int, type : String)
  41. {
  42. if(type == "Add")
  43. {
  44. health += Health;
  45. }
  46. else if(type == "Subtract")
  47. {
  48. health -= Health;
  49. }
  50. else if(type == "Multiply")
  51. {
  52. health *= Health;
  53. }
  54. else if(type == "Divide")
  55. {
  56. health /= Health;
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement