Пример #1
0
    private void SetEnemyAIBySpawnPoint(Enemy enemy, SpawnDetail.SpawnPoint spawnPoint)
    {
        // Set the direction for the enemy respectively.
        enemy.MoveDirection = spawnPoint.enemyStartDirection;

        // If this new enemy is going to be a hit-run AI
        if (spawnPoint.aiType == AIType.HitRunAI)
        {
            // Setup the properties respectively.
            enemy.LingerDuration   = spawnPoint.lingerDuration;
            enemy.ShootAfterMoving = spawnPoint.shootAfterMoving;
            enemy.MoveDuration     = spawnPoint.moveDuration;
        }
    }
Пример #2
0
    private IEnumerator HandleSpawnPoint(SpawnDetail.SpawnPoint spawnPoint)
    {
        // Wait for delay before the first enemy spawn.
        yield return(new WaitForSeconds(spawnPoint.spawnDelay));

        // Foreach enemy to spawn
        for (int i = 0; i < spawnPoint.enemyCount; ++i)
        {
            SpawnEnemyOnSpawnPoint(spawnPoint);

            // Wait for the delay before spawning the next enemy
            yield return(new WaitForSeconds(spawnPoint.enemySpawnDelay));
        }

        yield return(null);
    }
Пример #3
0
    private void SpawnEnemyOnSpawnPoint(SpawnDetail.SpawnPoint spawnPoint)
    {
        GameObject newEnemyObj = FetchOrCreateEnemyObject(spawnPoint.enemyPrefab.GetComponent <Enemy>().TypeOfEnemy, spawnPoint.enemyPrefab);
        Enemy      newEnemy    = newEnemyObj.GetComponent <Enemy>();

        // Move this new enemy to it's spawnpoint
        newEnemyObj.transform.position = spawnPoint.position;

        // Copy the details of the prefab into the new enemy.
        newEnemy.CopyDetails(spawnPoint.enemyPrefab.GetComponent <Enemy>());

        SetEnemyAIBySpawnPoint(newEnemy, spawnPoint);

        // Initalize this enemy
        newEnemy.InitEnemy(spawnPoint.aiType);

        newEnemy.Invulnerable = true;
    }