using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class HealthBar_Logic : MonoBehaviour {

	private global_variables variable_script;
	
	private GameObject gameManager;


	// Use this for initialization
	void Start () {
		gameManager = GameObject.FindGameObjectWithTag ("GameController").gameObject;
		variable_script = gameManager.GetComponent<global_variables> ();
	}
	
	// Update is called once per frame
	void Update () {
			switch (variable_script.playerHealth) {
				case 6:
						gameObject.GetComponent<Image>().sprite=Resources.Load<Sprite> ("images/UI/health");
						break;
				
				case 5:
						gameObject.GetComponent<Image> ().sprite=Resources.Load <Sprite>("images/UI/health5");
						break;
				case 4:
						gameObject.GetComponent<Image> ().sprite=Resources.Load <Sprite>("images/UI/health4");
						break;
		
				case 3:
					gameObject.GetComponent<Image> ().sprite=Resources.Load <Sprite>("images/UI/health3");
					break;

				case 2:
					gameObject.GetComponent<Image> ().sprite=Resources.Load <Sprite>("images/UI/health2");
					break;

				case 1:
					gameObject.GetComponent<Image> ().sprite=Resources.Load <Sprite>("images/UI/health1");
					break;
				
				case 0:
					gameObject.GetComponent<Image> ().sprite=Resources.Load <Sprite>("images/UI/healthblank");
					break;
		}
		
	}
}
