mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-28 00:19:57 +07:00
Fixed sector world gen / Added sector goal unlocks
This commit is contained in:
parent
6f6601d270
commit
ac039ce7cd
@ -51,9 +51,11 @@ text.customgame=Custom Game
|
|||||||
text.campaign=Campaign
|
text.campaign=Campaign
|
||||||
text.sectors=Sectors
|
text.sectors=Sectors
|
||||||
text.sector=Selected Sector: [LIGHT_GRAY]{0}
|
text.sector=Selected Sector: [LIGHT_GRAY]{0}
|
||||||
|
text.sector.time=Time: [LIGHT_GRAY]{0}
|
||||||
text.sector.deploy=Deploy
|
text.sector.deploy=Deploy
|
||||||
text.sector.resume=Resume
|
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.sector.unexplored=[accent][[Unexplored]
|
||||||
text.quit=Quit
|
text.quit=Quit
|
||||||
text.maps=Maps
|
text.maps=Maps
|
||||||
|
@ -368,6 +368,15 @@ public class Control extends Module{
|
|||||||
input.update();
|
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
|
//check unlocks every 2 seconds
|
||||||
if(!state.mode.infiniteResources && Timers.get("timerCheckUnlock", 120)){
|
if(!state.mode.infiniteResources && Timers.get("timerCheckUnlock", 120)){
|
||||||
checkUnlockableBlocks();
|
checkUnlockableBlocks();
|
||||||
|
@ -41,59 +41,33 @@ public class NetClient extends Module{
|
|||||||
private final static float playerSyncTime = 2;
|
private final static float playerSyncTime = 2;
|
||||||
|
|
||||||
private Timer timer = new Timer(5);
|
private Timer timer = new Timer(5);
|
||||||
/**
|
/**Whether the client is currently connecting.*/
|
||||||
* Whether the client is currently connecting.
|
|
||||||
*/
|
|
||||||
private boolean connecting = false;
|
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;
|
private boolean quiet = false;
|
||||||
/**
|
/**Counter for data timeout.*/
|
||||||
* Counter for data timeout.
|
|
||||||
*/
|
|
||||||
private float timeoutTime = 0f;
|
private float timeoutTime = 0f;
|
||||||
/**
|
/**Last sent client snapshot ID.*/
|
||||||
* Last sent client snapshot ID.
|
|
||||||
*/
|
|
||||||
private int lastSent;
|
private int lastSent;
|
||||||
|
|
||||||
/**
|
/**Last snapshot ID recieved.*/
|
||||||
* Last snapshot ID recieved.
|
|
||||||
*/
|
|
||||||
private int lastSnapshotBaseID = -1;
|
private int lastSnapshotBaseID = -1;
|
||||||
/**
|
/**Last snapshot recieved.*/
|
||||||
* Last snapshot recieved.
|
|
||||||
*/
|
|
||||||
private byte[] lastSnapshotBase;
|
private byte[] lastSnapshotBase;
|
||||||
/**
|
/**Current snapshot that is being built from chinks.*/
|
||||||
* Current snapshot that is being built from chinks.
|
|
||||||
*/
|
|
||||||
private byte[] currentSnapshot;
|
private byte[] currentSnapshot;
|
||||||
/**
|
/**Array of recieved chunk statuses.*/
|
||||||
* Array of recieved chunk statuses.
|
|
||||||
*/
|
|
||||||
private boolean[] recievedChunks;
|
private boolean[] recievedChunks;
|
||||||
/**
|
/**Counter of how many chunks have been recieved.*/
|
||||||
* Counter of how many chunks have been recieved.
|
|
||||||
*/
|
|
||||||
private int recievedChunkCounter;
|
private int recievedChunkCounter;
|
||||||
/**
|
/**ID of snapshot that is currently being constructed.*/
|
||||||
* ID of snapshot that is currently being constructed.
|
|
||||||
*/
|
|
||||||
private int currentSnapshotID = -1;
|
private int currentSnapshotID = -1;
|
||||||
|
|
||||||
/**
|
/**Decoder for uncompressing snapshots.*/
|
||||||
* Decoder for uncompressing snapshots.
|
|
||||||
*/
|
|
||||||
private DEZDecoder decoder = new DEZDecoder();
|
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();
|
private IntSet removed = new IntSet();
|
||||||
/**
|
/**Byte stream for reading in snapshots.*/
|
||||||
* Byte stream for reading in snapshots.
|
|
||||||
*/
|
|
||||||
private ReusableByteArrayInputStream byteStream = new ReusableByteArrayInputStream();
|
private ReusableByteArrayInputStream byteStream = new ReusableByteArrayInputStream();
|
||||||
private DataInputStream dataStream = new DataInputStream(byteStream);
|
private DataInputStream dataStream = new DataInputStream(byteStream);
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package io.anuke.mindustry.maps;
|
package io.anuke.mindustry.maps;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
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 io.anuke.ucore.util.Bits;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.control;
|
import static io.anuke.mindustry.Vars.control;
|
||||||
@ -9,15 +11,21 @@ import static io.anuke.mindustry.Vars.control;
|
|||||||
public class Sector{
|
public class Sector{
|
||||||
/**Position on the map, can be positive or negative.*/
|
/**Position on the map, can be positive or negative.*/
|
||||||
public short x, y;
|
public short x, y;
|
||||||
/**Whether this sector has already been captured. TODO statistics?*/
|
/**Whether this sector has already been completed.*/
|
||||||
public boolean unlocked;
|
public boolean complete;
|
||||||
/**Slot ID of this sector's save. -1 means no save has been created.*/
|
/**Slot ID of this sector's save. -1 means no save has been created.*/
|
||||||
public int saveID = -1;
|
public int saveID = -1;
|
||||||
/**Display texture. Needs to be disposed.*/
|
/**Display texture. Needs to be disposed.*/
|
||||||
public transient Texture texture;
|
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(){
|
public boolean hasSave(){
|
||||||
return saveID != -1 && SaveIO.isSaveValid(saveID) && control.getSaves().getByID(saveID) != null;
|
return control.getSaves().getByID(saveID) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int packedPosition(){
|
public int packedPosition(){
|
||||||
|
@ -29,11 +29,10 @@ public class Sectors{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**Unlocks a sector. This shows nearby 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);
|
createSector(x, y);
|
||||||
Sector sector = get(x, y);
|
Sector sector = get(x, y);
|
||||||
sector.unlocked = true;
|
sector.complete = true;
|
||||||
if(sector.texture == null) createTexture(sector);
|
|
||||||
|
|
||||||
for(GridPoint2 point : Geometry.d4){
|
for(GridPoint2 point : Geometry.d4){
|
||||||
createSector(sector.x + point.x, sector.y + point.y);
|
createSector(sector.x + point.x, sector.y + point.y);
|
||||||
@ -47,8 +46,10 @@ public class Sectors{
|
|||||||
Sector sector = new Sector();
|
Sector sector = new Sector();
|
||||||
sector.x = (short)x;
|
sector.x = (short)x;
|
||||||
sector.y = (short)y;
|
sector.y = (short)y;
|
||||||
sector.unlocked = false;
|
sector.complete = false;
|
||||||
grid.put(x, y, sector);
|
grid.put(x, y, sector);
|
||||||
|
|
||||||
|
if(sector.texture == null) createTexture(sector);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load(){
|
public void load(){
|
||||||
@ -60,7 +61,7 @@ public class Sectors{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(out.size == 0){
|
if(out.size == 0){
|
||||||
unlockSector(0, 0);
|
createSector(0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ public class WorldGenerator{
|
|||||||
double border = 14;
|
double border = 14;
|
||||||
|
|
||||||
if(edgeDist < border){
|
if(edgeDist < border){
|
||||||
elevation += (border - edgeDist) / 6.0;
|
// elevation += (border - edgeDist) / 6.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(temp < 0.35){
|
if(temp < 0.35){
|
||||||
|
5
core/src/io/anuke/mindustry/maps/goals/Goal.java
Normal file
5
core/src/io/anuke/mindustry/maps/goals/Goal.java
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package io.anuke.mindustry.maps.goals;
|
||||||
|
|
||||||
|
public interface Goal{
|
||||||
|
boolean isComplete();
|
||||||
|
}
|
16
core/src/io/anuke/mindustry/maps/goals/WaveGoal.java
Normal file
16
core/src/io/anuke/mindustry/maps/goals/WaveGoal.java
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
@ -37,8 +37,9 @@ public class SectorsDialog extends FloatingDialog{
|
|||||||
addCloseButton();
|
addCloseButton();
|
||||||
|
|
||||||
content().label(() -> Bundles.format("text.sector", selected == null ? "<none>" :
|
content().label(() -> Bundles.format("text.sector", selected == null ? "<none>" :
|
||||||
(selected.x + ", " + selected.y + (!selected.unlocked ? " " + Bundles.get("text.sector.locked") : ""))
|
(selected.x + ", " + selected.y + (!selected.complete && selected.saveID != -1 ? " " + Bundles.get("text.sector.locked") : ""))
|
||||||
+ (selected.saveID == -1 && selected.unlocked ? " " + Bundles.get("text.sector.unexplored") : "")));
|
+ (selected.saveID == -1 ? " " + Bundles.get("text.sector.unexplored") :
|
||||||
|
(selected.hasSave() ? " [accent]/[white] " + Bundles.format("text.sector.time", selected.getSave().getPlayTime()) : ""))));
|
||||||
content().row();
|
content().row();
|
||||||
content().add(new SectorView()).grow();
|
content().add(new SectorView()).grow();
|
||||||
content().row();
|
content().row();
|
||||||
@ -56,7 +57,7 @@ public class SectorsDialog extends FloatingDialog{
|
|||||||
logic.play();
|
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){
|
void selectSector(Sector sector){
|
||||||
@ -148,7 +149,7 @@ public class SectorsDialog extends FloatingDialog{
|
|||||||
selectSector(sector);
|
selectSector(sector);
|
||||||
}
|
}
|
||||||
Draw.color(Palette.remove);
|
Draw.color(Palette.remove);
|
||||||
}else if (sector.unlocked){
|
}else if (sector.complete){
|
||||||
Draw.color(Palette.accent);
|
Draw.color(Palette.accent);
|
||||||
}else{
|
}else{
|
||||||
Draw.color(Color.LIGHT_GRAY);
|
Draw.color(Color.LIGHT_GRAY);
|
||||||
|
@ -16,10 +16,7 @@ public class Build{
|
|||||||
private static final Rectangle rect = new Rectangle();
|
private static final Rectangle rect = new Rectangle();
|
||||||
private static final Rectangle hitrect = new Rectangle();
|
private static final Rectangle hitrect = new Rectangle();
|
||||||
|
|
||||||
/**
|
/**Returns block type that was broken, or null if unsuccesful.*/
|
||||||
* Returns block type that was broken, or null if unsuccesful.
|
|
||||||
*/
|
|
||||||
//@Remote(targets = Loc.both, forward = true, called = Loc.server, in = In.blocks)
|
|
||||||
public static void beginBreak(Team team, int x, int y){
|
public static void beginBreak(Team team, int x, int y){
|
||||||
if(!validBreak(team, x, y)){
|
if(!validBreak(team, x, y)){
|
||||||
return;
|
return;
|
||||||
@ -61,10 +58,7 @@ public class Build{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**Places a BuildBlock at this location.*/
|
||||||
* Places a BuildBlock at this location.
|
|
||||||
*/
|
|
||||||
//@Remote(targets = Loc.both, forward = true, called = Loc.server, in = In.blocks)
|
|
||||||
public static void beginPlace(Team team, int x, int y, Recipe recipe, int rotation){
|
public static void beginPlace(Team team, int x, int y, Recipe recipe, int rotation){
|
||||||
if(!validPlace(team, x, y, recipe.result, rotation)){
|
if(!validPlace(team, x, y, recipe.result, rotation)){
|
||||||
return;
|
return;
|
||||||
@ -107,9 +101,7 @@ public class Build{
|
|||||||
threads.runDelay(() -> Events.fire(BlockBuildEvent.class, team, tile));
|
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){
|
public static boolean validPlace(Team team, int x, int y, Block type, int rotation){
|
||||||
Recipe recipe = Recipe.getByResult(type);
|
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){
|
public static boolean validBreak(Team team, int x, int y){
|
||||||
Tile tile = world.tile(x, y);
|
Tile tile = world.tile(x, y);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user