
var _mainCamera : GameObject;
var _hit : RaycastHit;

var _xyRaw : Vector2 = Vector2.zero;
var _xyPrevious : Vector2 = Vector2.zero;
var _xyDifference : Vector2 = Vector2.zero;

function Awake () {
	_mainCamera = GameObject.Find("MainCamera");
}

function Update () {
	_xyRaw = Input.mousePosition;
	_xyDifference =Vector2(_xyRaw.x-_xyPrevious.x,_xyRaw.y-_xyPrevious.y);
	
	// Construct a Ray from the mouse cordenates
	var _ray : Ray = _mainCamera.GetComponent(Camera).ScreenPointToRay(_xyRaw);
	if(Physics.Raycast(_ray,_hit)){
		Debug.Log(_hit.transform.gameObject.name);
		if(_hit.transform.gameObject.CompareTag("orange")){
			_hit.transform.gameObject.GetComponent(OrangeScript)._distanceDifference = _xyDifference;
			_hit.transform.gameObject.GetComponent(OrangeScript).Explode();
			}
		}
	guiTexture.pixelInset = Rect(Input.mousePosition.x-16,Input.mousePosition.y-16,32,32);
	_xyPrevious = _xyRaw;
}