using UnityEngine;
using System.Collections;

public class AutoWater : MonoBehaviour {
	
	public GameObject pot;
	public int cost;
	
	public AudioClip sound;
	
	private States states;
	
	// Use this for initialization
	void Start ()
	{
		states = GameObject.Find ("Player").GetComponent<States>();
		GetComponent<InteractText>().interactText = "Install irrigation : $" + cost;
	}
	
	void Use ()
	{
		if (states.playerMoney >= cost)
		{
			AudioSource.PlayClipAtPoint(sound, transform.position);
			states.playerMoney -= cost;
			pot.GetComponent<Plant>().auto = true;
			gameObject.SetActive(false);
		}
	}
}
