using System;
using Data;
using UnityEngine;

public class Pawn : MonoBehaviour
{
    [SerializeField] private UnitData unitData;
    [SerializeField] private SpriteRenderer spriteRenderer;
    [SerializeField] private Animator animator;
    
    
    private Vector2 _moveInput;

    public virtual void HandleMove(Vector2 input)
    {
        _moveInput = input;
        animator.Play(input.magnitude > 0 ? "Walk" : "Idle");
        if(_moveInput.magnitude > 0)
            spriteRenderer.flipX = _moveInput.x < 0;
    }

    private void FixedUpdate()
    {
        transform.Translate(_moveInput * unitData.MoveSpeed);
    }
}
