Attempting to check a bool value in an array

Alright, I want to set some ‘win conditions’ on the levels of my game.

Until now I have just used an arbitrary score, and when you exceed the score, it loads the next scene. That was simple enough. But now I want to change things up for later levels, and I want you to hit a certain target or SET OF TARGETS and exceed a score (it could just as well be limited to hitting certain targets, for our purposes here).

Conceptually, it makes sense. I want to have a bool on these targets, that switch from false to true, after they have been hit. And to load the next scene, none should pass as false (all targets pass as hit/true).

I have the array set up, I think. But how do I access the bool value, in the script, on those target objects?
I am looking for objects that have the script ‘Target’ on them. All will have it, all will have the bool set to true, as default, and then the actual targets I will set to false in the Inspector (so that I can have different targets, and even a different number of targets, on each level).

GameObject[] targets = GameObject.FindObjectsOfType(typeof(Target)) as GameObject[];

Now I have a bool on the script, Target, targetHit, and on collision it obviously changes to true.

But how do I check that bool for all targets in my GameManager script?

foreach (GameObject target in targets)
        {
            if(target.targetHit == true)
            {

           }
        }

That is what I was hoping what would work, but I am getting an error. Clearly I am missing a step, where I tell the script how to check the targets for the bool value, targetHit.

Well, I had to answer my own question. I ended up not using an array. Instead, I have three ‘objectives’, so three bools that I need to switch from false to true on any given level.

I ended up writing a new script, one each for the objectives (my previous attempt had the spectular flaw that if you hit one of the targets three times, the code would view that the same as all three targets being hit, a target is a target after all).

In the first script, OnTriggerEnter2D, bool objective1 in my GameManager script would get flipped to true

void OnTriggerEnter2D(Collider2D other)
{
if(other.gameObject.CompareTag("insertTagHere"))
{
gameManager.objective1 = true;
}

. 2nd objective on the 2nd script, and so on.

In my GameManager, I had the three bools.

Once they are all true, they flip a 4th bool: targetsHit.

If targetsHit returns true and optionally, you have exceeded the score to progress (the previous way I had implemented, to progress levels) it starts the coroutine to load the next scene.

if(objective1 && objective2 && objective3)
{
targetsHit = true;
}

if((score >= scoreToProgress) && targetsHit)
{
StartCoroutine(LoadNewScene());
}

Hope that helps someone out there, at some point in the future!