コード例 #1
0
ファイル: EnemySpawnController.cs プロジェクト: atuzov/ATG
        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;
            }
        }
コード例 #2
0
ファイル: EnemySpawnController.cs プロジェクト: atuzov/ATG
        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);
        }