Beispiel #1
0
    private void Spawn()
    {
        //Instantiate dequeued item, in random spawnpoint
        SpawnPoints nextSpawnPoint = spawnPoints[UnityEngine.Random.Range(0, spawnPoints.Length)];

        Enemy enemy = Instantiate(enemiesController.enemiesToSpawnQueue.First(true), nextSpawnPoint.transform.position, Quaternion.identity);

        OnEnemySpawn?.Invoke(enemy);

        nextSpawnPoint.ActivatePortal();
    }
Beispiel #2
0
    private IEnumerator RepeatinglySpawnEnemy()
    {
        while (isSpawning)
        {
            yield return(new WaitForSeconds(secondsBetweenSpawns));

            var newEnemy = Instantiate(enemyPrefab, gameObject.transform);
            newEnemy.transform.SetParent(enemyParent);
            newEnemy.particlesParent = particlesParent;
            numEnemies++;
            onEnemySpawn.Invoke(numEnemies);
            GetComponent <AudioSource>().PlayOneShot(spawnSFX);
        }
    }
Beispiel #3
0
    private void Spawn(Vector3 spawnPosition, GameObject nextNode)
    {
        Enemy enemy = _enemyPool.GetObjectFromPool();

        if (enemy == null)
        {
            return;
        }


        enemy.transform.position = new Vector3(RandomizeCoordinate(spawnPosition.x), spawnPosition.y, RandomizeCoordinate(spawnPosition.z));
        var meshRenderers = enemy.GetComponentsInChildren <MeshRenderer>();

        foreach (var renderer in meshRenderers)
        {
            renderer.enabled = true;
        }

        //enemy.setMoveNode(nextNode);

        OnEnemySpawn.Invoke(enemy, nextNode);
    }
Beispiel #4
0
 private void Start()
 {
     OnEnemySpawn?.Invoke();
 }
Beispiel #5
0
 public void SpawnEnemy(GameObject prefab, Vector2 position, float rotation, Vector2 velocity)
 {
     OnEnemySpawn?.Invoke(Spawn(prefab, position, rotation, velocity));
 }
Beispiel #6
0
 public void TriggerEnemySpawnEvent(GameObject enemy)
 {
     OnEnemySpawn?.Invoke(enemy);
 }