mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-30 22:49:06 +07:00
Fixed terrible spawn generation
This commit is contained in:
@ -24,12 +24,12 @@ public class Mechs implements ContentList{
|
||||
speed = 0.5f;
|
||||
weapon = Weapons.blaster;
|
||||
trailColor = Palette.lightTrail;
|
||||
maxSpeed = 3f;
|
||||
maxSpeed = 4f;
|
||||
}};
|
||||
|
||||
delta = new Mech("delta-mech", false){{
|
||||
drillPower = -1;
|
||||
speed = 0.63f;
|
||||
speed = 0.75f;
|
||||
boostSpeed = 0.86f;
|
||||
itemCapacity = 15;
|
||||
armor = 30f;
|
||||
@ -38,13 +38,13 @@ public class Mechs implements ContentList{
|
||||
weapon = Weapons.shockgun;
|
||||
ammoCapacity = 50;
|
||||
trailColor = Color.valueOf("d3ddff");
|
||||
maxSpeed = 3f;
|
||||
maxSpeed = 5f;
|
||||
}};
|
||||
|
||||
tau = new Mech("tau-mech", false){{
|
||||
drillPower = 2;
|
||||
speed = 0.5f;
|
||||
maxSpeed = 3f;
|
||||
maxSpeed = 5f;
|
||||
}};
|
||||
|
||||
omega = new Mech("omega-mech", false){{
|
||||
|
@ -46,7 +46,7 @@ public class Weapons implements ContentList{
|
||||
reload = 50f;
|
||||
roundrobin = true;
|
||||
shots = 6;
|
||||
inaccuracy = 15f;
|
||||
inaccuracy = 10f;
|
||||
recoil = 2f;
|
||||
velocityRnd = 0.7f;
|
||||
ejectEffect = ShootFx.shellEjectSmall;
|
||||
|
@ -25,8 +25,8 @@ public class WeaponBullets extends BulletList{
|
||||
{
|
||||
bulletWidth = 8f;
|
||||
bulletHeight = 9f;
|
||||
bulletShrink = 0.6f;
|
||||
lifetime = 30f;
|
||||
bulletShrink = 0.5f;
|
||||
lifetime = 50f;
|
||||
drag = 0.04f;
|
||||
}
|
||||
};
|
||||
|
@ -18,7 +18,7 @@ import io.anuke.mindustry.world.blocks.defense.turrets.Turret;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
public class FortressGenerator{
|
||||
private final static int minCoreDst = 50;
|
||||
private final static int minCoreDst = 60;
|
||||
private static Structure[] structures;
|
||||
|
||||
private int enemyX, enemyY, coreX, coreY;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package io.anuke.mindustry.maps.generation;
|
||||
|
||||
import com.badlogic.gdx.math.GridPoint2;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.IntArray;
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
@ -183,10 +184,12 @@ public class WorldGenerator{
|
||||
public void generateMap(Tile[][] tiles, Sector sector){
|
||||
int width = tiles.length, height = tiles[0].length;
|
||||
SeedRandom rnd = new SeedRandom(sector.getSeed());
|
||||
Generation gena = new Generation(sector, tiles, tiles.length, tiles[0].length, rnd);
|
||||
Array<GridPoint2> spawnpoints = sector.currentMission().getSpawnPoints(gena);
|
||||
|
||||
for(int x = 0; x < width; x++){
|
||||
for(int y = 0; y < height; y++){
|
||||
GenResult result = generateTile(sector.x, sector.y, x, y);
|
||||
GenResult result = generateTile(this.result, sector.x, sector.y, x, y, true, spawnpoints);
|
||||
Tile tile = new Tile(x, y, (byte)result.floor.id, (byte)result.wall.id, (byte)0, (byte)0, result.elevation);
|
||||
tiles[x][y] = tile;
|
||||
}
|
||||
@ -227,10 +230,10 @@ public class WorldGenerator{
|
||||
}
|
||||
|
||||
public GenResult generateTile(int sectorX, int sectorY, int localX, int localY, boolean detailed){
|
||||
return generateTile(result, sectorX, sectorY, localX, localY, detailed);
|
||||
return generateTile(result, sectorX, sectorY, localX, localY, detailed, null);
|
||||
}
|
||||
|
||||
public GenResult generateTile(GenResult result, int sectorX, int sectorY, int localX, int localY, boolean detailed){
|
||||
public GenResult generateTile(GenResult result, int sectorX, int sectorY, int localX, int localY, boolean detailed, Array<GridPoint2> spawnpoints){
|
||||
int x = sectorX * sectorSize + localX + Short.MAX_VALUE;
|
||||
int y = sectorY * sectorSize + localY + Short.MAX_VALUE;
|
||||
|
||||
@ -239,9 +242,23 @@ public class WorldGenerator{
|
||||
|
||||
double ridge = rid.getValue(x, y, 1f / 400f);
|
||||
double iceridge = rid.getValue(x+99999, y, 1f / 300f) + sim3.octaveNoise2D(2, 1f, 1f/14f, x, y)/11f;
|
||||
double elevation = sim.octaveNoise2D(detailed ? 7 : 2, 0.62, 1f / 640, x, y) * 6.1 - 1 - ridge;
|
||||
double elevation = elevationOf(x, y, detailed);
|
||||
double temp = vn.noise(x, y, 1f / 300f) * sim3.octaveNoise2D(detailed ? 2 : 1, 1, 1f / 13f, x, y)/13f
|
||||
+ sim3.octaveNoise2D(detailed ? 12 : 6, 0.6, 1f / 920f, x, y);
|
||||
+ sim3.octaveNoise2D(detailed ? 12 : 6, 0.6, 1f / 920f, x, y);
|
||||
|
||||
int lerpDst = 20;
|
||||
lerpDst *= lerpDst;
|
||||
|
||||
if(detailed && spawnpoints != null){
|
||||
for(GridPoint2 p : spawnpoints){
|
||||
float dst = Vector2.dst2(p.x, p.y, localX, localY);
|
||||
|
||||
if(dst < lerpDst){
|
||||
float targetElevation = Math.max(0.86f, (float)elevationOf(sectorX * sectorSize + p.x + Short.MAX_VALUE, sectorY * sectorSize + p.y + Short.MAX_VALUE, true));
|
||||
elevation = Mathf.lerp((float)elevation, targetElevation, Mathf.clamp(1.5f*(1f-(dst / lerpDst))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(elevation < 0.7){
|
||||
floor = Blocks.deepwater;
|
||||
@ -290,6 +307,11 @@ public class WorldGenerator{
|
||||
return result;
|
||||
}
|
||||
|
||||
double elevationOf(int x, int y, boolean detailed){
|
||||
double ridge = rid.getValue(x, y, 1f / 400f);
|
||||
return sim.octaveNoise2D(detailed ? 7 : 2, 0.62, 1f / 640, x, y) * 6.1 - 1 - ridge;
|
||||
}
|
||||
|
||||
public static class GenResult{
|
||||
public Block floor, wall;
|
||||
public byte elevation;
|
||||
|
@ -1,5 +1,7 @@
|
||||
package io.anuke.mindustry.maps.missions;
|
||||
|
||||
import com.badlogic.gdx.math.GridPoint2;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.game.GameMode;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
@ -41,4 +43,9 @@ public class BattleMission implements Mission{
|
||||
//TODO check all enemy teams, not just the first
|
||||
return Vars.state.teams.getTeams(false).first().cores.size == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Array<GridPoint2> getSpawnPoints(Generation gen){
|
||||
return Array.with(new GridPoint2(coreX, coreY), new GridPoint2(gen.width - 1 - coreX, gen.height - 1 - coreY));
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,12 @@
|
||||
package io.anuke.mindustry.maps.missions;
|
||||
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import io.anuke.mindustry.content.blocks.Blocks;
|
||||
import com.badlogic.gdx.math.GridPoint2;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.content.blocks.StorageBlocks;
|
||||
import io.anuke.mindustry.game.GameMode;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.maps.generation.Generation;
|
||||
import io.anuke.mindustry.world.blocks.Floor;
|
||||
import io.anuke.ucore.noise.Noise;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
public interface Mission{
|
||||
boolean isComplete();
|
||||
@ -17,34 +14,13 @@ public interface Mission{
|
||||
GameMode getMode();
|
||||
void display(Table table);
|
||||
|
||||
default Array<GridPoint2> getSpawnPoints(Generation gen){
|
||||
return Array.with();
|
||||
}
|
||||
|
||||
default void generate(Generation gen){}
|
||||
|
||||
default void generateCoreAt(Generation gen, int coreX, int coreY, Team team){
|
||||
Noise.setSeed(0);
|
||||
float targetElevation = Math.max(gen.tiles[coreX][coreY].getElevation(), 1);
|
||||
|
||||
int lerpDst = 20;
|
||||
for(int x = -lerpDst; x <= lerpDst; x++){
|
||||
for(int y = -lerpDst; y <= lerpDst; y++){
|
||||
int wx = gen.width / 2 + x, wy = gen.height / 2 + y;
|
||||
|
||||
float dst = Vector2.dst(wx, wy, coreX, coreY);
|
||||
float elevation = gen.tiles[wx][wy].getElevation();
|
||||
|
||||
if(dst < 4){
|
||||
elevation = targetElevation;
|
||||
}else if(dst < lerpDst){
|
||||
elevation = Mathf.lerp(elevation, targetElevation, Mathf.clamp(2*(1f-(dst / lerpDst))) + Noise.nnoise(wx, wy, 8f, 1f));
|
||||
}
|
||||
|
||||
if(gen.tiles[wx][wy].floor().liquidDrop == null){
|
||||
gen.tiles[wx][wy].setElevation((int) elevation);
|
||||
}else{
|
||||
gen.tiles[wx][wy].setFloor((Floor) Blocks.sand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gen.tiles[coreX][coreY].setBlock(StorageBlocks.core);
|
||||
gen.tiles[coreX][coreY].setTeam(team);
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package io.anuke.mindustry.maps.missions;
|
||||
|
||||
import com.badlogic.gdx.math.GridPoint2;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.game.GameMode;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.maps.generation.Generation;
|
||||
@ -40,4 +42,9 @@ public class WaveMission implements Mission{
|
||||
public boolean isComplete(){
|
||||
return state.wave >= target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Array<GridPoint2> getSpawnPoints(Generation gen){
|
||||
return Array.with(new GridPoint2(gen.width/2, gen.height/2));
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ public class GenViewDialog extends FloatingDialog{
|
||||
Pixmap pixmap = new Pixmap(sectorSize, sectorSize, Format.RGBA8888);
|
||||
for(int i = 0; i < sectorSize; i++){
|
||||
for(int j = 0; j < sectorSize; j++){
|
||||
world.generator().generateTile(result, wx, wy, i, j, true);
|
||||
world.generator().generateTile(result, wx, wy, i, j, true, null);
|
||||
pixmap.drawPixel(i, sectorSize - 1 - j, ColorMapper.colorFor(result.floor, result.wall, Team.none, result.elevation));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user