Ejemplo n.º 1
0
        public Controllers(Data data, IEnemySpawnEvent enemySpawnHandler, IGameStartEvent gameStartEventHandler, IGameOverEvent gameOverEventHandler)
        {
            var pcInputHorizontal = new PCInputHorizontal();
            var pcInputVertical   = new PCInputVertical();
            var pcInputFire       = new PCInputFire();

            IPlayerFactory playerFactory = new PlayerFactory(data.Player);
            var            player        = playerFactory.CreatePlayer();

            var enemiesPlaceHolder = new GameObject("enemiesPlaceHolder").transform;
            var bulletsPlaceHolder = new GameObject("bulletsPlaceHolder").transform;

            bulletsPlaceHolder.parent = enemiesPlaceHolder;

            Object.Instantiate(data.Enviroment.spaceParticle, enemiesPlaceHolder.transform);

            var enemies       = new CompositeMove();
            var enemyFactory  = new EnemyFactory();
            var bulletFactory = new BulletFactory();

            var controllers = new List <IExecute>
            {
                new InputController(pcInputHorizontal, pcInputVertical, pcInputFire),
                new MoveController(pcInputHorizontal, pcInputVertical, enemiesPlaceHolder, data.Player),
                new EnemyMoveController(enemies, player),
                new ShootController(pcInputFire, bulletFactory, data.Bullets, bulletsPlaceHolder),
                new EnemySpawnController(enemies, enemyFactory, data.Enemy, enemiesPlaceHolder, enemySpawnHandler),
            };

            _executeControllers = controllers.ToArray();
        }
Ejemplo n.º 2
0
        public Controllers(Data data)
        {
            var pcInputHorizontal = new PCInputHorizontal();
            var pcInputVertical   = new PCInputVertical();
            var pcInputFire       = new PCFireInput();

            IPlayerFactory playerFactory = new PlayerFactory(data.Player);
            IPlayer        player        = playerFactory.CreatePlayer();

            IBulletFactory bulletFactory = new BulletFactory(data.Bullet);

            IEnemyFactory enemyFactory = new EnemyFactory();
            CompositeMove enemy        = new CompositeMove();

            int enemiesNum = 5;

            for (int i = 0; i < enemiesNum; ++i)
            {
                enemy.AddUnit(enemyFactory.CreateEnemy(data.Enemy, EnemyType.Small));
            }


            var enemiesList = enemy.GetEnemiesList();
            List <IDestructable> destructables = new List <IDestructable>();

            foreach (var _enemy in enemiesList)
            {
                destructables.Add((IDestructable)_enemy);
            }
            destructables.Add((IDestructable)player);


            IUIFactory uIFactory = new UIFactory();
            IUIInfo    uI        = uIFactory.CreateUI(data.UISettings);

            var executes = new List <IExecute>();

            executes.Add(new InputController(pcInputHorizontal, pcInputVertical, pcInputFire));
            executes.Add(new MoveController(pcInputHorizontal, pcInputVertical, player, data.Player));
            executes.Add(new EnemyMoveController(enemy, player.GetPosition()));
            executes.Add(new FireController(player, pcInputFire, data.Bullet, bulletFactory));
            executes.Add(new CollisionController(destructables));
            executes.Add(new UIController(uI, player, enemiesList));

            _executeControllers = executes.ToArray();
        }
Ejemplo n.º 3
0
        public Controllers(Data data)
        {
            var pcInputHorizontal = new PCInputHorizontal();
            var pcInputVertical   = new PCInputVertical();

            IPlayerFactory playerFactory = new PlayerFactory(data.Player);
            var            player        = playerFactory.CreatePlayer();

            IEnemyFactory enemyFactory = new EnemyFactory();
            CompositeMove enemy        = new CompositeMove();

            enemy.AddUnit(enemyFactory.CreateEnemy(data.Enemy, EnemyType.Small));

            var executes = new List <IExecute>();

            executes.Add(new InputController(pcInputHorizontal, pcInputVertical));
            executes.Add(new MoveController(pcInputHorizontal, pcInputVertical, player, data.Player));
            executes.Add(new EnemyMoveController(enemy, player));
            _executeControllers = executes.ToArray();
        }