Just cant seem to figure out this simple problem

So I got 6 gameobjects (3 soldier of each team) walking towards each other in a line (3 on the left, walk to the right and 3 on the right that walk to the left) with a rigidbody 2D.

There are two towers on that line, one for each team.

Im trying to make it so the soldiers move and if they collide with a tower, attack it. If they collide with an enemy, attack it. This I can do very easily.

The problem is when multiple soldiers show up.

I want to give attacking soldiers priority in relation to the tower, so if you are attacking the tower you stop and start attacking the enemy soldier.

If there are multiple enemy soldiers the soldier will attack one and when the enemy soldier is dead, attack the other one until no more enemy soldiers are present, at which point the soldier will keep moving foward.

My issue here is the collider thingy to give priority or to remove it, I tried with queues, with OnColliderStay2D, with OnColliderEnter2D but I just cant seem to make it work properly… Anyone can give me a hand?

I tried with coroutines, queues but I always get so tangled up both in code and in my mind that I believe im just complicating the code.

I tried something like this:

int lel = Physics2D.OverlapCircle(transform.position, .8f, new ContactFilter2D(), listResults);
            float distanceMax = 0;
            if (lel > 0) {
                esse.Pause();
                foreach (Collider2D esseMesmo in listaDeAtaque) {
                    float temp = Vector2.Distance(esseMesmo.gameObject.transform.position,transform.position);
                    if (temp > distanceMax) {
                        distanceMax = temp;
    
                    }
                }
            }

But it just doesnt work and gets way too complicated, can anyone give me a hand on this?

Where is your code you filled the list listaDeAtaque. If you are using collision event why do you still using overlapcircle?