Exemple #1
0
    private IEnumerator corSpawnEnemy()
    {
        while (true)
        {
            yield return(new WaitForSeconds(_timerToSpawn));

            if (_timerToSpawn < 1.5f)
            {
                _deltaTime = 0f;
            }
            else if (_timerToSpawn < 2f)
            {
                _deltaTime = .05f;
            }
            else if (_timerToSpawn < 2.5f)
            {
                _deltaTime = .075f;
            }
            _timerToSpawn -= _deltaTime;
            Vector3 randomPosition = UtilityCustom.GetRandomPosition();
            Vector3 destination    = UtilityCustom.GetDestination();
            if (!_isGameOver)
            {
                if (Main.EnemyMain.enemiesPool.Count != 0)
                {
                    GetEnemyFromPool(randomPosition, destination);
                }
                else
                {
                    SpawnNewEnemy(randomPosition, destination);
                }
            }
        }
    }
Exemple #2
0
 private void AddToPool(BulletContent bullet)
 {
     bullet.rb.velocity = Vector3.zero;
     bullet.gameObject.transform.position = UtilityCustom.GetRandomPosition();
     Main.BulletMain.bulletsPool.Enqueue(bullet);
     bullet.gameObject.SetActive(false);
 }
Exemple #3
0
 private void AddToPool(EnemyContent enemy)
 {
     enemy.gameObject.transform.position = UtilityCustom.GetRandomPosition();
     enemy.destination = UtilityCustom.GetDestination();
     Main.EnemyMain.enemiesPool.Enqueue(enemy);
     enemy.gameObject.SetActive(false);
 }