public SpaceshipInitialization(ISpaceshipFactory spaceshipFactory, HealthKeeper health) { _spaceshipFactory = spaceshipFactory; _spaceship = _spaceshipFactory.CreateSpaceship(); _spaceship.AddComponent <TrackingSpaceshipContacts>(); _health = health; _contacts = _spaceship.GetComponent <TrackingSpaceshipContacts>(); _contacts.SpaceshipCollisionHappend += _health.DetermineContact; }
public IPlayer CreatePlayer(IRegistration playerParameters) { string name, spaceshipModel, engineModel, armourModel, weaponModel; name = playerParameters.ParametersForPlayer["name"]; spaceshipModel = playerParameters.ParametersForPlayer["ship"]; engineModel = playerParameters.ParametersForPlayer["engine"]; armourModel = playerParameters.ParametersForPlayer["armour"]; weaponModel = playerParameters.ParametersForPlayer["weapon"]; ISpaceshipEngine engine = engineFactory.CreateEngine(engineModel); IArmour armour = armourFactory.CreateArmour(armourModel); IWeapon weapon = weaponFactory.CreateWeapon(weaponModel.ToLower()); weapon.Bullet = bulletFactory.CreateBullet(); ISpaceShip spaceship = spaceshipFactory.CreateSpaceship(spaceshipModel, engine, armour, weapon); IPlayer player = playerFactory.CreatePlayer(name, spaceship); return(player); }