Implemented hiscore and hiscore display

This commit is contained in:
Anuken 2017-05-05 17:37:21 -04:00
parent eef909db3e
commit 73d5dbdd34
7 changed files with 41 additions and 10 deletions

View file

@ -43,6 +43,9 @@ public class Control extends RendererModule{
Settings.loadAll("io.anuke.moment");
for(String map : maps)
Settings.defaults("hiscore"+map, 0);
Sounds.setFalloff(9000f);
player = new Player();

View file

@ -29,6 +29,8 @@ public class GameState{
player.heal();
Inventory.clearItems();
spawnpoints.clear();
respawntime = -1;
hiscore = false;
ui.updateItems();
ui.updateWeapons();
@ -89,6 +91,14 @@ public class GameState{
wave ++;
int last = Settings.getInt("hiscore"+maps[currentMap]);
if(wave > last){
Settings.putInt("hiscore"+maps[currentMap], wave);
Settings.save();
hiscore = true;
}
wavetime = waveSpacing();
}

View file

@ -4,7 +4,6 @@ import static io.anuke.mindustry.Vars.*;
import com.badlogic.gdx.Input.Buttons;
import io.anuke.mindustry.ai.Pathfind;
import io.anuke.mindustry.entities.Weapon;
import io.anuke.mindustry.resource.ItemStack;
import io.anuke.mindustry.world.Tile;
@ -97,7 +96,6 @@ public class Input{
Effects.effect("break", tile.entity);
Effects.shake(3f, 1f);
tile.setBlock(Blocks.air);
Pathfind.updatePath();
breaktime = 0f;
Sounds.play("break");
}

View file

@ -129,6 +129,10 @@ public class UI extends SceneModule{
public Dialog show(Scene scene){
super.show(scene);
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.pack();
return this;
@ -379,14 +383,14 @@ public class UI extends SceneModule{
new label("Respawning in"){{
get().update(()->{
get().setText("[crimson]Respawning in " + (int)(respawntime/60));
get().setText("[yellow]Respawning in " + (int)(respawntime/60));
});
get().setFontScale(0.75f);
}};
visible(()->{
return respawntime > 0;
return respawntime > 0 && playing;
});
}};
}}.end();

View file

@ -19,7 +19,7 @@ public class Vars{
public static final float wavespace = 20*60;
public static final float enemyspawnspace = 65;
public static final float breakduration = 30;
public static boolean debug = true;
public static boolean debug = false;
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 Pixmap[] mapPixmaps;
public static Texture[] mapTextures;
public static int currentMap;
public static int worldsize = 128;
public static int pixsize = worldsize*tilesize;
public static Tile[][] tiles = new Tile[worldsize][worldsize];
public static boolean hiscore = false;
public static Recipe recipe;
public static int rotation;

View file

@ -52,6 +52,7 @@ public class World{
worldsize = size;
pixsize = worldsize*tilesize;
tiles = new Tile[worldsize][worldsize];
currentMap = id;
for(int x = 0; x < worldsize; x ++){
for(int y = 0; y < worldsize; y ++){

View file

@ -6,21 +6,24 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion;
import io.anuke.mindustry.GameState;
import io.anuke.mindustry.World;
import io.anuke.ucore.scene.ui.ButtonGroup;
import io.anuke.ucore.scene.ui.Dialog;
import io.anuke.ucore.scene.ui.ImageButton;
import io.anuke.ucore.core.Settings;
import io.anuke.ucore.scene.ui.*;
public class LevelDialog extends Dialog{
Label[] scores = new Label[maps.length];
private int selectedMap;
public LevelDialog(){
super("Level Select");
setup();
shown(()->{
for(int i = 0; i < maps.length; i ++)
scores[i].setText("High Score: [lime]" + Settings.getInt("hiscore"+maps[i]));
});
}
void setup(){
ButtonGroup<ImageButton> mapgroup = new ButtonGroup<>();
addCloseButton();
getButtonTable().addButton("Play", ()->{
hide();
@ -28,6 +31,8 @@ public class LevelDialog extends Dialog{
GameState.play();
});
ButtonGroup<ImageButton> mapgroup = new ButtonGroup<>();
for(int i = 0; i < maps.length; i ++){
content().add(maps[i]);
}
@ -44,5 +49,12 @@ public class LevelDialog extends Dialog{
image.getImageCell().size(150, 150);
content().add(image).size(180);
}
content().row();
for(int i = 0; i < maps.length; i ++){
scores[i] = new Label("");
content().add(scores[i]);
}
}
}