public IEnemyLogicState HandleEvent(IGameObject gameObject, IGameWorld gameWorld, object gameEvent) { if (gameEvent is ShellHitEvent) { var destructionState = new EnemyLogicDestructionState(_enemyData); destructionState.Init(gameObject, gameWorld); return(destructionState); } if (gameEvent is FireEvent) { if (_currentUpdatesForReload == 0) { var fireEvent = gameEvent as FireEvent; _currentUpdatesForReload = _updatesForReload; var(fireX, fireY) = _geometryMathService .PointOnBoundary(gameObject, fireEvent.Direction); var fireCommandOptions = new FireCommandOptions(fireX, fireY, fireEvent.Direction); _fireCommand.Do(gameObject, gameWorld, fireCommandOptions); } } return(this); }
public void HandleEvent(IGameObject gameObject, IGameWorld gameWorld, object gameEvent) { if (gameEvent is FireEvent) { var fireEvent = gameEvent as FireEvent; var(fireX, fireY) = _geometryMathService .PointOnBoundary(gameObject, fireEvent.Direction); var fireCommandOptions = new FireCommandOptions(fireX, fireY, fireEvent.Direction); _fireCommand.Do(gameObject, gameWorld, fireCommandOptions); } if (gameEvent is ShellHitEvent) { gameWorld.SendEvent(new PlayerKilled()); } if (gameEvent is MovedEvent) { var movedEvent = gameEvent as MovedEvent; _consoleWriter.SetCameraCenter(movedEvent.NewX, movedEvent.NewY); } }