using UnityEngine;
using System.Collections;

public class Maquina : MonoBehaviour {
	public int pctCompleto = 0;
	public bool consertando;
	public Rect r;

	void Awake() {
		r = new Rect (Screen.width / 9, Screen.height * 7 / 8, Screen.width * 7 / 9, 20);
	}

	public void Inicia() {
		consertando = true;
		audio.Play ();
	}

	public void para() {
		consertando = false;
	}

	public bool consertaUnidade() {
		pctCompleto++;

		if (pctCompleto >= 100)
						audio.Stop ();
		return pctCompleto >= 100;
	}

	void OnGUI() {
		if (consertando) {
			//GUI.Label(r, Color.blue);

			GUI.Box(r, GUIContent.none);
			GUI.Box(new Rect(r.x+2,r.y+2, (Screen.width * 7 / 9-4) * (pctCompleto*0.01f),16), GUIContent.none);
		}
	}
}
