Beispiel #1
0
    // Test SpawnWave Coroutine.
    void SpawnWave()
    {
        enemiesSpawned++;
        Debug.Log(name + ": Testing. Enemies Spawned = " + enemiesSpawned, this);
        Enemy enemy = Instantiate(enemyPrefab, transform);

        EnemySpawned?.Invoke(endPath);
    }
Beispiel #2
0
    private static Enemy SpawnEnemy()
    {
        var enemy = PoolObjects.Get <Enemy>();

        enemy.Transform.SetParent(_enemyContainer);
        enemy.Speed = _currentEnemySpeed;

        enemy.Transform.position = GetRandomPosition;
        EnemyInGame.Add(enemy);
        EnemySpawned?.Invoke(enemy);
        return(enemy);
    }
Beispiel #3
0
        private void Spawn()
        {
            if (_enemyCount >= MaxCount)
            {
                return;
            }

            var enemy = Instantiate(_enemyPrefab, PositionGenerator.GetRandomPosition(PositionSettings),
                                    GetRandomRotation());

            _enemyCount++;

            EnemySpawned?.Invoke(enemy);

            enemy.GetComponent <AircraftController>().Died += () => _enemyCount--;
        }
        private void SpawnEnemy()
        {
            var spawnPlace   = GetSpawnCoords();
            var enemySpawned = Instantiate(_enemyPrefabs[Random.Range(0, _enemyPrefabs.Count)], spawnPlace,
                                           Quaternion.identity);

            enemySpawned.transform.parent = _spawnParent;
            _enemiesSpawned.Add(enemySpawned);
            EnemySpawned?.Invoke(enemySpawned);
            var killableEvent = enemySpawned.GetComponent <KillableEvent>();

            if (killableEvent != null)
            {
                killableEvent.KillableDead += OnKillableDead;
            }
        }
    void GenerateEnemy(int health = 100)
    {
        int i = Random.Range(0, enemies.Length);

        var newEnemy    = Instantiate(enemies[i], gameObject.transform);
        var enemyScript = newEnemy.GetComponent <EnemyScript>();

        enemyScript.TargetPosition = spawnPosition;
        enemyScript.MoveTime       = TimeToEnter;
        enemyScript.RotationSpeed  = Random.Range(rotSpeedMin, rotSpeedMax);
        enemyScript.BobAmplitude   = bobAmplitude;
        enemyScript.BobSpeed       = bobSpeed;

        var material = newEnemy.GetComponentInChildren <MeshRenderer>().material;

        material.SetFloat("_Resolution", Random.Range(noiseResolutionMin, noiseResolutionMax));
        material.SetFloat("_Speed", Random.Range(noiseSpeedMin, noiseSpeedMax));

        CurrentEnemy = new Enemy(newEnemy, health);

        EnemySpawned.Invoke(newEnemy);
    }