using UnityEngine;
using System.Collections;

public class LDPlayerMovement : TM_MovementComponent
{
    private Rewired.Player myRewiredPlayer;

    public float PlayerSpeed = 3.0f;

    private GameManager theGame;

    void Awake()
    {
        myRewiredPlayer = Rewired.ReInput.players.GetPlayer(0);
    }

    void Start()
    {
        theGame = GameManager.GetGame();
    }

    void Update()
    {
        if (theGame.GetGameState() != EGameState.gameplay)
        {
            return;
        }

        CalculateMoveThisFrame();
    }

	// Update is called once per frame
    public override void CalculateMoveThisFrame()
	{
        _vDesiredMoveThisFrame = Vector3.zero;

        Vector2 moveDir = myRewiredPlayer.GetAxis2D("MoveHorizontal", "MoveVertical");
        moveDir *= Time.deltaTime * PlayerSpeed;

        _vDesiredMoveThisFrame = new Vector3(moveDir.x, moveDir.y, 0);

	}

}
