using UnityEngine;
using System.Collections;

public class RayCollision : MonoBehaviour 
{
    public float MinDamagePerSecond = 0f;
    public float MaxDamagePerSecond = 0f;

    private float _Intensity = 0f;

    public void SetIntensity(float i_Intensity)
    {
        _Intensity = Mathf.Max(i_Intensity, 0f);
    }

    void OnTriggerStay2D(Collider2D collider)
    {
        if (collider.gameObject.CompareTag("Player"))
        {
            float ratio = Mathf.Lerp(MinDamagePerSecond, MaxDamagePerSecond, _Intensity);
            collider.gameObject.SendMessage("AddDamage", ratio * Time.deltaTime);
        }
    }

}
