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

public class AutomaticCircuit : MonoBehaviour {

	public float time;
	private int state;
	// Use this for initialization
	void Start () {
		state = 0;
		InvokeRepeating("Toggle", 2.0f, time);
	}
	
	// Update is called once per frame
	void Update () {
		
	}

	void Toggle () {
		for (int i = 0; i < gameObject.transform.childCount; i++) {
			gameObject.transform.GetChild (i).GetComponent<CircuitCube> ().state = state;
		}
		state = (state == 0) ? 1 : 0;
	}
}
