Search in sources :

Example 1 with EnemySpawn

use of io.anuke.mindustry.game.EnemySpawn in project Mindustry by Anuken.

the class Logic method runWave.

public void runWave() {
    if (state.lastUpdated < state.wave + 1) {
        world.pathfinder().resetPaths();
        state.lastUpdated = state.wave + 1;
    }
    for (EnemySpawn spawn : spawns) {
        Array<SpawnPoint> spawns = world.getSpawns();
        for (int lane = 0; lane < spawns.size; lane++) {
            int fl = lane;
            Tile tile = spawns.get(lane).start;
            int spawnamount = spawn.evaluate(state.wave, lane);
            for (int i = 0; i < spawnamount; i++) {
                float range = 12f;
                Timers.runTask(i * 5f, () -> {
                    Enemy enemy = new Enemy(spawn.type);
                    enemy.set(tile.worldx() + Mathf.range(range), tile.worldy() + Mathf.range(range));
                    enemy.lane = fl;
                    enemy.tier = spawn.tier(state.wave, fl);
                    enemy.add();
                    Effects.effect(Fx.spawn, enemy);
                    state.enemies++;
                });
            }
        }
    }
    state.wave++;
    state.wavetime = wavespace * state.difficulty.timeScaling;
    state.extrawavetime = maxwavespace * state.difficulty.maxTimeScaling;
    Events.fire(WaveEvent.class);
}
Also used : EnemySpawn(io.anuke.mindustry.game.EnemySpawn) Enemy(io.anuke.mindustry.entities.enemies.Enemy) Tile(io.anuke.mindustry.world.Tile) SpawnPoint(io.anuke.mindustry.game.SpawnPoint) SpawnPoint(io.anuke.mindustry.game.SpawnPoint)

Aggregations

Enemy (io.anuke.mindustry.entities.enemies.Enemy)1 EnemySpawn (io.anuke.mindustry.game.EnemySpawn)1 SpawnPoint (io.anuke.mindustry.game.SpawnPoint)1 Tile (io.anuke.mindustry.world.Tile)1