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

@@ -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;
}
}