Map distortion / Multi-spawns
Before Width: | Height: | Size: 188 B After Width: | Height: | Size: 202 B |
Before Width: | Height: | Size: 189 B After Width: | Height: | Size: 201 B |
Before Width: | Height: | Size: 91 B After Width: | Height: | Size: 172 B |
Before Width: | Height: | Size: 96 B After Width: | Height: | Size: 170 B |
Before Width: | Height: | Size: 99 B After Width: | Height: | Size: 167 B |
Before Width: | Height: | Size: 486 B After Width: | Height: | Size: 487 B |
Before Width: | Height: | Size: 230 B After Width: | Height: | Size: 223 B |
Before Width: | Height: | Size: 268 B After Width: | Height: | Size: 259 B |
Before Width: | Height: | Size: 229 B After Width: | Height: | Size: 217 B |
Before Width: | Height: | Size: 257 B After Width: | Height: | Size: 250 B |
Before Width: | Height: | Size: 361 B After Width: | Height: | Size: 346 B |
Before Width: | Height: | Size: 397 B After Width: | Height: | Size: 383 B |
Before Width: | Height: | Size: 346 B After Width: | Height: | Size: 341 B |
Before Width: | Height: | Size: 395 B After Width: | Height: | Size: 384 B |
Before Width: | Height: | Size: 377 B After Width: | Height: | Size: 363 B |
Before Width: | Height: | Size: 370 B After Width: | Height: | Size: 343 B |
Before Width: | Height: | Size: 288 B After Width: | Height: | Size: 282 B |
Before Width: | Height: | Size: 375 B After Width: | Height: | Size: 372 B |
Before Width: | Height: | Size: 403 B After Width: | Height: | Size: 379 B |
Before Width: | Height: | Size: 410 B After Width: | Height: | Size: 400 B |
Before Width: | Height: | Size: 293 B After Width: | Height: | Size: 302 B |
Before Width: | Height: | Size: 367 B After Width: | Height: | Size: 362 B |
Before Width: | Height: | Size: 328 B After Width: | Height: | Size: 324 B |
Before Width: | Height: | Size: 336 B After Width: | Height: | Size: 325 B |
Before Width: | Height: | Size: 223 B After Width: | Height: | Size: 233 B |
Before Width: | Height: | Size: 301 B After Width: | Height: | Size: 295 B |
Before Width: | Height: | Size: 239 B After Width: | Height: | Size: 231 B |
Before Width: | Height: | Size: 277 B After Width: | Height: | Size: 268 B |
Before Width: | Height: | Size: 233 B After Width: | Height: | Size: 234 B |
Before Width: | Height: | Size: 266 B After Width: | Height: | Size: 259 B |
Before Width: | Height: | Size: 382 B After Width: | Height: | Size: 365 B |
Before Width: | Height: | Size: 425 B After Width: | Height: | Size: 397 B |
Before Width: | Height: | Size: 373 B After Width: | Height: | Size: 360 B |
Before Width: | Height: | Size: 418 B After Width: | Height: | Size: 403 B |
Before Width: | Height: | Size: 386 B After Width: | Height: | Size: 374 B |
Before Width: | Height: | Size: 380 B After Width: | Height: | Size: 355 B |
Before Width: | Height: | Size: 296 B After Width: | Height: | Size: 293 B |
Before Width: | Height: | Size: 394 B After Width: | Height: | Size: 379 B |
Before Width: | Height: | Size: 389 B After Width: | Height: | Size: 369 B |
Before Width: | Height: | Size: 402 B After Width: | Height: | Size: 385 B |
Before Width: | Height: | Size: 290 B After Width: | Height: | Size: 302 B |
Before Width: | Height: | Size: 373 B After Width: | Height: | Size: 357 B |
Before Width: | Height: | Size: 336 B After Width: | Height: | Size: 326 B |
Before Width: | Height: | Size: 344 B After Width: | Height: | Size: 332 B |
Before Width: | Height: | Size: 231 B After Width: | Height: | Size: 244 B |
Before Width: | Height: | Size: 313 B After Width: | Height: | Size: 306 B |
Before Width: | Height: | Size: 404 B After Width: | Height: | Size: 403 B |
Before Width: | Height: | Size: 183 B After Width: | Height: | Size: 181 B |
Before Width: | Height: | Size: 353 B After Width: | Height: | Size: 351 B |
Before Width: | Height: | Size: 327 B After Width: | Height: | Size: 324 B |
Before Width: | Height: | Size: 368 B After Width: | Height: | Size: 352 B |
Before Width: | Height: | Size: 958 B After Width: | Height: | Size: 974 B |
Before Width: | Height: | Size: 419 B After Width: | Height: | Size: 449 B |
Before Width: | Height: | Size: 444 B After Width: | Height: | Size: 466 B |
Before Width: | Height: | Size: 386 B After Width: | Height: | Size: 358 B |
Before Width: | Height: | Size: 670 B After Width: | Height: | Size: 663 B |
Before Width: | Height: | Size: 195 B After Width: | Height: | Size: 186 B |
Before Width: | Height: | Size: 463 KiB After Width: | Height: | Size: 462 KiB |
@ -14,7 +14,7 @@ public class Zones implements ContentList{
|
||||
@Override
|
||||
public void load(){
|
||||
|
||||
groundZero = new Zone("groundZero", new MapGenerator("groundZero")){{
|
||||
groundZero = new Zone("groundZero", new MapGenerator("groundZero", 1)){{
|
||||
deployCost = ItemStack.with(Items.copper, 100);
|
||||
startingItems = ItemStack.with(Items.copper, 50);
|
||||
alwaysUnlocked = true;
|
||||
|
@ -1,22 +1,36 @@
|
||||
package io.anuke.mindustry.maps.generators;
|
||||
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.geom.Point2;
|
||||
import io.anuke.arc.util.noise.Simplex;
|
||||
import io.anuke.mindustry.content.Blocks;
|
||||
import io.anuke.mindustry.io.MapIO;
|
||||
import io.anuke.mindustry.maps.Map;
|
||||
import io.anuke.mindustry.maps.MapTileData;
|
||||
import io.anuke.mindustry.maps.MapTileData.TileDataMarker;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.storage.CoreBlock;
|
||||
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class MapGenerator extends Generator{
|
||||
private Map map;
|
||||
private String mapName;
|
||||
|
||||
/**The amount of final enemy spawns used. -1 to use everything in the map.
|
||||
* This amount of enemy spawns is selected randomly from the map.*/
|
||||
public int enemySpawns = -1;
|
||||
|
||||
public MapGenerator(String mapName){
|
||||
this.mapName = mapName;
|
||||
}
|
||||
|
||||
public MapGenerator(String mapName, int enemySpawns){
|
||||
this.mapName = mapName;
|
||||
this.enemySpawns = enemySpawns;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
map = world.maps.loadInternalMap(mapName);
|
||||
@ -30,15 +44,61 @@ public class MapGenerator extends Generator{
|
||||
|
||||
data.position(0, 0);
|
||||
TileDataMarker marker = data.newDataMarker();
|
||||
Array<Point2> players = new Array<>();
|
||||
Array<Point2> enemies = new Array<>();
|
||||
|
||||
for(int y = 0; y < data.height(); y++){
|
||||
for(int x = 0; x < data.width(); x++){
|
||||
data.read(marker);
|
||||
|
||||
if(content.block(marker.wall) instanceof CoreBlock){
|
||||
players.add(new Point2(x, y));
|
||||
marker.wall = 0;
|
||||
}
|
||||
|
||||
if(enemySpawns != -1 && content.block(marker.wall) == Blocks.spawn){
|
||||
enemies.add(new Point2(x, y));
|
||||
marker.wall = 0;
|
||||
}
|
||||
|
||||
tiles[x][y] = new Tile(x, y, marker.floor, marker.wall == Blocks.blockpart.id ? 0 : marker.wall, marker.rotation, marker.team);
|
||||
}
|
||||
}
|
||||
|
||||
Simplex simplex = new Simplex(Mathf.random(99999));
|
||||
|
||||
for(int x = 0; x < data.width(); x++){
|
||||
for(int y = 0; y < data.height(); y++){
|
||||
final double scl = 10;
|
||||
final int mag = 3;
|
||||
int newX = Mathf.clamp((int)(simplex.octaveNoise2D(1, 1, 1.0 / scl, x, y) * mag + x), 0, data.width()-1);
|
||||
int newY = Mathf.clamp((int)(simplex.octaveNoise2D(1, 1, 1.0 / scl, x + 9999, y + 9999) * mag + y), 0, data.height()-1);
|
||||
if(tiles[newX][newY].block() != Blocks.spawn){
|
||||
tiles[x][y].setBlock(tiles[newX][newY].block());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(enemySpawns > enemies.size){
|
||||
throw new IllegalArgumentException("Enemy spawn pool greater than map spawn #.");
|
||||
}
|
||||
|
||||
if(enemySpawns != -1){
|
||||
enemies.shuffle();
|
||||
for(int i = 0; i < enemySpawns; i++){
|
||||
Point2 point = enemies.get(i);
|
||||
tiles[point.x][point.y].setBlock(Blocks.spawn);
|
||||
}
|
||||
}
|
||||
|
||||
Point2 core = players.random();
|
||||
if(core == null){
|
||||
throw new IllegalArgumentException("All zone maps must have a core.");
|
||||
}
|
||||
|
||||
//TODO set specific core block?
|
||||
tiles[core.x][core.y].setBlock(Blocks.core, defaultTeam);
|
||||
|
||||
world.prepareTiles(tiles);
|
||||
world.setMap(map);
|
||||
}
|
||||
|