Пример #1
0
        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);
        }