Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Author : Christopher Cullen
- // Date : 17/10/2012
- static public var health : int = 100;
- public var healthGUI : GUIStyle;
- function Update ()
- {
- if(health < 0 )
- {
- health = 0;
- }
- if(health > 100 )
- {
- health = 100;
- }
- }
- function ChangeHealthColour()
- {
- if(health >= 75 )
- {
- healthGUI.normal.textColor = Color.green;
- }
- if(health <= 74 && health >= 26 )
- {
- healthGUI.normal.textColor = Color( 0.96, 0.60, 0);
- }
- if(health <= 25 )
- {
- healthGUI.normal.textColor = Color.red;
- }
- }
- // To use this add "Name of this script".ApplyHealth( a int , a string);
- static function ApplyHealth(Health : int, type : String)
- {
- if(type == "Add")
- {
- health += Health;
- }
- else if(type == "Subtract")
- {
- health -= Health;
- }
- else if(type == "Multiply")
- {
- health *= Health;
- }
- else if(type == "Divide")
- {
- health /= Health;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement