using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class displayItem : MonoBehaviour {
	public Texture2D img;
	private bool isDisplay = false;
	private Camera mCam;

	void Start(){
		mCam = GameObject.Find ("Main Camera").GetComponent<Camera>();
	}

	void OnGUI(){
		if (isDisplay) {
			GUI.DrawTexture (mCam.pixelRect, img, ScaleMode.ScaleToFit, true);
		}
	}
	void OnTriggerEnter(Collider other) {
		if (other.gameObject.name == "Player_2D") {
			Debug.Log ("Showing");
			isDisplay = true;
			GetComponent<AudioSource> ().Play ();
		}
	}

	void Update(){
		if (Input.GetKeyDown("space") && isDisplay) {
			isDisplay = false;
			Destroy (gameObject);
			ItemManager.count--;
		}
	}
}
