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

public class Spikes : MonoBehaviour
{
    public LayerMask AttackLayerMask; 

    private SpriteRenderer spriteRenderer;

    public void Awake()
    {
        this.spriteRenderer = this.GetComponent<SpriteRenderer>(); 
    }

    public void FixedUpdate()
    {
        Collider2D[] colliders = Physics2D.OverlapAreaAll(this.spriteRenderer.bounds.min, this.spriteRenderer.bounds.max, AttackLayerMask.value);
        Debug.DrawLine(spriteRenderer.bounds.min, spriteRenderer.bounds.max); 
        foreach(Collider2D collider in colliders)
        {
            Entity e = collider.gameObject.GetComponent<Entity>();
            if (e != null)
            {
                e.Harm(100000, null, this.transform.position);
            }
        }
    }
}
