Implemented hiscore and hiscore display
This commit is contained in:
@@ -43,6 +43,9 @@ public class Control extends RendererModule{
|
|||||||
|
|
||||||
Settings.loadAll("io.anuke.moment");
|
Settings.loadAll("io.anuke.moment");
|
||||||
|
|
||||||
|
for(String map : maps)
|
||||||
|
Settings.defaults("hiscore"+map, 0);
|
||||||
|
|
||||||
Sounds.setFalloff(9000f);
|
Sounds.setFalloff(9000f);
|
||||||
|
|
||||||
player = new Player();
|
player = new Player();
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ public class GameState{
|
|||||||
player.heal();
|
player.heal();
|
||||||
Inventory.clearItems();
|
Inventory.clearItems();
|
||||||
spawnpoints.clear();
|
spawnpoints.clear();
|
||||||
|
respawntime = -1;
|
||||||
|
hiscore = false;
|
||||||
|
|
||||||
ui.updateItems();
|
ui.updateItems();
|
||||||
ui.updateWeapons();
|
ui.updateWeapons();
|
||||||
@@ -89,6 +91,14 @@ public class GameState{
|
|||||||
|
|
||||||
wave ++;
|
wave ++;
|
||||||
|
|
||||||
|
int last = Settings.getInt("hiscore"+maps[currentMap]);
|
||||||
|
|
||||||
|
if(wave > last){
|
||||||
|
Settings.putInt("hiscore"+maps[currentMap], wave);
|
||||||
|
Settings.save();
|
||||||
|
hiscore = true;
|
||||||
|
}
|
||||||
|
|
||||||
wavetime = waveSpacing();
|
wavetime = waveSpacing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import static io.anuke.mindustry.Vars.*;
|
|||||||
|
|
||||||
import com.badlogic.gdx.Input.Buttons;
|
import com.badlogic.gdx.Input.Buttons;
|
||||||
|
|
||||||
import io.anuke.mindustry.ai.Pathfind;
|
|
||||||
import io.anuke.mindustry.entities.Weapon;
|
import io.anuke.mindustry.entities.Weapon;
|
||||||
import io.anuke.mindustry.resource.ItemStack;
|
import io.anuke.mindustry.resource.ItemStack;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
@@ -97,7 +96,6 @@ public class Input{
|
|||||||
Effects.effect("break", tile.entity);
|
Effects.effect("break", tile.entity);
|
||||||
Effects.shake(3f, 1f);
|
Effects.shake(3f, 1f);
|
||||||
tile.setBlock(Blocks.air);
|
tile.setBlock(Blocks.air);
|
||||||
Pathfind.updatePath();
|
|
||||||
breaktime = 0f;
|
breaktime = 0f;
|
||||||
Sounds.play("break");
|
Sounds.play("break");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,6 +129,10 @@ public class UI extends SceneModule{
|
|||||||
public Dialog show(Scene scene){
|
public Dialog show(Scene scene){
|
||||||
super.show(scene);
|
super.show(scene);
|
||||||
restart.content().clearChildren();
|
restart.content().clearChildren();
|
||||||
|
if(hiscore){
|
||||||
|
restart.content().add("[YELLOW]New highscore!").pad(6);
|
||||||
|
restart.content().row();
|
||||||
|
}
|
||||||
restart.content().add("You lasted until wave [GREEN]" + wave + "[].").pad(6);
|
restart.content().add("You lasted until wave [GREEN]" + wave + "[].").pad(6);
|
||||||
restart.pack();
|
restart.pack();
|
||||||
return this;
|
return this;
|
||||||
@@ -379,14 +383,14 @@ public class UI extends SceneModule{
|
|||||||
|
|
||||||
new label("Respawning in"){{
|
new label("Respawning in"){{
|
||||||
get().update(()->{
|
get().update(()->{
|
||||||
get().setText("[crimson]Respawning in " + (int)(respawntime/60));
|
get().setText("[yellow]Respawning in " + (int)(respawntime/60));
|
||||||
});
|
});
|
||||||
|
|
||||||
get().setFontScale(0.75f);
|
get().setFontScale(0.75f);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
visible(()->{
|
visible(()->{
|
||||||
return respawntime > 0;
|
return respawntime > 0 && playing;
|
||||||
});
|
});
|
||||||
}};
|
}};
|
||||||
}}.end();
|
}}.end();
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class Vars{
|
|||||||
public static final float wavespace = 20*60;
|
public static final float wavespace = 20*60;
|
||||||
public static final float enemyspawnspace = 65;
|
public static final float enemyspawnspace = 65;
|
||||||
public static final float breakduration = 30;
|
public static final float breakduration = 30;
|
||||||
public static boolean debug = true;
|
public static boolean debug = false;
|
||||||
|
|
||||||
public static final Vector2 vector = new Vector2();
|
public static final Vector2 vector = new Vector2();
|
||||||
|
|
||||||
@@ -39,10 +39,13 @@ public class Vars{
|
|||||||
public static final String[] maps = {"delta", "canyon", "pit", "maze"};
|
public static final String[] maps = {"delta", "canyon", "pit", "maze"};
|
||||||
public static Pixmap[] mapPixmaps;
|
public static Pixmap[] mapPixmaps;
|
||||||
public static Texture[] mapTextures;
|
public static Texture[] mapTextures;
|
||||||
|
public static int currentMap;
|
||||||
public static int worldsize = 128;
|
public static int worldsize = 128;
|
||||||
public static int pixsize = worldsize*tilesize;
|
public static int pixsize = worldsize*tilesize;
|
||||||
public static Tile[][] tiles = new Tile[worldsize][worldsize];
|
public static Tile[][] tiles = new Tile[worldsize][worldsize];
|
||||||
|
|
||||||
|
public static boolean hiscore = false;
|
||||||
|
|
||||||
public static Recipe recipe;
|
public static Recipe recipe;
|
||||||
public static int rotation;
|
public static int rotation;
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ public class World{
|
|||||||
worldsize = size;
|
worldsize = size;
|
||||||
pixsize = worldsize*tilesize;
|
pixsize = worldsize*tilesize;
|
||||||
tiles = new Tile[worldsize][worldsize];
|
tiles = new Tile[worldsize][worldsize];
|
||||||
|
currentMap = id;
|
||||||
|
|
||||||
for(int x = 0; x < worldsize; x ++){
|
for(int x = 0; x < worldsize; x ++){
|
||||||
for(int y = 0; y < worldsize; y ++){
|
for(int y = 0; y < worldsize; y ++){
|
||||||
|
|||||||
@@ -6,21 +6,24 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
|||||||
|
|
||||||
import io.anuke.mindustry.GameState;
|
import io.anuke.mindustry.GameState;
|
||||||
import io.anuke.mindustry.World;
|
import io.anuke.mindustry.World;
|
||||||
import io.anuke.ucore.scene.ui.ButtonGroup;
|
import io.anuke.ucore.core.Settings;
|
||||||
import io.anuke.ucore.scene.ui.Dialog;
|
import io.anuke.ucore.scene.ui.*;
|
||||||
import io.anuke.ucore.scene.ui.ImageButton;
|
|
||||||
|
|
||||||
public class LevelDialog extends Dialog{
|
public class LevelDialog extends Dialog{
|
||||||
|
Label[] scores = new Label[maps.length];
|
||||||
private int selectedMap;
|
private int selectedMap;
|
||||||
|
|
||||||
public LevelDialog(){
|
public LevelDialog(){
|
||||||
super("Level Select");
|
super("Level Select");
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
|
shown(()->{
|
||||||
|
for(int i = 0; i < maps.length; i ++)
|
||||||
|
scores[i].setText("High Score: [lime]" + Settings.getInt("hiscore"+maps[i]));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup(){
|
void setup(){
|
||||||
ButtonGroup<ImageButton> mapgroup = new ButtonGroup<>();
|
|
||||||
|
|
||||||
addCloseButton();
|
addCloseButton();
|
||||||
getButtonTable().addButton("Play", ()->{
|
getButtonTable().addButton("Play", ()->{
|
||||||
hide();
|
hide();
|
||||||
@@ -28,6 +31,8 @@ public class LevelDialog extends Dialog{
|
|||||||
GameState.play();
|
GameState.play();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ButtonGroup<ImageButton> mapgroup = new ButtonGroup<>();
|
||||||
|
|
||||||
for(int i = 0; i < maps.length; i ++){
|
for(int i = 0; i < maps.length; i ++){
|
||||||
content().add(maps[i]);
|
content().add(maps[i]);
|
||||||
}
|
}
|
||||||
@@ -44,5 +49,12 @@ public class LevelDialog extends Dialog{
|
|||||||
image.getImageCell().size(150, 150);
|
image.getImageCell().size(150, 150);
|
||||||
content().add(image).size(180);
|
content().add(image).size(180);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
content().row();
|
||||||
|
|
||||||
|
for(int i = 0; i < maps.length; i ++){
|
||||||
|
scores[i] = new Label("");
|
||||||
|
content().add(scores[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user