Added spawner grace period
This commit is contained in:
@@ -46,6 +46,9 @@ public class FortressGenerator{
|
|||||||
//tungsten duo and drone outpost
|
//tungsten duo and drone outpost
|
||||||
new Structure(0.02f, Items.tungsten, "BgEADXR1bmdzdGVuLXdhbGwEAA1jYXJiaWRlLWRyaWxsAwADZHVvAgATdHVuZ3N0ZW4td2FsbC1sYXJnZQAAA2FpcgUACWRyb25lLXBhZAUHAAAAAAEDAQMCAgAAAAAAAAAAAQADAAADAAMBAgAAAAABAAQBBQAAAAECAAAAAAEAAwAAAAAAAQIAAAAAAQABAQEBAQEBAg=="),
|
new Structure(0.02f, Items.tungsten, "BgEADXR1bmdzdGVuLXdhbGwEAA1jYXJiaWRlLWRyaWxsAwADZHVvAgATdHVuZ3N0ZW4td2FsbC1sYXJnZQAAA2FpcgUACWRyb25lLXBhZAUHAAAAAAEDAQMCAgAAAAAAAAAAAQADAAADAAMBAgAAAAABAAQBBQAAAAECAAAAAAEAAwAAAAAAAQIAAAAAAQABAQEBAQEBAg=="),
|
||||||
|
|
||||||
|
//resupply point
|
||||||
|
new Structure(0.03f, Items.lead, "BgEADXR1bmdzdGVuLXdhbGwCAAtzb2xhci1wYW5lbAUAA2R1bwMADnJlc3VwcGx5LXBvaW50AAADYWlyBAANY2FyYmlkZS1kcmlsbAUFAQABAAEAAAAAAAEAAgMBAQEBAQABAAMDBAEFAQEAAQACAwEBAQEBAAEBAQEBAQAAAAA="),
|
||||||
|
|
||||||
//lead storage
|
//lead storage
|
||||||
new Structure(0.02f, Items.lead, vaults),
|
new Structure(0.02f, Items.lead, vaults),
|
||||||
|
|
||||||
@@ -64,6 +67,9 @@ public class FortressGenerator{
|
|||||||
//2x interceptor outpost
|
//2x interceptor outpost
|
||||||
new Structure(0.02f, Items.lead, "CgMAEXNvbGFyLXBhbmVsLWxhcmdlBgADZHVvAgAPaW50ZXJjZXB0b3ItcGFkBAASY2FyYmlkZS13YWxsLWxhcmdlBwAOcmVzdXBwbHktcG9pbnQAAANhaXIFAAtzb2xhci1wYW5lbAEADGNhcmJpZGUtd2FsbAkAC2Rpc3RyaWJ1dG9yCAALbGFzZXItZHJpbGwKCAEAAQMBAwEDAQMBAwECAAABAAIDAAAAAAAAAAABAgAAAQAAAAAAAAADAQAAAQIBAgQDAAAFAAAAAAAAAAYCAQMAAAAABwAIAAAACQAAAAECBAMAAAEAAAAAAAABAAABAgAAAAAFAAAAAAAAAAYCAQIBAAIDAAAAAAMBAAABAgECAQAAAAAAAAAAAAAAAQIAAAEAAQEBAQEBAQEBAQEBAAA="),
|
new Structure(0.02f, Items.lead, "CgMAEXNvbGFyLXBhbmVsLWxhcmdlBgADZHVvAgAPaW50ZXJjZXB0b3ItcGFkBAASY2FyYmlkZS13YWxsLWxhcmdlBwAOcmVzdXBwbHktcG9pbnQAAANhaXIFAAtzb2xhci1wYW5lbAEADGNhcmJpZGUtd2FsbAkAC2Rpc3RyaWJ1dG9yCAALbGFzZXItZHJpbGwKCAEAAQMBAwEDAQMBAwECAAABAAIDAAAAAAAAAAABAgAAAQAAAAAAAAADAQAAAQIBAgQDAAAFAAAAAAAAAAYCAQMAAAAABwAIAAAACQAAAAECBAMAAAEAAAAAAAABAAABAgAAAAAFAAAAAAAAAAYCAQIBAAIDAAAAAAMBAAABAgECAQAAAAAAAAAAAAAAAQIAAAEAAQEBAQEBAQEBAQEBAAA="),
|
||||||
|
|
||||||
|
//resupply point (again)
|
||||||
|
new Structure(0.02f, Items.lead, "BgEADXR1bmdzdGVuLXdhbGwCAAtzb2xhci1wYW5lbAUAA2R1bwMADnJlc3VwcGx5LXBvaW50AAADYWlyBAANY2FyYmlkZS1kcmlsbAUFAQABAAEAAAAAAAEAAgMBAQEBAQABAAMDBAEFAQEAAQACAwEBAQEBAAEBAQEBAQAAAAA="),
|
||||||
|
|
||||||
//coal laser outpost
|
//coal laser outpost
|
||||||
new Structure(0.03f, null, "BgEADHRob3JpdW0td2FsbAMABmxhbmNlcgUAFGNvbWJ1c3Rpb24tZ2VuZXJhdG9yBAANY2FyYmlkZS1kcmlsbAAAA2FpcgIAC3NvbGFyLXBhbmVsBwcAAAEAAQABAQEBAQEBAAAAAQACAgMAAAACAAEAAAABAAICAAAAAAIAAQAAAAEAAQAEAQUAAQABAAAAAQACAAMBAAMCAAEAAAABAAIAAAMAAwIAAQAAAAEAAQABAwEDAQABAA=="),
|
new Structure(0.03f, null, "BgEADHRob3JpdW0td2FsbAMABmxhbmNlcgUAFGNvbWJ1c3Rpb24tZ2VuZXJhdG9yBAANY2FyYmlkZS1kcmlsbAAAA2FpcgIAC3NvbGFyLXBhbmVsBwcAAAEAAQABAQEBAQEBAAAAAQACAgMAAAACAAEAAAABAAICAAAAAAIAAQAAAAEAAQAEAQUAAQABAAAAAQACAAMBAAMCAAEAAAABAAIAAAMAAwIAAQAAAAEAAQABAwEDAQABAA=="),
|
||||||
|
|
||||||
@@ -123,7 +129,6 @@ public class FortressGenerator{
|
|||||||
void genOutposts(){
|
void genOutposts(){
|
||||||
int padding = 10;
|
int padding = 10;
|
||||||
int maxDifficulty = 13;
|
int maxDifficulty = 13;
|
||||||
float baseChance = 0.4f;
|
|
||||||
Array<Structure> selected = new Array<>();
|
Array<Structure> selected = new Array<>();
|
||||||
Array<Rectangle> used = new Array<>();
|
Array<Rectangle> used = new Array<>();
|
||||||
Rectangle rect = new Rectangle();
|
Rectangle rect = new Rectangle();
|
||||||
@@ -135,6 +140,8 @@ public class FortressGenerator{
|
|||||||
selected.add(structures[i]);
|
selected.add(structures[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float baseChance = 0.8f / selected.size;
|
||||||
|
|
||||||
used.add(new Rectangle(enemyX - base.width()/2, enemyY - base.height()/2, base.width(), base.height()));
|
used.add(new Rectangle(enemyX - base.width()/2, enemyY - base.height()/2, base.width(), base.height()));
|
||||||
int elev = gen.tiles[enemyX][enemyY].getElevation();
|
int elev = gen.tiles[enemyX][enemyY].getElevation();
|
||||||
for(int x = 0; x < base.width(); x++){
|
for(int x = 0; x < base.width(); x++){
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import java.io.DataOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class UnitPad extends Block{
|
public class UnitPad extends Block{
|
||||||
|
protected float gracePeriodMultiplier = 8f;
|
||||||
protected UnitType type;
|
protected UnitType type;
|
||||||
protected float produceTime = 1000f;
|
protected float produceTime = 1000f;
|
||||||
protected float openDuration = 50f;
|
protected float openDuration = 50f;
|
||||||
@@ -101,8 +102,8 @@ public class UnitPad extends Block{
|
|||||||
@Override
|
@Override
|
||||||
public TextureRegion[] getIcon(){
|
public TextureRegion[] getIcon(){
|
||||||
return new TextureRegion[]{
|
return new TextureRegion[]{
|
||||||
Draw.region(name),
|
Draw.region(name),
|
||||||
Draw.region(name + "-top")
|
Draw.region(name + "-top")
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,6 +160,10 @@ public class UnitPad extends Block{
|
|||||||
|
|
||||||
boolean isEnemy = tile.getTeam() == Team.red;
|
boolean isEnemy = tile.getTeam() == Team.red;
|
||||||
|
|
||||||
|
if(isEnemy){
|
||||||
|
entity.warmup += Timers.delta();
|
||||||
|
}
|
||||||
|
|
||||||
if(!isEnemy){
|
if(!isEnemy){
|
||||||
//player-made spawners have default behavior
|
//player-made spawners have default behavior
|
||||||
|
|
||||||
@@ -170,7 +175,8 @@ public class UnitPad extends Block{
|
|||||||
}else{
|
}else{
|
||||||
if(!entity.open) entity.speedScl = Mathf.lerpDelta(entity.speedScl, 0f, 0.05f);
|
if(!entity.open) entity.speedScl = Mathf.lerpDelta(entity.speedScl, 0f, 0.05f);
|
||||||
}
|
}
|
||||||
}else if(!entity.hasSpawned){
|
//check if grace period had passed
|
||||||
|
}else if(!entity.hasSpawned && entity.warmup > produceTime*gracePeriodMultiplier){
|
||||||
//otherwise, it's an enemy, cheat by not requiring resources
|
//otherwise, it's an enemy, cheat by not requiring resources
|
||||||
entity.buildTime += Timers.delta() / 4f;
|
entity.buildTime += Timers.delta() / 4f;
|
||||||
entity.speedScl = Mathf.lerpDelta(entity.speedScl, 1f, 0.05f);
|
entity.speedScl = Mathf.lerpDelta(entity.speedScl, 1f, 0.05f);
|
||||||
@@ -233,16 +239,19 @@ public class UnitPad extends Block{
|
|||||||
public float time;
|
public float time;
|
||||||
public float speedScl;
|
public float speedScl;
|
||||||
public boolean hasSpawned;
|
public boolean hasSpawned;
|
||||||
|
public float warmup; //only for enemy spawners
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(DataOutputStream stream) throws IOException{
|
public void write(DataOutputStream stream) throws IOException{
|
||||||
stream.writeFloat(buildTime);
|
stream.writeFloat(buildTime);
|
||||||
|
stream.writeFloat(warmup);
|
||||||
stream.writeBoolean(hasSpawned);
|
stream.writeBoolean(hasSpawned);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInputStream stream) throws IOException{
|
public void read(DataInputStream stream) throws IOException{
|
||||||
buildTime = stream.readFloat();
|
buildTime = stream.readFloat();
|
||||||
|
warmup = stream.readFloat();
|
||||||
hasSpawned = stream.readBoolean();
|
hasSpawned = stream.readBoolean();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user