private MobSpawner <ZombieFactory> CreateMobSpawner(ILogger logger, UnityTimeProvider timeProvider, EntitiesSpawner entitiesSpawner, TypeTargetLocator tankMobTargetLocator, StateMachineFactory stateMachineFactory, DefaultRandom random) { var zombieFactories = new List <ZombieFactory>(); foreach (var zombiePrefab in Zombies) { var pool = new SimplePool <Zombie>(logger, 15, 10, p => { var zombie = Instantiate(zombiePrefab); return(zombie); }); var zombieFactory = new ZombieFactory(timeProvider, entitiesSpawner, tankMobTargetLocator, stateMachineFactory, _deps.Doors, pool); zombieFactories.Add(zombieFactory); } var zombieSpawnPoints = GetZombieSpawnPoints(_deps.ZombieSpawnPoints); var mobSpawner = new MobSpawner <ZombieFactory>(random, entitiesSpawner, new MobSpawnerSettings(AliveZombieCount, zombieSpawnPoints), zombieFactories); return(mobSpawner); }
public override void Init(List <SceneNode> sceneNodes) { var logger = CreateLogger(); _deps = GetDeps(sceneNodes); var random = new DefaultRandom(new Random()); var tankMobTargetLocator = new TypeTargetLocator(EntityType.Tank); var targetLocators = new List <ITargetLocator> { tankMobTargetLocator }; var entitiesSpawner = new EntitiesSpawner(targetLocators); var timeProvider = new UnityTimeProvider(); CreateTank(logger, timeProvider, entitiesSpawner); var stateMachineFactory = new StateMachineFactory(); var mobSpawner = CreateMobSpawner(logger, timeProvider, entitiesSpawner, tankMobTargetLocator, stateMachineFactory, random); mobSpawner.Start(); }