using UnityEngine;
using System.Collections;

public class TongueController : MonoBehaviour {
	
	#region Private Variables
	private Vector3 _defaultPosition;
	private Vector3 _endPosition;
	private bool _moveDown = false;
	private float _smoothing = 4f;
	#endregion

	#region Public Variables
	public Transform tongueObject;
	#endregion

	
	#region Events
	void Awake () {

		_defaultPosition = transform.position;

		_endPosition = _defaultPosition;
		_endPosition.y -= 5f;
		
	}

	void Update () {

 		Vector3 target = _moveDown ? _endPosition : _defaultPosition;
		tongueObject.position = Vector3.Lerp (tongueObject.position, target, Time.deltaTime * _smoothing);
		
	}

	void OnTriggerEnter2D (Collider2D c) {
		
		_moveDown = true;
		
	}


	void OnTriggerExit2D () {

		_moveDown = false;
		
	}
	#endregion

}
