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

public class Attack : MonoBehaviour
{
    public int attackDamage = 10;
    public Vector2 knockback = Vector2.zero;

    private void OnTriggerEnter2D(Collider2D collision)
    {
        // see if it can be hit
        Damageable damage = collision.GetComponent<Damageable>();

        // hit the target
        if (damage != null)
        {
            Vector2 deliveredKnockback = transform.parent.localScale.x > 0 ? knockback: new Vector2(-knockback.x, knockback.y);
            bool goHit = damage.Hit(attackDamage, deliveredKnockback);

            //if (goHit)
            //{
            //    Debug.Log(collision.name + " hit for " + attackDamage);
            //}
        }
    }
}
