Refactored enemy class to avoid code duplication.