mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-18 16:28:33 +07:00
Added difficulty, fixed some bugs
This commit is contained in:
parent
53008df1d2
commit
1574ca33bc
@ -404,6 +404,7 @@ public class Control extends RendererModule<Moment>{
|
||||
void drawHealth(DestructibleEntity dest){
|
||||
float len = 3;
|
||||
float offset = 7;
|
||||
|
||||
Draw.thickness(3f);
|
||||
Draw.color(Color.GRAY);
|
||||
Draw.line(dest.x - len + 1, dest.y - offset, dest.x + len + 1, dest.y - offset);
|
||||
@ -411,7 +412,7 @@ public class Control extends RendererModule<Moment>{
|
||||
Draw.color(Color.BLACK);
|
||||
Draw.line(dest.x - len + 1, dest.y - offset, dest.x + len, dest.y - offset);
|
||||
Draw.color(Color.RED);
|
||||
Draw.line(dest.x - len + 1, dest.y - offset, dest.x - len + len * 2 * ((float) dest.health / dest.maxhealth), dest.y - offset);
|
||||
Draw.line(dest.x - len + 1, dest.y - offset, dest.x - len + (int)(len * 2 * ((float) dest.health / dest.maxhealth)), dest.y - offset);
|
||||
Draw.clear();
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import com.badlogic.gdx.Input.Keys;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
|
||||
import io.anuke.moment.ai.Pathfind;
|
||||
import io.anuke.moment.entities.Enemy;
|
||||
import io.anuke.moment.entities.Player;
|
||||
import io.anuke.moment.resource.Item;
|
||||
@ -35,7 +36,7 @@ public class Moment extends ModuleController<Moment>{
|
||||
|
||||
public int wave = 1;
|
||||
public float wavespace = 60*60;
|
||||
public float wavetime = wavespace;
|
||||
public float wavetime;
|
||||
public float spawnspace = 65;
|
||||
public Tile core;
|
||||
public Array<Tile> spawnpoints = new Array<Tile>();
|
||||
@ -52,7 +53,7 @@ public class Moment extends ModuleController<Moment>{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup(){
|
||||
public void preInit(){
|
||||
KeyBinds.defaults(
|
||||
"up", Keys.W,
|
||||
"left", Keys.A,
|
||||
@ -76,6 +77,10 @@ public class Moment extends ModuleController<Moment>{
|
||||
|
||||
player = new Player();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit(){
|
||||
restart();
|
||||
}
|
||||
|
||||
@ -95,12 +100,13 @@ public class Moment extends ModuleController<Moment>{
|
||||
}
|
||||
|
||||
public void play(){
|
||||
wavetime = waveSpacing();
|
||||
playing = true;
|
||||
}
|
||||
|
||||
public void restart(){
|
||||
wave = 1;
|
||||
wavetime = wavespace;
|
||||
wavetime = waveSpacing();
|
||||
Entities.clear();
|
||||
Enemy.amount = 0;
|
||||
player.add();
|
||||
@ -112,10 +118,12 @@ public class Moment extends ModuleController<Moment>{
|
||||
player.y = core.worldy()+10;
|
||||
|
||||
items.put(Item.stone, 20);
|
||||
|
||||
if(get(UI.class).about != null)
|
||||
get(UI.class).updateItems();
|
||||
}
|
||||
|
||||
public void coreDestroyed(){
|
||||
//TODO "you lose" message or something
|
||||
Effects.shake(5, 6);
|
||||
for(int i = 0; i < 16; i ++){
|
||||
Timers.run(i*2, ()->{
|
||||
@ -131,7 +139,10 @@ public class Moment extends ModuleController<Moment>{
|
||||
}
|
||||
|
||||
void generate(){
|
||||
spawnpoints.clear();
|
||||
Pathfind.reset();
|
||||
Generator.generate(tiles, "map");
|
||||
Pathfind.updatePath();
|
||||
core.setBlock(TileType.core);
|
||||
int x = core.x, y = core.y;
|
||||
|
||||
@ -174,7 +185,14 @@ public class Moment extends ModuleController<Moment>{
|
||||
}
|
||||
|
||||
wave ++;
|
||||
wavetime = wavespace;
|
||||
|
||||
wavetime = waveSpacing();
|
||||
}
|
||||
|
||||
public float waveSpacing(){
|
||||
int scale = Settings.getInt("difficulty");
|
||||
float out = (scale == 0 ? 2f : scale == 1f ? 1f : 0.5f);
|
||||
return wavespace*out;
|
||||
}
|
||||
|
||||
public Tile tile(int x, int y){
|
||||
|
@ -12,9 +12,7 @@ import io.anuke.moment.entities.Enemy;
|
||||
import io.anuke.moment.resource.*;
|
||||
import io.anuke.moment.world.Tile;
|
||||
import io.anuke.moment.world.TileType;
|
||||
import io.anuke.ucore.core.Draw;
|
||||
import io.anuke.ucore.core.UGraphics;
|
||||
import io.anuke.ucore.core.UInput;
|
||||
import io.anuke.ucore.core.*;
|
||||
import io.anuke.ucore.modules.SceneModule;
|
||||
import io.anuke.ucore.scene.builders.*;
|
||||
import io.anuke.ucore.scene.style.Styles;
|
||||
@ -107,6 +105,10 @@ public class UI extends SceneModule<Moment>{
|
||||
return (i / 4f) + "x";
|
||||
});
|
||||
|
||||
prefs.sliderPref("difficulty", "Difficulty", 1, 0, 2, i -> {
|
||||
return i == 0 ? "Easy" : i == 1 ? "Normal" : "Hard";
|
||||
});
|
||||
|
||||
|
||||
prefs.checkPref("fps", "Show FPS", false);
|
||||
|
||||
@ -116,7 +118,7 @@ public class UI extends SceneModule<Moment>{
|
||||
about.getContentTable().add("Made by Anuken for the" + "\nGDL Metal Monstrosity jam." + "\nTools used:");
|
||||
about.addCloseButton();
|
||||
|
||||
restart = new Dialog("Your core was destroyed.", "dialog");
|
||||
restart = new Dialog("The core was destroyed.", "dialog");
|
||||
restart.content().add("You lasted until wave [GREEN]" + main.wave + "[].").pad(6);
|
||||
restart.getButtonTable().addButton("Back to menu", ()->{
|
||||
restart.hide();
|
||||
@ -348,7 +350,7 @@ public class UI extends SceneModule<Moment>{
|
||||
|
||||
Label fps = new Label("");
|
||||
fps.update(()->{
|
||||
fps.setText(Gdx.graphics.getFramesPerSecond() + " FPS");
|
||||
fps.setText(Settings.getBool("fps") ? (Gdx.graphics.getFramesPerSecond() + " FPS") : "");
|
||||
});
|
||||
row();
|
||||
add(fps);
|
||||
|
@ -46,6 +46,10 @@ public class Pathfind{
|
||||
|
||||
}
|
||||
|
||||
static public void reset(){
|
||||
paths.clear();
|
||||
}
|
||||
|
||||
static public void updatePath(){
|
||||
if(paths.size == 0){
|
||||
for(int i = 0; i < Moment.i.spawnpoints.size; i ++){
|
||||
|
Loading…
Reference in New Issue
Block a user