using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.InputSystem;

public class PlayerController : MonoBehaviour
{
    private Player player;

    private void Start()
    {
        player = GetComponent<Player>();
    }
    
    private void FixedUpdate()
    {
        player.AddGravityForceOnJump();
        player.MoveHorizontal();
    }

    private void OnMove(InputValue value)
    {
        player.SetInputVector(value);
    }

    private void OnDash(InputValue value)
    {
        if (value.isPressed)
        {
            player.Dash();   
        }
    }
    
    private void OnJump(InputValue value)
    {
        player._isJumping = value.isPressed;
        if(value.isPressed)
        {
            player.Jump();
        }
    }

    
    private void OnAttack(InputValue value)
    {
        if (player.IsDashing)
        {
            return;
        }
    
        if (value.isPressed)
        {
            player.Attack();
        }
    }
    
    // private void OnTriggerEnter2D(Collider2D collision)
    // {
    //     if (player.IsDashing())
    //     {
    //         player.AttackOnDash(collision);
    //     }
    // }
}