#pragma strict

var texHbarOverlay : Texture2D;
var texHbar : Texture2D;

var hp : float;

function Start()
{
	Agent.FindPlayer();
}

function Update()
{
	hp = Agent.Player.GetComponent(Player).Health;
}

function OnGUI()
{
	var W = Screen.width;
	var H = Screen.height;
	var min_size : float = Mathf.Min( W, H );
	var hudScale : float = min_size / 1400.0;
	
	var HPBBackScale : Vector2 = Vector2(678*hudScale,80*hudScale);
	var HPBScale : Vector2 = Vector2(671*hudScale,38*hudScale);
	
	GUI.BeginGroup (new Rect (20, 20, HPBBackScale.x, HPBBackScale.y));
		GUI.BeginGroup (new Rect (2, 2, hp*(HPBScale.x/100), HPBScale.y));
			GUI.DrawTexture(Rect(0,0,HPBScale.x,HPBScale.y), texHbar);
		GUI.EndGroup ();
		GUI.DrawTexture(Rect(0,0,HPBBackScale.x,HPBBackScale.y), texHbarOverlay);
	GUI.EndGroup ();
}