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

[RequireComponent (typeof(WaveController))]
public class ClickyWaves : MonoBehaviour 
{
	[SerializeField]
	private LayerMask trampLayer;
	private WaveController wc;
	// Use this for initialization
	void Start () 
	{
		wc = GetComponent<WaveController> ();
	}
	
	// Update is called once per frame
	void Update () 
	{
		if (Input.GetMouseButtonDown (0)) 
		{
			Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
			RaycastHit hit;
			if (Physics.Raycast (ray, out hit, float.MaxValue,trampLayer)) 
			{		
				WaveController.WaveInfo wave = wc.GetWaveAtPosition (hit.point);
				//print (wave.height);
				//print (wave.normal);
				wc.MakeWave (hit.point, 1f);
			}
		}
	}
}
