Пример #1
0
    IEnumerator SpawnWave(int wave)
    {
        player.GetHealing(data.healthRegenPerWave);
        BasicEnemy randomEnemy = null;

        while (randomEnemy == enemyToSpawn || randomEnemy == null)
        {
            randomEnemy = enemiesList[Random.Range(0, enemiesList.Count)];
        }
        enemyToSpawn = randomEnemy;
        int enemiesToSpawn = enemyToSpawn.CalculateEnemiesToSpawn(wave);

        for (int i = 0; i < enemiesToSpawn; i++)
        {
            float      horizontalMargin = 30 * data.scaling;
            float      spawnX           = Random.Range(-Screen.height / 2f * 9f / 20f + horizontalMargin, Screen.height / 2f * 9f / 20f - horizontalMargin);
            float      spawnY           = Screen.height * (0.5f + data.entityBorder);
            BasicEnemy spawnedEnemy     = Instantiate(enemyToSpawn, new Vector3(spawnX, spawnY, 0), Quaternion.Euler(0, 0, 0), enemiesParent);
            spawnedEnemy.health = spawnedEnemy.CalculateHealth(wave);
            spawnedEnemy.powerUpPercentChance = spawnedEnemy.health * data.powerUpPercentChancePerHealth;
            spawnedEnemy.speed          = spawnedEnemy.CalculateSpeed(wave);
            spawnedEnemy.damage         = spawnedEnemy.CalculateDamage(wave);
            spawnedEnemy.gameController = this;
            spawnedEnemy.data           = data;
            yield return(new WaitForSeconds(spawnedEnemy.CalculateSpawnTime(wave)));
        }
    }
Пример #2
0
    IEnumerator MeteoriteSpawning()
    {
        yield return(new WaitForSeconds(spawnTime * Random.Range(0f, spawnTime)));

        for (; ;)
        {
            if (!data.isPaused)
            {
                BasicEnemy enemyToSpawn = gameController.meteorite;
                BasicEnemy spawnedEnemy = Instantiate(enemyToSpawn, transform.position, Quaternion.Euler(0, 0, 0), gameController.enemiesParent);
                spawnedEnemy.health         = spawnedEnemy.CalculateHealth(gameController.wave);
                spawnedEnemy.speed          = spawnedEnemy.CalculateSpeed(gameController.wave) / 3;
                spawnedEnemy.damage         = spawnedEnemy.CalculateDamage(gameController.wave);
                spawnedEnemy.gameController = gameController;
                spawnedEnemy.data           = data;
                yield return(new WaitForSeconds(spawnTime));
            }
        }
    }