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(); }
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(); }
public GameInitialization(Controllers controllers, Data data) { Camera camera = Camera.main; var inputInitialization = new InputInitialization(); var playerFactory = new PlayerFactory(data.Player); var playerInitialization = new PlayerInitialization(playerFactory, data.Player.Position); var enemyFactory = new EnemyFactory(data.Enemy); var enemyInitialization = new EnemyInitialization(enemyFactory); controllers.Add(inputInitialization); controllers.Add(playerInitialization); controllers.Add(enemyInitialization); controllers.Add(new InputController(inputInitialization.GetInput())); controllers.Add(new MoveController(inputInitialization.GetInput(), playerInitialization.GetPlayer(), data.Player)); controllers.Add(new EnemyMoveController(enemyInitialization.GetMoveEnemies(), playerInitialization.GetPlayer())); controllers.Add(new CameraController(playerInitialization.GetPlayer(), camera.transform)); controllers.Add(new EndGameController(enemyInitialization.GetEnemies(), playerInitialization.GetPlayer().gameObject.GetInstanceID())); }
private void Start() { Camera camera = Camera.main; var inputInitialization = new InputInitialization(); var playerFactory = new PlayerFactory(_data.Player); var playerInitialization = new PlayerInitialization(playerFactory); var enemyFactory = new EnemyFactory(_data.Enemy); var enemyInitialization = new EnemyInitialization(enemyFactory); _controllers = new Controllers(); _controllers.Add(inputInitialization); _controllers.Add(playerInitialization); _controllers.Add(enemyInitialization); _controllers.Add(new InputController(inputInitialization.GetInput())); _controllers.Add(new MoveController(inputInitialization.GetInput(), playerInitialization.GetPlayer(), _data.Player)); _controllers.Add(new EnemyMoveController(enemyInitialization.GetEnemy(), playerInitialization.GetPlayer())); _controllers.Add(new CameraController(playerInitialization.GetPlayer(), camera.transform)); _controllers.Initialization(); }
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(); }