using UnityEngine;
using System.Collections;

public class reticleOverlay : MonoBehaviour {
	public bool toggleStandardCrosshair = true;
	public GameObject crosshairStandard;
	public GameObject crosshairInteract;
	
	void Start ()
	{
		crosshairStandard = GameObject.Find ("/Chef!/GUI/crosshairImage_Standard");
		crosshairInteract = GameObject.Find ("/Chef!/GUI/crosshairImage_Interact");
	}
	
	// Update is called once per frame
	void Update () 
	{
		
		Ray ray = camera.ViewportPointToRay (new Vector3 (0.5F, 0.5F, 0));
		RaycastHit hit;
		
		if (Physics.Raycast (ray, out hit)) {
			print ("I'm looking at ..." + hit.transform.name);
			
			if (hit.transform.CompareTag ("Interactable_ON"))
				toggleStandardCrosshair = false;
			else
				toggleStandardCrosshair = true;
			
			crosshairUpdate();
		}
		
		else {
			
			print ("I'm looking at nothing!");
			
			toggleStandardCrosshair = true;
			
			crosshairUpdate();
		}
	}
	
	public void crosshairUpdate()
	{
		if (toggleStandardCrosshair == false) {
			crosshairStandard.SetActive (false);
			crosshairInteract.SetActive (true);
			print ("Flipped Standard False");
		}
		
		else if (toggleStandardCrosshair == true) {
			crosshairStandard.SetActive (true);
			crosshairInteract.SetActive (false);
			print ("Flipped Standard True");
		}
	}
}