/// <summary> /// We want to use AWAKE so our modules initialize before everything else. /// </summary> void Awake() { //Create a new default module factory and pass in the active scene as a reference, so this particular module can be scoped to the scene DefaultModuleFactory _factory = new DefaultModuleFactory(gameObject.scene); //declare our spawner module for spawning objects in the scene, and set spawn immediately = true _spawnerModule = new ConsistentSpawnModule(_spawnPrefab, true); //declare our mover module for moving objects around _moverModule = new MoverModule(_spawnerModule); //add our modules to the factory so they can be accessed outside this scope. _factory.AddModule(_spawnerModule); _factory.AddModule(_moverModule); SetupViewCallbacks(); }
/// <summary> /// We put the Ispawner module in the constructor, because the mover module depends on it /// </summary> /// <param name="spawnerModule">An implementation of the spawner module</param> public MoverModule(ISpawnerModule spawnerModule) { _spawnerModule = spawnerModule; }