private Spawner <Ship> CreatePlayerShipSpawner() { var shipSpawnerGameObject = Game.Create <GameObject>(); var shipSpawnerTransform = shipSpawnerGameObject.AddComponent <Transform>(); shipSpawnerTransform.Position = new Vector2(0, 0); shipSpawnerTransform.Scale = new Vector2(3, 3); shipSpawnerTransform.Direction = new Vector2(0, 1); var shipSpawnerComponent = shipSpawnerGameObject.AddComponent <Spawner <Ship> >(); var shipFactory = new PlayerShipFactory(); var playerBulletFactory = new PlayerBulletFactory(); var playerLaserAmmoFactory = new PlayerLaserAmmoFactory(); playerBulletFactory.Spawned.AddListener((x) => unityPlayerBulletsFactory.OnSpawn(game, x)); shipFactory.BulletFactory = playerBulletFactory; playerLaserAmmoFactory.Spawned.AddListener((x) => unityPlayerLaserAmmoFactory.OnSpawn(game, x)); shipFactory.LaserAmmoFactory = playerLaserAmmoFactory; shipFactory.Spawned.AddListener((x) => unityPlayerShipFactory.OnSpawn(game, x)); shipSpawnerComponent.Factory = shipFactory; return(shipSpawnerComponent); }
private Scene(GameSettings gameSettings) { _gameSettings = gameSettings; Swarm = new AlienShipFactory(_gameSettings).GetSwarm(); Ground = new GroundFactory(_gameSettings).GetGround(); PlayerShip = new PlayerShipFactory(_gameSettings).GetPlayer(); PlayerShipMissile = new List <GameObject>(); AlienShipMissile = new List <GameObject>(); }