You need to do two things:
Check the distance between the player's position and the enemy position.
Check that the angle made by the line between the player and enemy & the line pointing in the direction of the player's view is less than 180degrees.
The first is easy:
bool isCloseEnoughToAttack = Vector.Magnitude( Math.abs(player.position - enemy.position) ) < distanceToStartAttacking
The second is a little more complicated. As long as you don't need to be really particular about what 'in-front of player' means, you can fairly easily check the angle is not behind by checking the Dot Product is greater than 0:
bool isInFrontOfPlayer = Vector.DotProduct(Vector.Normalize(player.position - enemy.position), player.lookAtDirection) > 0
Note - This code is psudeocode, I don't know the exact naming of your variables/libraries; but it should be fairly similar.