using UnityEngine;
using System.Collections;

public class DollControl : MonoBehaviour {

	#region Private Variables
	public ConsumeManager consumeManager;
	private Vector3 _defaultPos;
	private Rigidbody2D _rigidbody;
	private bool _determined = false;
	#endregion


	#region Events
	void Awake () {

		_defaultPos = transform.position;
		_rigidbody = GetComponent <Rigidbody2D> ();
		
	}

	void OnTriggerEnter2D (Collider2D c) {

		if (c.tag == "Eat" && !_determined) {

			consumeManager.AddScore (this.gameObject, -1);
			_determined = true;
		}

		if (c.tag == "Free" && !_determined) {
			consumeManager.AddScore (this.gameObject, 1);
			_determined = true;
		}

	}
	#endregion


	#region Methods
	public void Reset () {

		transform.position = _defaultPos;
		transform.rotation = Quaternion.identity;
		_rigidbody.gravityScale = 0f;
		_determined = false;

	}
	#endregion

}
