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

public class PlayerInput : MonoBehaviour
{
    [SerializeField] InputStatus _status;
    [SerializeField] PlayerMove _move;
    [SerializeField] PlayerAttack _attack;
    public int _vect = default;

    private int horizontal = default; //キーの入力値　縦方向　Ｗ＝１　　Ｓ＝２
    private int verticul = default; //キーの入力値　横方向　　Ｄ＝１０　Ａ＝２０
    private int addvect = default;
    private void Update()
    {
        if(_status.state == 0)
        {
            _vect = SetVect();
            _move.Move(_vect);
            if (Input.GetKeyDown(KeyCode.Space))
            {
                _attack.Strike();
            }
        }
    }

    private int SetVect()
    {
        if (Input.GetKey(KeyCode.W) && Input.GetKey(KeyCode.S))
        {
            horizontal = 0;
        }
        else if (Input.GetKey(KeyCode.W))
        {
            horizontal = 2;
        }
        else if (Input.GetKey(KeyCode.S))
        {
            horizontal = 1;
        }
        else
        {
            horizontal = 0;
        }

        if (Input.GetKey(KeyCode.D) && Input.GetKey(KeyCode.A))
        {
            verticul = 0;
        }
        else if (Input.GetKey(KeyCode.D))
        {
            verticul = 20;
        }
        else if (Input.GetKey(KeyCode.A))
        {
            verticul = 10;
        }
        else
        {
            verticul = 0;
        }


        addvect = horizontal + verticul;


        return addvect;
    }

}
