See how in your code you ask the same question twice? How you spin waiting for anything, then once anything happens you set pressed, exit and go decide again what to do? You want to alway avoid repeating yourself.
The best way to structure this is to have two panel scripts, one for each: offensive, defensive, etc.
Display the appropriate panel (perhaps have left/right buttons to switch)
When on a panel, respond to the user intents and update the data.
When a panel is inactive, its script should ignore all input intents.
The usual way to do this is to enable and disable input contexts in the OnEnable() / OnDisable() methods of each panel’s script. That way only one panel is listening at a time, if any.
Otherwise, coroutines work like any other code. Check this out:
Coroutines in a nutshell:
Splitting up larger tasks in coroutines:
Coroutines are NOT always an appropriate solution: know when to use them!
“Why not simply stop having so many coroutines ffs.” - orionsyndrome on Unity3D forums
Our very own Bunny83 has also provided a Coroutine Crash Course: