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

public class ProjectileScript : MonoBehaviour
{
    [SerializeField] float Damage = 1;

    float MaxTimeToDestroy = 3.0f;

    private void Update()
    {
        MaxTimeToDestroy -= Time.deltaTime;

        if(MaxTimeToDestroy <= 0)
        {
            Destroy(this.gameObject);
        }
    }


    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Enemy"))
        {
            TargetBase target = collision.GetComponent<TargetBase>();
            if (target)
            {
                target.NotifyShot(Damage);
                Destroy(this.gameObject);
            }
        }
    }

}
