Exemplo n.º 1
0
        private void CreateUnitSpawners()
        {
            _spawners = new UnitSpawner[_spawnPoints.Count];
            int numberOfUnitsPerSpawner = _unitsCount / _spawnPoints.Count;

            //TODO добавить проверку на остаток от деления
            for (int i = 0; i < _spawnPoints.Count; i++)
            {
                var spawner = new UnitSpawner(numberOfUnitsPerSpawner, _spawnPoints[i], _enemyPool);
                _spawners[i] = spawner;
            }
        }
Exemplo n.º 2
0
        public void SpawnOneUnit()
        {
            UnitSpawner spawner          = _spawners[0];
            int         maxUnitInSpawner = _spawners[0].UnitsCount;

            for (int i = 0; i < _spawners.Length; i++)
            {
                if (maxUnitInSpawner < _spawners[i].UnitsCount)
                {
                    spawner = _spawners[i];
                }
            }

            var enemy = spawner.SpawnUnit();

            if (enemy == null)
            {
                return;
            }
            _spawnedUnitsCount++;
            enemy.MapData = _mapData;
            _enemyInGame.Add(enemy);
        }