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

[RequireComponent(typeof(LineRenderer))]
public class Noise : MonoBehaviour
{
	private LineRenderer lr = null;

	private float radius = 0;

	[SerializeField]
	private float spreadSpeed = 5;

	[SerializeField]
	private LayerMask blockMask;

	private void Start()
	{
		lr = GetComponent<LineRenderer>();
	}

	private void Update()
	{
		radius += spreadSpeed * Time.deltaTime;
		for (int i = 0; i < 360; i++)
		{
			foreach (var hit in Physics2D.LinecastAll(transform.position, (transform.position + Quaternion.Euler(0, 0, i) * new Vector3(radius, 0, 0))))
			{
				NoiseProtectionObstacle obstacle = hit.collider.GetComponent<NoiseProtectionObstacle>();
				if (obstacle == null)
					continue;
				obstacle.GetNoiseProtection(hit.fraction);
			}
		}
	}
}
