using UnityEngine;
using System.Collections;

public class Movement : MonoBehaviour 
{
	public Vector3 moveDirec = Vector3.zero;
	private CharacterController charControl;
	public float moveSpeed = 3, creep = 1,walk = 3,run=6;
	public float gravity = 60;
	public MakePing myPing;

	public Animator anima;
	void Start()
	{
		charControl = this.GetComponent<CharacterController>();
		myPing = this.GetComponentInChildren<MakePing>();
		anima = gameObject.GetComponentInChildren<Animator>();
	}
	
	void Update()
	{
		if(Input.GetKey(KeyCode.LeftShift))
		{
			moveSpeed = run;
			myPing.large = true;
			myPing.medium = false;
			myPing.small = false;

		}
		else if(Input.GetKey(KeyCode.LeftControl))
		{
			moveSpeed = creep;
			myPing.large = false;
			myPing.medium = false;
			myPing.small = true;
		}
		else
		{
			moveSpeed = walk;
			myPing.large = false;
			myPing.medium = true;
			myPing.small = false;

			
		}

		#region New
		if(Input.GetKey(KeyCode.W))
		{
			GameObject.Find("Monk").transform.rotation = Quaternion.Euler(0,0,0);
			
		}
		if(Input.GetKey(KeyCode.S))
		{
			GameObject.Find("Monk").transform.rotation = Quaternion.Euler(0,180,0);
			
		}
		if(Input.GetKey(KeyCode.A))
		{
			GameObject.Find("Monk").transform.rotation = Quaternion.Euler(0,-90,0);
			
		}
		if(Input.GetKey(KeyCode.D))
		{
			GameObject.Find("Monk").transform.rotation = Quaternion.Euler(0,90,0);
			
			
		}

		if(!(Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.S) ||Input.GetKey(KeyCode.W)))
		{
			anima.SetBool("Move",false);
		}
		else
		{
			anima.SetBool("Move",true);
		}
		#endregion
		moveDirec = new Vector3(Input.GetAxis("Horizontal"),0,Input.GetAxis("Vertical"));
		moveDirec = transform.TransformDirection(moveDirec);
		moveDirec *= moveSpeed;
		moveDirec .y -= gravity * Time.deltaTime;
		charControl.Move(moveDirec * Time.deltaTime);
	}


}










