using UnityEngine;
using System.Collections;

public class InputManager : MonoBehaviour {
	public bool action_taken = false;
	private CharecterManager charecterManager;
	private TurnManager turnManager;

	// Use this for initialization
	void Start () {
		charecterManager = GetComponent<CharecterManager>();
		turnManager = GetComponent<TurnManager>();
	}
	
	// Update is called once per frame
	void Update () {	
		action_taken = false;
		if(turnManager.IsPlayersTurn()){
			if ( Input.GetAxis("Horizontal") > 0 ){
				action_taken = charecterManager.MovePlayer(Direction.RIGHT);
			} else if( Input.GetAxis("Horizontal") < 0 ){
				action_taken = charecterManager.MovePlayer(Direction.LEFT);
			} else if( Input.GetAxis("Vertical") > 0 ){
				action_taken = charecterManager.MovePlayer(Direction.UP);
			} else if( Input.GetAxis("Vertical") < 0 ){
				action_taken = charecterManager.MovePlayer(Direction.DOWN);
			} else {
			
			}
		} else {
			// Options like spacebar to scroll through message.
		}
		if (action_taken){
			turnManager.NextTurn();
		}
	}
}
