﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SphereClick : MonoBehaviour {

	string TextOnSphere;
	string GoalText;

	public void OnMouseDown(){
		//This is the text showing on the sphere
		TextOnSphere = this.transform.GetChild(0).GetComponent<TextMesh> ().text;
		//This is the KeyWord kept by "SpawnerThisWillControllTheSpheres"
		GoalText     = this.GetComponentInParent<RandomWord>().KeyWord; //Because it's public we can get it.

		if (TextOnSphere.ToLower () == GoalText.ToLower ()) {
			//If the text on this sphere was the correct one 
			this.GetComponentInParent<RandomWord> ().CleanupAndReset ();
		} else {
			//If it was the wrong one set it red
			this.GetComponent<SpriteRenderer>().color = new Color(1f,0f,0f);
		}
	}
}
