private void ChangeDoorState() { int count = 0; foreach (GameObject DS in DoorSwitch) { if (DS.GetComponent <DoorSwitch> ().DS_open == true) { count++; } if (count == DoorSwitch.Length) { open = true; } else { open = false; } } }