How to handle cpu shooting on player on top-down shooter

Hi to everyone! I’m new and this is my first topic on this forum. So, i have to make a top down shooter with phaser 3 for university. The game is an arcade with tanks, so my problem is about handling enemies’ shooting. I want that enemies will shoot only when they see me, there is any function that do this?? Or do you have any suggestions? Thanks to everyone!

Look at Raycasting.