public IEnemyInputState Update(IGameObject gameObject, IGameWorld gameWorld) { var player = _gameObjectLocator.GetPlayer(); var distanceToPlayer = gameWorld.GetDistance(gameObject, player); if (distanceToPlayer > _playerLoseDistance || !gameWorld.IsObjectsVisibleToEachOther(gameObject, player)) { return(new EnemyInputIdleState(_gameObjectLocator, _geometryMathService, _enemyData)); } if (distanceToPlayer > _approachingDistance) { var moveAzimuth = _geometryMathService.Azimuth( gameObject.X, gameObject.Y, player.X, player.Y); gameObject.HandleEvent(gameWorld, new MoveEvent(moveAzimuth)); } var fireAzimuth = _geometryMathService.Azimuth( gameObject.X, gameObject.Y, player.X, player.Y); gameObject.HandleEvent(gameWorld, new FireEvent(fireAzimuth)); return(this); }
public IEnemyInputState Update(IGameObject gameObject, IGameWorld gameWorld) { var player = _gameObjectLocator.GetPlayer(); var distanceToPlayer = gameWorld.GetDistance(gameObject, player); if (distanceToPlayer < _playerAggroDistance && gameWorld.IsObjectsVisibleToEachOther(gameObject, player)) { return(new EnemyInputAggroState(_gameObjectLocator, _geometryMathService, _enemyData)); } return(this); }