using UnityEngine;
using System.Collections;

public class HealthBar : MonoBehaviour
	{

	public Material[] materials;
	public int maxHealth;

	public void setHealth( int v )
		{        
		float av = (float)v / maxHealth;
		int index = Mathf.CeilToInt(av * (materials.Length-1));
		renderer.material = materials[index];
		}

	void Update()
		{
		// DEBUG
		//setHealth( Random.Range(0,maxHealth));
		}

	}
