Exemple #1
0
    void Update()
    {
        if (GameManager.Instance.IsGameRunning)
        {
            _timer -= Time.deltaTime;
            if (_timer <= Mathf.Epsilon)
            {
                var spawnPoint = _spawnPoints[Random.Range(0, _spawnPoints.Length)];
                var location   = spawnPoint.GetSpawnPoint();

                var spawn = _spawnList.GetRandomSpawn();
                if (spawn == null)
                {
                    return;
                }

                counter++;
                if (counter % 10 == 0)
                {
                    _spawnTimer -= 0.2f;
                    _spawnTimer  = Mathf.Clamp(_spawnTimer, 0.5f, 2f);
                }
                _timer = _spawnTimer;

                Instantiate(spawn, location, spawnPoint.gameObject.transform.rotation);
            }
        }
    }
Exemple #2
0
    void Update()
    {
        if (LevelManager.Instance.IsGameRunning)
        {
            _timer -= (Time.deltaTime * LevelManager.Instance.GameSpeed);
            if (_timer < Mathf.Epsilon)
            {
                var spawn = _spawnlist.GetRandomSpawn();
                Instantiate(spawn, _spawnLocation.position, spawn.transform.rotation);
                _timer = _spawnInterval;
            }


            _energyTimer -= (Time.deltaTime * LevelManager.Instance.GameSpeed);
            if (_energyTimer < Mathf.Epsilon)
            {
                var spawn    = _pickupSpawnList.GetRandomSpawn();
                var location = _pickupSpawnLocation[Random.Range(0, _pickupSpawnLocation.Length)];
                Instantiate(spawn, location.position, spawn.transform.rotation);
                _energyTimer = _pickupSpawnInterval;
            }
        }
    }