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

public class Player_Attack : MonoBehaviour {

    private bool isAttacking = false;

    private float attackTimer = 0;
    private float attackCd = .7f;

    public Collider2D attackTrigger;

    private Animator anim;

    void Awake()
    {
        anim = gameObject.GetComponent<Animator>();
        attackTrigger.enabled = false;
    }


    private void Update()
    {
        if (Input.GetButtonDown("Attack") && !isAttacking)
        {
            isAttacking = true;
            attackTimer = attackCd;
            attackTrigger.enabled = true;

        }

        if (isAttacking)
        {
            if (attackTimer > 0)
            {
                attackTimer -= Time.deltaTime;
            }
            else
            {
                isAttacking = false;
                attackTrigger.enabled = false;
            }
        }

        anim.SetBool("IsAttacking", isAttacking);
    }

}
