using UnityEngine;
using System.Collections;

public class IconControl : MonoBehaviour {

	#region Private Variables
	private string _collidedWith;
	private InMechanic _mechanic;
	private Rigidbody2D _rigidbody;
	private Vector3 _defaultPos;
	#endregion


	#region Getters and Setters
	public string collidedWith {
		get {
			return _collidedWith;
		}
		private set {
			_collidedWith = value;
		}
	}
	#endregion


	#region Events
	void Start () {

		_mechanic = GameObject.FindObjectOfType <InMechanic> ();
		_rigidbody = GetComponent <Rigidbody2D> ();
		_defaultPos = transform.position;
		
	}

	void OnBecameInvisible () {

		transform.rotation = Quaternion.identity;
		transform.position = _defaultPos;

	}

	void OnMouseDown () {

		collidedWith = string.Empty;
		_mechanic.Check ();

	}

	void OnCollisionStay2D (Collision2D c) {

		collidedWith = c.gameObject.tag;
		_mechanic.Check ();
		
	}
	#endregion
	
}
