using UnityEngine;
using System.Collections;

public class EraseDisplaySymbol : MonoBehaviour {

    public AudioClip clearSound;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}

	public void OnClick()
	{
		Dictionaries.dictionaries.currentDisplaySymbols = new ArrayList(GameObject.FindGameObjectsWithTag("displaySymbol"));

        if(Dictionaries.dictionaries.currentDisplaySymbols.Count > 0)
        {
            GetComponent<AudioSource>().PlayOneShot(clearSound);

//            for (int i = 0; i < Dictionaries.dictionaries.currentDisplaySymbols.Count; i++)
//            {
//                if (i == Dictionaries.dictionaries.currentDisplaySymbols.Count - 1)
//                {
//                    Destroy(((GameObject)Dictionaries.dictionaries.currentDisplaySymbols[i]));
//                }
//                else
//                {
//                    ((GameObject)Dictionaries.dictionaries.currentDisplaySymbols[i]).transform.position += new Vector3(20.0f, 0, 0);
//                }
//                if (Dictionaries.dictionaries.messageToSend != "")
//                {
//                    string sub = Dictionaries.dictionaries.messageToSend.Substring(0, Dictionaries.dictionaries.messageToSend.Length - 1);
//                    Dictionaries.dictionaries.messageToSend = sub;
//                }
//            }
//
//			Dictionaries.dictionaries.currentDisplaySymbols.RemoveAt(Dictionaries.dictionaries.currentDisplaySymbols.Count - 1);
			for (int i = 0; i < Dictionaries.dictionaries.currentDisplaySymbols.Count; i++)
			{
				Destroy(((GameObject)Dictionaries.dictionaries.currentDisplaySymbols[i]));
			}
			Dictionaries.dictionaries.messageToSend = "";
			Dictionaries.dictionaries.currentDisplaySymbols.Clear();

        }        
	}
}
