public IGameObject BuildGameObject(GameObjectSerialized gameObjectSerialized) { if (gameObjectSerialized.GameObjectType != SerializedName) { throw new ArgumentException("Wrong serialized object"); } var stoneGraphicComponent = new CharGraphicComponent(_stoneData.DisplayChar, _consoleWriter); var stone = new GameObject(null, null, null, stoneGraphicComponent); stone.X = gameObjectSerialized.X; stone.Y = gameObjectSerialized.Y; stone.Width = gameObjectSerialized.Width; stone.Height = gameObjectSerialized.Height; return(stone); }
private static IGameWorld CreateWorld(IConsoleWriter consoleWriter) { var gameObjectLocator = new GameObjectLocator(); var lineIntersectionResolver = new LianBarskyIntersectionResolver(); var geometryMathService = new GeometryMathService(lineIntersectionResolver); var serializedGameObjectDataProvider = new SerializedGameObjectDataProvider(); var enemyData = serializedGameObjectDataProvider.GetEnemyData(); var playerData = serializedGameObjectDataProvider.GetPlayerData(); var stoneData = serializedGameObjectDataProvider.GetStoneData(); var shellData = serializedGameObjectDataProvider.GetShellData(); var shellInputComponent = new ShellInputComponent(); var shellPhysicComponent = new PhysicComponent(shellData.Speed); var shellLogicComponent = new ShellLogicComponent(); var shellGraphicComponent = new CharGraphicComponent(shellData.DisplayChar, consoleWriter); var shell = new GameObject(shellInputComponent, shellPhysicComponent, shellLogicComponent, shellGraphicComponent); shell.Width = shellData.Width; shell.Height = shellData.Height; var fireCommand = new FireCommand(shell); var serializedGameObjectBuilders = new List <ISerializedGameObjectBuilder>() { new StoneBuilder(consoleWriter, stoneData), new PlayerBuilder(consoleWriter, geometryMathService, fireCommand, playerData), new EnemyBuilder(consoleWriter, gameObjectLocator, geometryMathService, fireCommand, enemyData), new WinPlatformBuilder(consoleWriter, gameObjectLocator, geometryMathService) }; var gameObjectBuilder = new GameObjectBuilder(serializedGameObjectBuilders, gameObjectLocator); var worldProvider = new WorldProvider(gameObjectBuilder, geometryMathService, consoleWriter); var world = worldProvider.GetWorld(1); return(world); }
public IGameObject BuildGameObject(GameObjectSerialized gameObjectSerialized) { if (gameObjectSerialized.GameObjectType != SerializedName) { throw new ArgumentException("Wrong serialized object"); } var winPlatformLogicComponent = new WinPlatformLogicComponent(_gameObjectLocator, _geometryMathService); var winPlatformGraphicComponent = new CharGraphicComponent('w', _consoleWriter); var winPlatform = new GameObject(null, null, winPlatformLogicComponent, winPlatformGraphicComponent); winPlatform.X = gameObjectSerialized.X; winPlatform.Y = gameObjectSerialized.Y; winPlatform.Width = gameObjectSerialized.Width; winPlatform.Height = gameObjectSerialized.Height; winPlatform.IsAbstract = true; return(winPlatform); }