예제 #1
0
    private void Update()
    {
        if (_currentWave == null)
        {
            return;
        }

        _timeAfterLastSpawn += Time.deltaTime;

        if (_timeAfterLastSpawn >= _currentWave.Delay && _spawned < _currentWave.Count)
        {
            InstantiateEnemy(_currentWave.Template);
            _spawned++;
            _timeAfterLastSpawn = 0;
            EnemyCountChanged?.Invoke(_spawned, _currentWave.Count);
        }

        if (_currentWave.Count <= _spawned && _timeAfterLastSpawn >= _currentWave.Delay)
        {
            InstantiateEnemy(_currentWave.BossTemplate);
            _spawned++;
            EnemyCountChanged?.Invoke(_spawned, _currentWave.Count + 1);

            if (_waves.Count > _currentWaveNumber + 1)
            {
                AllEnemiesSpawned?.Invoke();
            }

            _currentWave = null;
        }
    }
예제 #2
0
        private void Update()
        {
            if (!_needToSpawn)
            {
                return;
            }
            if (_enemiesSpawnedTotalCount >= _maxEnemies)
            {
                return;
            }

            if (_timeSinceLastSpawn >= _spawnRate)
            {
                SpawnEnemy();

                _timeSinceLastSpawn        = 0f;
                _enemiesSpawnedTotalCount += 1;
                if (_enemiesSpawnedTotalCount == _maxEnemies)
                {
                    AllEnemiesSpawned?.Invoke();
                }
            }
            else
            {
                _timeSinceLastSpawn += Time.deltaTime;
            }
        }
예제 #3
0
    private void Update()
    {
        if (_currentWave == null)
        {
            return;
        }

        _lastSpawnTime += Time.deltaTime;

        if (_lastSpawnTime >= _currentWave.Delay)
        {
            InstantiateEnemy();
            _spawned++;
            _lastSpawnTime = 0;
            EnemyCountChanged?.Invoke(_spawned, _currentWave.Count);
        }

        if (_currentWave.Count <= _spawned)
        {
            if (_waves.Count > _currentWaveNumber + 1)
            {
                AllEnemiesSpawned?.Invoke();
            }

            _currentWave = null;
        }
    }
    IEnumerator EnemySpawner()
    {
        if (Enemys > 0 && !BattleEnded)
        {
            float      YPos = Random.Range(40, 180);
            GameObject GO   = Pool.SpawnFromPool("ESoldier", transform.position = new Vector3(1800, YPos, 1));
            //BaseKnightMovement obj = GO.GetComponent<BaseKnightMovement>();
            Enemys--;
            yield return(new WaitForSeconds(eSpawnRate));

            StartCoroutine(EnemySpawner());
        }
        else
        {
            AllEnemiesSpawned?.Invoke();
        }
    }