using UnityEngine;
using System.Collections;

public class PC : MonoBehaviour {

    private KeyCode leftButton = KeyCode.A;
    private KeyCode rightButton = KeyCode.D;
    private KeyCode upButton = KeyCode.W;
    private KeyCode downButton = KeyCode.S;
    private KeyCode torch = KeyCode.X;
    private KeyCode pray = KeyCode.Z;

    private Monk monk;

	// Use this for initialization
	void Start () {
        monk = GetComponent<Monk>();
	}
	
	// Update is called once per frame
	void Update ()
	{
        float lr = GetLeftRight();
        if (lr != 0)
        {
            monk.Move(lr < 0 ? Monk.Direction.Left : Monk.Direction.Right);
        }
        else
        {
            float ud = GetUpDown();
            if (ud != 0)
            {
                monk.Move(ud < 0 ? Monk.Direction.Down : Monk.Direction.Up);
            }
            else
            {
                monk.Stop();
            }
        }

		if (Input.GetKey(torch))
		{
			monk.Stop();
			monk.Pray(0);
		}
		if (Input.GetKey(pray))
		{
			monk.Stop();
			monk.Pray(1);
		}
	}

    private float GetLeftRight()
    {        
        //return Input.GetAxis("Horizontal");

        if (Input.GetKey(leftButton))
        {
            return -1;
        }
        if (Input.GetKey(rightButton))
        {
            return +1;
        }
        return 0;
    }

    private float GetUpDown()
    {
        //return Input.GetAxis("Vertical");

        if (Input.GetKey(downButton))
        {
            return -1;
        }
        if (Input.GetKey(upButton))
        {
            return +1;
        }
        return 0;
    }


}
