using UnityEngine;

public class InputController : MonoBehaviour 
{

    private MoveController move;

	void Start () 
	{
        move = GetComponent<MoveController>();
	}

    void Update()
    {

        if (HumanControl.ActiveHuman == transform)
            Move();
    }

    private void Move()
    { 
        Vector2 input = Vector2.zero;
        if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow))
            input += Vector2.up;
        else if (Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow))
            input += Vector2.down;

        if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow))
            input += Vector2.left;
        else if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow))
            input += Vector2.right;

        move.MoveDir = input.normalized;
    }
}
