Enemy Attack Further Away

Sometimes it would need to be x however there will be times where it needs to be y. Since it depends on the direction the enemy id attacking and the player is facing no?