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

public class TriggerCircuit : MonoBehaviour {

	public GameObject circuit;
	public GameObject missingCircuitCube;

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

	void OnTriggerStay(Collider other){
		if (other.gameObject == missingCircuitCube) {
			for (int i = 0; i < circuit.transform.childCount; i++) {
				circuit.transform.GetChild (i).GetComponent<CircuitCube> ().state = 1;
			}
			missingCircuitCube.GetComponent<CircuitCube> ().state = 1;
		}
		
	}

	void OnTriggerExit(Collider other){
		if (other.gameObject == missingCircuitCube) {
			for (int i = 0; i < circuit.transform.childCount; i++) {
				circuit.transform.GetChild (i).GetComponent<CircuitCube> ().state = 0;
			}
			missingCircuitCube.GetComponent<CircuitCube> ().state = 0;
		}

	}
}
