Search in sources :

Example 6 with SpawnPoint

use of io.anuke.mindustry.game.SpawnPoint 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)

Example 7 with SpawnPoint

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

the class WorldGenerator method generate.

/**
 *Returns the core (starting) block. Should fill spawns with the correct spawnpoints.
 */
public static Tile generate(Pixmap pixmap, Tile[][] tiles, Array<SpawnPoint> spawns) {
    Noise.setSeed(world.getSeed());
    Tile core = null;
    for (int x = 0; x < pixmap.getWidth(); x++) {
        for (int y = 0; y < pixmap.getHeight(); y++) {
            Block floor = Blocks.stone;
            Block block = Blocks.air;
            int color = pixmap.getPixel(x, pixmap.getHeight() - 1 - y);
            BlockPair pair = ColorMapper.get(color);
            if (pair != null) {
                block = pair.wall;
                floor = pair.floor;
            }
            if (block == SpecialBlocks.playerSpawn) {
                block = Blocks.air;
                core = world.tile(x, y);
            } else if (block == SpecialBlocks.enemySpawn) {
                block = Blocks.air;
                spawns.add(new SpawnPoint(tiles[x][y]));
            }
            if (block == Blocks.air && Mathf.chance(0.025) && rocks.containsKey(floor)) {
                block = rocks.get(floor);
            }
            if (world.getMap().oreGen && (floor == Blocks.stone || floor == Blocks.grass || floor == Blocks.blackstone || floor == Blocks.snow || floor == Blocks.sand)) {
                if (Noise.nnoise(x, y, 8, 1) > 0.21) {
                    floor = Blocks.iron;
                }
                if (Noise.nnoise(x, y, 6, 1) > 0.237) {
                    floor = Blocks.coal;
                }
                if (Noise.nnoise(x + 9999, y + 9999, 8, 1) > 0.27) {
                    floor = Blocks.titanium;
                }
                if (Noise.nnoise(x + 99999, y + 99999, 7, 1) > 0.259) {
                    floor = Blocks.uranium;
                }
            }
            if (color == Hue.rgb(Color.PURPLE)) {
                if (!Vars.android)
                    new Enemy(EnemyTypes.target).set(x * tilesize, y * tilesize).add();
                floor = Blocks.stone;
            }
            tiles[x][y].setBlock(block, 0);
            tiles[x][y].setFloor(floor);
        }
    }
    for (int x = 0; x < pixmap.getWidth(); x++) {
        for (int y = 0; y < pixmap.getHeight(); y++) {
            tiles[x][y].updateOcclusion();
        }
    }
    return core;
}
Also used : BlockPair(io.anuke.mindustry.world.ColorMapper.BlockPair) Enemy(io.anuke.mindustry.entities.enemies.Enemy) SpawnPoint(io.anuke.mindustry.game.SpawnPoint) SpawnPoint(io.anuke.mindustry.game.SpawnPoint)

Aggregations

SpawnPoint (io.anuke.mindustry.game.SpawnPoint)7 Enemy (io.anuke.mindustry.entities.enemies.Enemy)3 Tile (io.anuke.mindustry.world.Tile)3 Vector2 (com.badlogic.gdx.math.Vector2)2 Player (io.anuke.mindustry.entities.Player)2 Rectangle (com.badlogic.gdx.math.Rectangle)1 EnemySpawn (io.anuke.mindustry.game.EnemySpawn)1 InputHandler (io.anuke.mindustry.input.InputHandler)1 Recipe (io.anuke.mindustry.resource.Recipe)1 ToolFragment (io.anuke.mindustry.ui.fragments.ToolFragment)1 BlockBar (io.anuke.mindustry.world.BlockBar)1 BlockPair (io.anuke.mindustry.world.ColorMapper.BlockPair)1 SolidEntity (io.anuke.ucore.entities.SolidEntity)1