Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        private void CreateTank(ILogger logger, UnityTimeProvider timeProvider, EntitiesSpawner entitiesSpawner)
        {
            var missilePool = new SimplePool <Missile>(logger,
                                                       5,
                                                       2,
                                                       p =>
            {
                var missile = Instantiate(MisslePrefab);
                missile.SetPoolOwner(p);
                return(missile);
            });
            var runtimeAbilityFactory = new ScriptableObjectRuntimeAbilityFactory(missilePool);

            var tankFactory = new TankFactory(timeProvider, entitiesSpawner, TankPrefab, _deps.AbilitiesContainer, _deps.PlayerHealth, runtimeAbilityFactory, ChangeAbilityCooldown, new InputManager());

            entitiesSpawner.Spawn <TankFactory, TankFactory, TankViewModel>(tankFactory, tankFactory, _deps.PlayerSpawnPoint.position, _deps.PlayerSpawnPoint.rotation);
        }
Esempio n. 3
0
        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();
        }