using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BatteryScript : MonoBehaviour {

	public AudioClip pickupSound;

	bool hasBeenTouched = false;
	// Use this for initialization
	void Start () {
		hasBeenTouched = false;
	}
	
	// Update is called once per frame
	void Update () {
		
	}


	protected void OnTriggerEnter2D(Collider2D col)
	{
		if(col.gameObject.tag == "Player" && !hasBeenTouched) 
		{
			this.GetComponent<AudioSource> ().clip = pickupSound;
			this.GetComponent<AudioSource> ().Play ();

			hasBeenTouched = true;
			this.GetComponent<SpriteRenderer> ().enabled = false;
			GameObject.FindGameObjectWithTag ("Player").GetComponent<PlayerScript> ().BatteryGrabbed ();
		}
	}
}
