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

public class MouseClick : MonoBehaviour {
	public LayerMask layer;
	private Ray ray;
	private RaycastHit hit;
	public Vector3 target;
	public GameObject prefab;
	public Inventory inv;
	// Use this for initialization
	void Start () {
		prefab = Resources.Load("Prefab/Large/Trigger_Large_PlayerPing")as GameObject;
		inv = GameObject.Find("Player").GetComponent<Inventory>();
	}
	
	// Update is called once per frame
	void Update () {
		if(Input.GetMouseButtonDown(0) )
		{
			ray = Camera.main.ScreenPointToRay(Input.mousePosition);
			if(Physics.Raycast(ray, out hit, layer))
			{
				target = hit.transform.position;
			}
		}
		if(Input.GetMouseButtonUp(0)&& inv.inv[7].Amount > 0 && inv.inv[2].Amount >0)
		{
			Instantiate(prefab,target,Quaternion.identity);
			inv.inv[2].Amount -= 1;
		}

			
	}
}
