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