using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class Move : MonoBehaviour {

	private Rigidbody rb;
	public int speed;
	public int health;
	public int sanityLevel;

	
	public Text text;
	public Text gameOverText;

	// Use this for initialization
	void Start () {
		rb = GetComponent<Rigidbody>();
		text.text = "";
		gameOverText.text = "";
	}

	void Update(){
		text.text = "Sanity Level: " + sanityLevel;

		if (sanityLevel <= 0) {
			sanityLevel = 0;
			gameOverText.text = "YOU HAVE DIED";
			Application.LoadLevel(2);
		}
	}
	
	void FixedUpdate ()
	{
		float moveHorizontal = Input.GetAxis ("Horizontal");
		float moveVertical = Input.GetAxis ("Vertical");
		
		Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
		
		rb.AddForce (movement * speed);
	}
	
	
	
	IEnumerator wait()
	{
		yield return new WaitForSeconds(25);
	}
}
