using System;
using UnityEngine;
using DG.Tweening;
using System.Collections;

public class AttackProjectile : MonoBehaviour
{
    [SerializeField]
    private float _speed;
    public void Throw(PlayerController thrower, float strength, Action<PlayerController, Vector3> callback)
    {
        GetComponent<Rigidbody2D>().AddForce(thrower.ShootingPoint.right * strength);
        StartCoroutine(DestroyProjectile(thrower, callback));
    }

    private IEnumerator DestroyProjectile(PlayerController thrower, Action<PlayerController, Vector3> callback)
    {
        yield return new WaitForSeconds(2);
        callback(thrower, transform.position);
        Destroy(gameObject);
    }
}
