Really strange code...
Firstly you shouldn't check animation check in always clause -> use it in switch behavior. Use of globala variable makes me feel bad/angry/sad as well.
Back to your problem:
[Easy solution]
Makes a lot of mess when you want to have many doors and switches in single scene.
On start: number of active switches =0
In switch behaviotr when hitting the player
If switch (not open) -> switch = open, number of active switches +1
If number of active switches == number of siwtches in scene -> open door
[Better solution]
Door behavior:
- list of switches that are required to be opened for door to open
- custom event : check if all <my> switches are open, i f yes then open myself
In switch behaviotr when hitting the player
If switch (not open) -> switch = open, trigger custom event in door behavior of door that thsi swithc belongs to (check if all switches are open)
In this solution door is a parent object that creates switches. Switches know who is their parent (so they can ask the proper door for check) and parent (door) knwo all switches (list) in order to ask them if all of them are open.
[Easy solution] -> works if you have one door in scene (It would work with 2 as well, but with 3 it would be a mess).
[Better solution] -> always works but it can be pain in the ass since switches must be declared form code not from scene c4reator