Fixed sector world gen / Added sector goal unlocks

This commit is contained in:
Anuken 2018-07-17 19:12:44 -04:00
parent 6f6601d270
commit ac039ce7cd
10 changed files with 74 additions and 68 deletions

View File

@ -51,9 +51,11 @@ text.customgame=Custom Game
text.campaign=Campaign
text.sectors=Sectors
text.sector=Selected Sector: [LIGHT_GRAY]{0}
text.sector.time=Time: [LIGHT_GRAY]{0}
text.sector.deploy=Deploy
text.sector.resume=Resume
text.sector.locked=[scarlet][[LOCKED]
text.sector.unlocked=Sector completed!
text.sector.locked=[scarlet][[Incomplete]
text.sector.unexplored=[accent][[Unexplored]
text.quit=Quit
text.maps=Maps

View File

@ -368,6 +368,15 @@ public class Control extends Module{
input.update();
}
//check unlocked sectors
if(world.getSector() != null && world.getSector().goal.isComplete() && !world.getSector().complete){
world.sectors().completeSector(world.getSector().x, world.getSector().y);
world.sectors().save();
if(!headless){
ui.showInfoFade("$text.sector.unlocked");
}
}
//check unlocks every 2 seconds
if(!state.mode.infiniteResources && Timers.get("timerCheckUnlock", 120)){
checkUnlockableBlocks();

View File

@ -41,59 +41,33 @@ public class NetClient extends Module{
private final static float playerSyncTime = 2;
private Timer timer = new Timer(5);
/**
* Whether the client is currently connecting.
*/
/**Whether the client is currently connecting.*/
private boolean connecting = false;
/**
* If true, no message will be shown on disconnect.
*/
/**If true, no message will be shown on disconnect.*/
private boolean quiet = false;
/**
* Counter for data timeout.
*/
/**Counter for data timeout.*/
private float timeoutTime = 0f;
/**
* Last sent client snapshot ID.
*/
/**Last sent client snapshot ID.*/
private int lastSent;
/**
* Last snapshot ID recieved.
*/
/**Last snapshot ID recieved.*/
private int lastSnapshotBaseID = -1;
/**
* Last snapshot recieved.
*/
/**Last snapshot recieved.*/
private byte[] lastSnapshotBase;
/**
* Current snapshot that is being built from chinks.
*/
/**Current snapshot that is being built from chinks.*/
private byte[] currentSnapshot;
/**
* Array of recieved chunk statuses.
*/
/**Array of recieved chunk statuses.*/
private boolean[] recievedChunks;
/**
* Counter of how many chunks have been recieved.
*/
/**Counter of how many chunks have been recieved.*/
private int recievedChunkCounter;
/**
* ID of snapshot that is currently being constructed.
*/
/**ID of snapshot that is currently being constructed.*/
private int currentSnapshotID = -1;
/**
* Decoder for uncompressing snapshots.
*/
/**Decoder for uncompressing snapshots.*/
private DEZDecoder decoder = new DEZDecoder();
/**
* List of entities that were removed, and need not be added while syncing.
*/
/**List of entities that were removed, and need not be added while syncing.*/
private IntSet removed = new IntSet();
/**
* Byte stream for reading in snapshots.
*/
/**Byte stream for reading in snapshots.*/
private ReusableByteArrayInputStream byteStream = new ReusableByteArrayInputStream();
private DataInputStream dataStream = new DataInputStream(byteStream);

View File

@ -1,7 +1,9 @@
package io.anuke.mindustry.maps;
import com.badlogic.gdx.graphics.Texture;
import io.anuke.mindustry.io.SaveIO;
import io.anuke.mindustry.game.Saves.SaveSlot;
import io.anuke.mindustry.maps.goals.Goal;
import io.anuke.mindustry.maps.goals.WaveGoal;
import io.anuke.ucore.util.Bits;
import static io.anuke.mindustry.Vars.control;
@ -9,15 +11,21 @@ import static io.anuke.mindustry.Vars.control;
public class Sector{
/**Position on the map, can be positive or negative.*/
public short x, y;
/**Whether this sector has already been captured. TODO statistics?*/
public boolean unlocked;
/**Whether this sector has already been completed.*/
public boolean complete;
/**Slot ID of this sector's save. -1 means no save has been created.*/
public int saveID = -1;
/**Display texture. Needs to be disposed.*/
public transient Texture texture;
/**Goal of this sector-- what needs to be accomplished to unlock it.*/
public transient Goal goal = new WaveGoal(30);
public SaveSlot getSave(){
return control.getSaves().getByID(saveID);
}
public boolean hasSave(){
return saveID != -1 && SaveIO.isSaveValid(saveID) && control.getSaves().getByID(saveID) != null;
return control.getSaves().getByID(saveID) != null;
}
public int packedPosition(){

View File

@ -29,11 +29,10 @@ public class Sectors{
}
/**Unlocks a sector. This shows nearby sectors.*/
public void unlockSector(int x, int y){
public void completeSector(int x, int y){
createSector(x, y);
Sector sector = get(x, y);
sector.unlocked = true;
if(sector.texture == null) createTexture(sector);
sector.complete = true;
for(GridPoint2 point : Geometry.d4){
createSector(sector.x + point.x, sector.y + point.y);
@ -47,8 +46,10 @@ public class Sectors{
Sector sector = new Sector();
sector.x = (short)x;
sector.y = (short)y;
sector.unlocked = false;
sector.complete = false;
grid.put(x, y, sector);
if(sector.texture == null) createTexture(sector);
}
public void load(){
@ -60,7 +61,7 @@ public class Sectors{
}
if(out.size == 0){
unlockSector(0, 0);
createSector(0, 0);
}
}

View File

@ -223,7 +223,7 @@ public class WorldGenerator{
double border = 14;
if(edgeDist < border){
elevation += (border - edgeDist) / 6.0;
// elevation += (border - edgeDist) / 6.0;
}
if(temp < 0.35){

View File

@ -0,0 +1,5 @@
package io.anuke.mindustry.maps.goals;
public interface Goal{
boolean isComplete();
}

View File

@ -0,0 +1,16 @@
package io.anuke.mindustry.maps.goals;
import static io.anuke.mindustry.Vars.*;
public class WaveGoal implements Goal{
private final int target;
public WaveGoal(int target){
this.target = target;
}
@Override
public boolean isComplete(){
return state.wave >= target;
}
}

View File

@ -37,8 +37,9 @@ public class SectorsDialog extends FloatingDialog{
addCloseButton();
content().label(() -> Bundles.format("text.sector", selected == null ? "<none>" :
(selected.x + ", " + selected.y + (!selected.unlocked ? " " + Bundles.get("text.sector.locked") : ""))
+ (selected.saveID == -1 && selected.unlocked ? " " + Bundles.get("text.sector.unexplored") : "")));
(selected.x + ", " + selected.y + (!selected.complete && selected.saveID != -1 ? " " + Bundles.get("text.sector.locked") : ""))
+ (selected.saveID == -1 ? " " + Bundles.get("text.sector.unexplored") :
(selected.hasSave() ? " [accent]/[white] " + Bundles.format("text.sector.time", selected.getSave().getPlayTime()) : ""))));
content().row();
content().add(new SectorView()).grow();
content().row();
@ -56,7 +57,7 @@ public class SectorsDialog extends FloatingDialog{
logic.play();
}
});
}).size(230f, 64f).name("deploy-button").disabled(b -> selected == null || !selected.unlocked);
}).size(230f, 64f).name("deploy-button").disabled(b -> selected == null);
}
void selectSector(Sector sector){
@ -148,7 +149,7 @@ public class SectorsDialog extends FloatingDialog{
selectSector(sector);
}
Draw.color(Palette.remove);
}else if (sector.unlocked){
}else if (sector.complete){
Draw.color(Palette.accent);
}else{
Draw.color(Color.LIGHT_GRAY);

View File

@ -16,10 +16,7 @@ public class Build{
private static final Rectangle rect = new Rectangle();
private static final Rectangle hitrect = new Rectangle();
/**
* Returns block type that was broken, or null if unsuccesful.
*/
//@Remote(targets = Loc.both, forward = true, called = Loc.server, in = In.blocks)
/**Returns block type that was broken, or null if unsuccesful.*/
public static void beginBreak(Team team, int x, int y){
if(!validBreak(team, x, y)){
return;
@ -61,10 +58,7 @@ public class Build{
}
/**
* Places a BuildBlock at this location.
*/
//@Remote(targets = Loc.both, forward = true, called = Loc.server, in = In.blocks)
/**Places a BuildBlock at this location.*/
public static void beginPlace(Team team, int x, int y, Recipe recipe, int rotation){
if(!validPlace(team, x, y, recipe.result, rotation)){
return;
@ -107,9 +101,7 @@ public class Build{
threads.runDelay(() -> Events.fire(BlockBuildEvent.class, team, tile));
}
/**
* Returns whether a tile can be placed at this location by this team.
*/
/**Returns whether a tile can be placed at this location by this team.*/
public static boolean validPlace(Team team, int x, int y, Block type, int rotation){
Recipe recipe = Recipe.getByResult(type);
@ -179,9 +171,7 @@ public class Build{
}
}
/**
* Returns whether the tile at this position is breakable by this team
*/
/**Returns whether the tile at this position is breakable by this team*/
public static boolean validBreak(Team team, int x, int y){
Tile tile = world.tile(x, y);