using UnityEngine;
using System.Collections;

public class reticleRaycast : MonoBehaviour {
	public bool toggleStandardCrosshair = true;
	public Texture2D crosshairStandard;
	public Texture2D crosshairInteract;
	float horizRatio = Screen.width;
	float vertRatio = Screen.height;
	public float timer = 300;
	public Camera MainCamera;
	public Camera SinkCamera;
	public Camera TrashCamera;
	public Camera CounterCamera;
	public Camera PantryCamera;
	public Camera StoveCamera;
	public Camera FridgeCamera;
	public Camera FreezerCamera;
		public Camera ExitCamera;
	public int storyProgress;
	public Texture tempEgg;
	public bool showPicture;
	public bool inInteractMode;
	public GameObject interactable;
	public GameObject eggs;



	void Start ()
	{
		SinkCamera.enabled = false;
		TrashCamera.enabled = false;
		CounterCamera.enabled = false;
		PantryCamera.enabled = false;
		StoveCamera.enabled = false;
		FridgeCamera.enabled = false;
		FreezerCamera.enabled = false;
		storyProgress = 0;
		inInteractMode = false;
		interactable = GameObject.Find ("eggPrefab");
		tempEgg = Resources.Load<Texture> ("tempEgg");
		}

	void OnGUI ()
	{
		if (toggleStandardCrosshair == false) 
		{
			GUI.DrawTexture(new Rect(((horizRatio / 2)-16), ((vertRatio / 2)-16),32,32),crosshairInteract);
		}
		if (toggleStandardCrosshair == true) 
		{
			GUI.DrawTexture(new Rect(((horizRatio / 2)-16), ((vertRatio / 2)-16),32,32),crosshairStandard);
		}
		if (showPicture == true) 
		{
			GUI.Label(new Rect(25, 25, 200, 200),"This is a test. This is only a test.");
		}
	}

	// Update is called once per frame
	void Update () 
	{
		Screen.lockCursor = true;
		timer -= Time.deltaTime;
		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;
			if (hit.transform.CompareTag ("egg_Interact"))
			{
				toggleStandardCrosshair = false;
				showPicture = true;
			}
		}
		else
		toggleStandardCrosshair = true;
		showPicture = false;
	}

	void eggInteraction ()
	{

	}

	void OnMouseDown ()
	{

		}

}