Пример #1
0
    // Start is called before the first frame update
    void Start()
    {
        // To update enemy path.
        waypointsList = waveConfig.GetWayPointLists();

        // Set the starting position of the enemy ship to the 1st waypoint
        transform.position = waypointsList[waypointIndex].transform.position;
    }
    // waveToSpawn is a variable name to identify that specigic WavConfig
    private IEnumerator SpawnAllEnemiesInWave(WavConvig waveToSpawn)
    {
        for (int enemyCount = 1; enemyCount <= waveToSpawn.GetNumberOfEnemies(); enemyCount++)
        {
            var newEnemy = Instantiate(
                waveToSpawn.GetEnemyPrefab(),
                waveToSpawn.GetWayPointLists()[0].transform.position,
                Quaternion.identity) as GameObject;
            // setting the wave as a component to the enemy
            newEnemy.GetComponent <EnemyPathing>().SetWaveConfig(waveToSpawn);

            yield return(new WaitForSeconds(waveToSpawn.GetTimeBetweenSpawns()));
        }
        //spawn the enemy prefeb from waveToSpawn
        //at the position of 1st waypoint in Path.
    }