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

public class EnemyTaunt : MonoBehaviour {

	public GameObject player;
	public TextMesh tauntText;

	private int sanityLevel;
	private bool collision;

	// Use this for initialization
	void Start () {
		tauntText.text = "";
	}
	
	// Update is called once per frame
	void Update () {
		//tauntText.transform.position = Camera.main.WorldToViewportPoint (gameObject.transform.position);
		player = GameObject.Find("Player");
		Move playerScript = player.GetComponent<Move> ();
		sanityLevel = playerScript.sanityLevel;

		if (collision == true) {
			if (sanityLevel == 0) {
				tauntText.text = "HAHA Loser!";
			}
			if (sanityLevel == 10) {
				tauntText.text = "You Suck!";
			}
			if (sanityLevel == 20) {
				tauntText.text = "Failure!";
			}
			if (sanityLevel == 30) {
				tauntText.text = "Smell you later!";
			}
			if (sanityLevel == 40) {
				tauntText.text = "HAHA Loser!";
			}
			if (sanityLevel == 50) {
				tauntText.text = "You Suck!";
			}
			if (sanityLevel == 60) {
				tauntText.text = "Failure!";
			}
			if (sanityLevel == 70) {
				tauntText.text = "Smell you later!";
			}
			if (sanityLevel == 80) {
				tauntText.text = "HAHA Loser!";
			}
			if (sanityLevel == 90) {
				tauntText.text = "Failure!";
			}

		} 

		if (collision == false) {
			tauntText.text = "";
		}
	}

	void OnTriggerEnter(Collider other)
	{
		if (other.gameObject.CompareTag ("Player")) {
			if(other.gameObject.GetComponent<MeshRenderer>().isVisible)
			{
				collision = true;
			}
		}
	}
	
	void OnTriggerExit(Collider other)
	{
		if (other.gameObject.CompareTag ("Player")) {
			collision = false;
		}
	}
}
