using UnityEngine;
using System.Collections;

public class Scale : MonoBehaviour
{
		public int ID;
		// Use this for initialization
		void Start ()
		{
	
		}
	
		// Update is called once per frame
		void Update ()
		{
	
		}

		void OnCollisionStay (Collision other)
		{
				bool toggled = false;
				if (other.collider.gameObject.CompareTag ("Player")) {
						if (Mass.Energy >= 50) {
								GameObject[] toggles = GameObject.FindGameObjectsWithTag ("Toggle");
								for (int i=0; i<toggles.Length; i++) {
										if (toggles [i].GetComponent<Toggle> () != null && toggles [i].GetComponent<Toggle> ().ID == this.ID) {
												toggles [i].GetComponent<Toggle> ().toggle ();
												toggled = true;
										}

								}
						}
				}
				if (toggled) {
						Destroy (this.gameObject);
				}
		}
}
