Changed game over menu for sectors
This commit is contained in:
@@ -13,9 +13,11 @@ text.editor.web=The web version does not support the editor!\nDownload the game
|
|||||||
text.web.unsupported=The web version does not support this feature! Download the game to use it.
|
text.web.unsupported=The web version does not support this feature! Download the game to use it.
|
||||||
text.multiplayer.web=The web version of the game does not support multiplayer!\nUse the downloadable PC, Android or iOS versions.
|
text.multiplayer.web=The web version of the game does not support multiplayer!\nUse the downloadable PC, Android or iOS versions.
|
||||||
text.host.web=The web version does not support hosting games! Download the game to use this feature.
|
text.host.web=The web version does not support hosting games! Download the game to use this feature.
|
||||||
text.gameover=The core was destroyed.
|
text.gameover=Your core has been destroyed
|
||||||
text.highscore=[YELLOW]New highscore!
|
text.sector.gameover=This sector has been lost. Re-deploy?
|
||||||
text.lasted=You lasted until wave
|
text.sector.retry=Retry
|
||||||
|
text.highscore=[accent]New highscore!
|
||||||
|
text.wave.lasted=You lasted until wave [accent]{0}[].
|
||||||
text.level.highscore=High Score: [accent]{0}
|
text.level.highscore=High Score: [accent]{0}
|
||||||
text.level.delete.title=Confirm Delete
|
text.level.delete.title=Confirm Delete
|
||||||
text.map.delete=Are you sure you want to delete the map "[orange]{0}[]"?
|
text.map.delete=Are you sure you want to delete the map "[orange]{0}[]"?
|
||||||
|
|||||||
@@ -144,12 +144,16 @@ public class Control extends Module{
|
|||||||
});
|
});
|
||||||
|
|
||||||
Events.on(GameOverEvent.class, () -> {
|
Events.on(GameOverEvent.class, () -> {
|
||||||
Effects.shake(5, 6, Core.camera.position.x, Core.camera.position.y);
|
//delete saves for game-over sectors
|
||||||
|
if(world.getSector() != null && world.getSector().hasSave()){
|
||||||
|
world.getSector().getSave().delete();
|
||||||
|
}
|
||||||
|
|
||||||
//TODO game over effect
|
threads.runGraphics(() -> {
|
||||||
ui.restart.show();
|
Effects.shake(5, 6, Core.camera.position.x, Core.camera.position.y);
|
||||||
|
ui.restart.show();
|
||||||
Timers.runTask(30f, () -> state.set(State.menu));
|
state.set(State.menu);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
Events.on(WorldLoadEvent.class, () -> threads.runGraphics(() -> Events.fire(WorldLoadGraphicsEvent.class)));
|
Events.on(WorldLoadEvent.class, () -> threads.runGraphics(() -> Events.fire(WorldLoadGraphicsEvent.class)));
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.badlogic.gdx.graphics.Pixmap.Format;
|
|||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.math.GridPoint2;
|
import com.badlogic.gdx.math.GridPoint2;
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.game.Team;
|
||||||
import io.anuke.mindustry.maps.generation.WorldGenerator.GenResult;
|
import io.anuke.mindustry.maps.generation.WorldGenerator.GenResult;
|
||||||
import io.anuke.mindustry.world.ColorMapper;
|
import io.anuke.mindustry.world.ColorMapper;
|
||||||
@@ -26,6 +27,18 @@ public class Sectors{
|
|||||||
Settings.json().addClassTag("Sector", Sector.class);
|
Settings.json().addClassTag("Sector", Sector.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void playSector(Sector sector){
|
||||||
|
if(!sector.hasSave()){
|
||||||
|
world.loadSector(sector);
|
||||||
|
logic.play();
|
||||||
|
sector.saveID = control.getSaves().addSave("sector-" + sector.packedPosition()).index;
|
||||||
|
world.sectors().save();
|
||||||
|
}else{
|
||||||
|
control.getSaves().getByID(sector.saveID).load();
|
||||||
|
state.set(State.playing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**If a sector is not yet unlocked, returns null.*/
|
/**If a sector is not yet unlocked, returns null.*/
|
||||||
public Sector get(int x, int y){
|
public Sector get(int x, int y){
|
||||||
return grid.get(x, y);
|
return grid.get(x, y);
|
||||||
|
|||||||
@@ -27,16 +27,16 @@ import static io.anuke.mindustry.Vars.*;
|
|||||||
|
|
||||||
|
|
||||||
public class WorldGenerator{
|
public class WorldGenerator{
|
||||||
private final int seed = 0;
|
private static final int baseSeed = 0;
|
||||||
private int oreIndex = 0;
|
private int oreIndex = 0;
|
||||||
|
|
||||||
private Simplex sim = new Simplex(seed);
|
private Simplex sim = new Simplex(baseSeed);
|
||||||
private Simplex sim2 = new Simplex(seed + 1);
|
private Simplex sim2 = new Simplex(baseSeed + 1);
|
||||||
private Simplex sim3 = new Simplex(seed + 2);
|
private Simplex sim3 = new Simplex(baseSeed + 2);
|
||||||
private RidgedPerlin rid = new RidgedPerlin(seed + 4, 1);
|
private RidgedPerlin rid = new RidgedPerlin(baseSeed + 4, 1);
|
||||||
private VoronoiNoise vn = new VoronoiNoise(seed + 2, (short)0);
|
private VoronoiNoise vn = new VoronoiNoise(baseSeed + 2, (short)0);
|
||||||
|
|
||||||
private SeedRandom random = new SeedRandom(seed + 3);
|
private SeedRandom random = new SeedRandom(baseSeed + 3);
|
||||||
|
|
||||||
private GenResult result = new GenResult();
|
private GenResult result = new GenResult();
|
||||||
private ObjectMap<Block, Block> decoration;
|
private ObjectMap<Block, Block> decoration;
|
||||||
@@ -69,7 +69,7 @@ public class WorldGenerator{
|
|||||||
prepareTiles(tiles, seed, genOres);
|
prepareTiles(tiles, seed, genOres);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void prepareTiles(Tile[][] tiles, int seed, boolean genOres){
|
public void prepareTiles(Tile[][] tiles, long seed, boolean genOres){
|
||||||
|
|
||||||
//find multiblocks
|
//find multiblocks
|
||||||
IntArray multiblocks = new IntArray();
|
IntArray multiblocks = new IntArray();
|
||||||
@@ -137,11 +137,11 @@ public class WorldGenerator{
|
|||||||
|
|
||||||
if(genOres){
|
if(genOres){
|
||||||
Array<OreEntry> ores = Array.with(
|
Array<OreEntry> ores = Array.with(
|
||||||
new OreEntry(Items.tungsten, 0.3f, seed),
|
new OreEntry(Items.tungsten, 0.3f, seed),
|
||||||
new OreEntry(Items.coal, 0.284f, seed),
|
new OreEntry(Items.coal, 0.284f, seed),
|
||||||
new OreEntry(Items.lead, 0.28f, seed),
|
new OreEntry(Items.lead, 0.28f, seed),
|
||||||
new OreEntry(Items.titanium, 0.27f, seed),
|
new OreEntry(Items.titanium, 0.27f, seed),
|
||||||
new OreEntry(Items.thorium, 0.26f, seed)
|
new OreEntry(Items.thorium, 0.26f, seed)
|
||||||
);
|
);
|
||||||
|
|
||||||
for(int x = 0; x < tiles.length; x++){
|
for(int x = 0; x < tiles.length; x++){
|
||||||
@@ -169,6 +169,8 @@ public class WorldGenerator{
|
|||||||
|
|
||||||
public void generateMap(Tile[][] tiles, int sectorX, int sectorY){
|
public void generateMap(Tile[][] tiles, int sectorX, int sectorY){
|
||||||
int width = tiles.length, height = tiles[0].length;
|
int width = tiles.length, height = tiles[0].length;
|
||||||
|
long seed = Bits.packLong(sectorX, sectorY);
|
||||||
|
SeedRandom rnd = new SeedRandom(seed);
|
||||||
|
|
||||||
for(int x = 0; x < width; x++){
|
for(int x = 0; x < width; x++){
|
||||||
for(int y = 0; y < height; y++){
|
for(int y = 0; y < height; y++){
|
||||||
@@ -188,7 +190,7 @@ public class WorldGenerator{
|
|||||||
if(!Mathf.inBounds(x + point.x, y + point.y, width, height)) continue;
|
if(!Mathf.inBounds(x + point.x, y + point.y, width, height)) continue;
|
||||||
if(tiles[x + point.x][y + point.y].getElevation() < elevation){
|
if(tiles[x + point.x][y + point.y].getElevation() < elevation){
|
||||||
|
|
||||||
if(Mathf.chance(0.06)){
|
if(rnd.chance(0.06)){
|
||||||
tile.setElevation(-1);
|
tile.setElevation(-1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -205,10 +207,6 @@ public class WorldGenerator{
|
|||||||
prepareTiles(tiles, seed, true);
|
prepareTiles(tiles, seed, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSector(int sectorX, int sectorY){
|
|
||||||
random.setSeed(Bits.packLong(sectorX, sectorY));
|
|
||||||
}
|
|
||||||
|
|
||||||
public GenResult generateTile(int sectorX, int sectorY, int localX, int localY){
|
public GenResult generateTile(int sectorX, int sectorY, int localX, int localY){
|
||||||
return generateTile(sectorX, sectorY, localX, localY, true);
|
return generateTile(sectorX, sectorY, localX, localY, true);
|
||||||
}
|
}
|
||||||
@@ -283,11 +281,11 @@ public class WorldGenerator{
|
|||||||
final RidgedPerlin ridge;
|
final RidgedPerlin ridge;
|
||||||
final int index;
|
final int index;
|
||||||
|
|
||||||
OreEntry(Item item, float frequency, int seed){
|
OreEntry(Item item, float frequency, long seed){
|
||||||
this.frequency = frequency;
|
this.frequency = frequency;
|
||||||
this.item = item;
|
this.item = item;
|
||||||
this.noise = new Simplex(seed + oreIndex);
|
this.noise = new Simplex(seed + oreIndex);
|
||||||
this.ridge = new RidgedPerlin(seed + oreIndex, 2);
|
this.ridge = new RidgedPerlin((int)(seed + oreIndex), 2);
|
||||||
this.index = oreIndex++;
|
this.index = oreIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,50 @@
|
|||||||
package io.anuke.mindustry.ui.dialogs;
|
package io.anuke.mindustry.ui.dialogs;
|
||||||
|
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
import io.anuke.ucore.scene.ui.Dialog;
|
import io.anuke.mindustry.maps.Sector;
|
||||||
|
import io.anuke.ucore.util.Bundles;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class RestartDialog extends Dialog{
|
public class RestartDialog extends FloatingDialog{
|
||||||
|
|
||||||
public RestartDialog(){
|
public RestartDialog(){
|
||||||
super("$text.gameover", "dialog");
|
super("$text.gameover");
|
||||||
|
setFillParent(false);
|
||||||
|
shown(this::rebuild);
|
||||||
|
}
|
||||||
|
|
||||||
shown(() -> {
|
void rebuild(){
|
||||||
content().clearChildren();
|
buttons().clear();
|
||||||
|
content().clear();
|
||||||
|
|
||||||
|
buttons().margin(10);
|
||||||
|
|
||||||
|
if(world.getSector() == null){
|
||||||
if(control.isHighScore()){
|
if(control.isHighScore()){
|
||||||
content().add("$text.highscore").pad(6);
|
content().add("$text.highscore").pad(6);
|
||||||
content().row();
|
content().row();
|
||||||
}
|
}
|
||||||
content().add("$text.lasted").pad(12).get();
|
content().add(Bundles.format("text.wave.lasted", state.wave)).pad(12);
|
||||||
content().add("[accent]" + state.wave);
|
|
||||||
pack();
|
|
||||||
});
|
|
||||||
|
|
||||||
getButtonTable().addButton("$text.menu", () -> {
|
buttons().addButton("$text.menu", () -> {
|
||||||
hide();
|
hide();
|
||||||
state.set(State.menu);
|
state.set(State.menu);
|
||||||
logic.reset();
|
logic.reset();
|
||||||
}).size(130f, 60f);
|
}).size(130f, 60f);
|
||||||
|
}else{
|
||||||
|
content().add("$text.sector.gameover");
|
||||||
|
buttons().addButton("$text.menu", () -> {
|
||||||
|
hide();
|
||||||
|
state.set(State.menu);
|
||||||
|
logic.reset();
|
||||||
|
}).size(130f, 60f);
|
||||||
|
|
||||||
|
buttons().addButton("$text.sector.retry", () -> {
|
||||||
|
Sector sector = world.getSector();
|
||||||
|
ui.loadLogic(() -> world.sectors().playSector(sector));
|
||||||
|
hide();
|
||||||
|
}).size(130f, 60f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package io.anuke.mindustry.ui.dialogs;
|
|||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.math.Rectangle;
|
import com.badlogic.gdx.math.Rectangle;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
|
||||||
import io.anuke.mindustry.graphics.Palette;
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
import io.anuke.mindustry.maps.Sector;
|
import io.anuke.mindustry.maps.Sector;
|
||||||
import io.anuke.ucore.core.Graphics;
|
import io.anuke.ucore.core.Graphics;
|
||||||
@@ -47,17 +46,7 @@ public class SectorsDialog extends FloatingDialog{
|
|||||||
buttons().addImageTextButton("$text.sector.deploy", "icon-play", 10*3, () -> {
|
buttons().addImageTextButton("$text.sector.deploy", "icon-play", 10*3, () -> {
|
||||||
hide();
|
hide();
|
||||||
|
|
||||||
ui.loadLogic(() -> {
|
ui.loadLogic(() -> world.sectors().playSector(selected));
|
||||||
if(!selected.hasSave()){
|
|
||||||
world.loadSector(selected);
|
|
||||||
logic.play();
|
|
||||||
selected.saveID = control.getSaves().addSave("sector-" + selected.packedPosition()).index;
|
|
||||||
world.sectors().save();
|
|
||||||
}else{
|
|
||||||
control.getSaves().getByID(selected.saveID).load();
|
|
||||||
state.set(State.playing);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}).size(230f, 64f).name("deploy-button").disabled(b -> selected == null);
|
}).size(230f, 64f).name("deploy-button").disabled(b -> selected == null);
|
||||||
|
|
||||||
if(debug){
|
if(debug){
|
||||||
|
|||||||
Reference in New Issue
Block a user