Better enemy spawn selection

This commit is contained in:
Anuken
2020-03-22 23:12:58 -04:00
parent 289cca3bf0
commit 2165a2af7d
3 changed files with 18 additions and 7 deletions

View File

@@ -125,7 +125,7 @@ public class TODOPlanetGenerator extends PlanetGenerator{
float constraint = 1.3f; float constraint = 1.3f;
float radius = width / 2f / Mathf.sqrt3; float radius = width / 2f / Mathf.sqrt3;
int rooms = rand.random(2, 5)/* - 1*/; int rooms = rand.random(2, 5) - 1;
Array<Room> array = new Array<>(); Array<Room> array = new Array<>();
for(int i = 0; i < rooms; i++){ for(int i = 0; i < rooms; i++){
@@ -139,6 +139,8 @@ public class TODOPlanetGenerator extends PlanetGenerator{
//check positions on the map to place the player spawn. this needs to be in the corner of the map //check positions on the map to place the player spawn. this needs to be in the corner of the map
Room spawn = null; Room spawn = null;
Array<Room> enemies = new Array<>();
int enemySpawns = rand.chance(0.3) ? 2 : 1;
int offset = rand.nextInt(360); int offset = rand.nextInt(360);
float length = width/2.55f - rand.random(13, 23); float length = width/2.55f - rand.random(13, 23);
int angleStep = 5; int angleStep = 5;
@@ -162,6 +164,15 @@ public class TODOPlanetGenerator extends PlanetGenerator{
if(waterTiles <= 4 || (i + angleStep >= 360)){ if(waterTiles <= 4 || (i + angleStep >= 360)){
array.add(spawn = new Room(cx, cy, rand.random(8, 15))); array.add(spawn = new Room(cx, cy, rand.random(8, 15)));
for(int j = 0; j < enemySpawns; j++){
float enemyOffset = rand.range(60f);
Tmp.v1.set(cx - width/2, cy - height/2).rotate(180f + enemyOffset).add(width/2, height/2);
Room espawn = new Room((int)Tmp.v1.x, (int)Tmp.v1.y, rand.random(8, 15));
array.add(espawn);
enemies.add(espawn);
}
break; break;
} }
} }
@@ -186,9 +197,9 @@ public class TODOPlanetGenerator extends PlanetGenerator{
ores(ores); ores(ores);
Room target = spawn; for(Room espawn : enemies){
Room furthest = array.max(r -> Mathf.dst(r.x, r.y, target.x, target.y)); tiles.getn(espawn.x, espawn.y).setOverlay(Blocks.spawn);
tiles.getn(furthest.x, furthest.y).setOverlay(Blocks.spawn); }
trimDark(); trimDark();

View File

@@ -1,3 +1,3 @@
org.gradle.daemon=true org.gradle.daemon=true
org.gradle.jvmargs=-Xms256m -Xmx1024m org.gradle.jvmargs=-Xms256m -Xmx1024m
archash=ff7229bd2071e3fabb9bdc0b18ef6ca90e3200f7 archash=c1e97cab1dd143cf49d3c694a6a2e150f742e291

View File

@@ -95,12 +95,12 @@ public class SectorDataGenerator{
} }
if(waterFloors / totalFloors >= 0.6f){ if(waterFloors / totalFloors >= 0.6f){
Log.info("Sector {0} has {1}/{2} water -> naval", sector.id, waterFloors, totalFloors); Log.debug("Sector {0} has {1}/{2} water -> naval", sector.id, waterFloors, totalFloors);
} }
//naval sector guaranteed //naval sector guaranteed
if(nearTiles > 4){ if(nearTiles > 4){
Log.info("Sector {0} has {1} water tiles at {2} {3} -> naval", sector.id, nearTiles, cx, cy); Log.debug("Sector {0} has {1} water tiles at {2} {3} -> naval", sector.id, nearTiles, cx, cy);
waterFloors = totalFloors; waterFloors = totalFloors;
} }