More UI changes, made weapons usable, fixed ammo for turret types
This commit is contained in:
@@ -41,6 +41,7 @@ public class Control extends Module{
|
||||
Array<EnemySpawn> spawns = new Array<>();
|
||||
int wave = 1;
|
||||
float wavetime;
|
||||
float extrawavetime;
|
||||
int enemies = 0;
|
||||
|
||||
float respawntime;
|
||||
@@ -79,7 +80,8 @@ public class Control extends Module{
|
||||
"down", Keys.S,
|
||||
"right", Keys.D,
|
||||
"rotate", Keys.R,
|
||||
"menu", Gdx.app.getType() == ApplicationType.Android ? Keys.BACK : Keys.ESCAPE
|
||||
"menu", Gdx.app.getType() == ApplicationType.Android ? Keys.BACK : Keys.ESCAPE,
|
||||
"pause", Keys.SPACE
|
||||
);
|
||||
|
||||
Settings.loadAll("io.anuke.moment");
|
||||
@@ -127,6 +129,7 @@ public class Control extends Module{
|
||||
|
||||
);
|
||||
|
||||
//TODO remove this debugging
|
||||
for(int i = 1; i < 60; i ++){
|
||||
UCore.log("\n\n--WAVE " + i);
|
||||
printEnemies(i);
|
||||
@@ -143,6 +146,7 @@ public class Control extends Module{
|
||||
player.weapon = weapons.first();
|
||||
|
||||
wave = 1;
|
||||
extrawavetime = maxwavespace;
|
||||
wavetime = waveSpacing();
|
||||
Entities.clear();
|
||||
enemies = 0;
|
||||
@@ -196,6 +200,7 @@ public class Control extends Module{
|
||||
this.wave = wave;
|
||||
this.wavetime = wavetime;
|
||||
this.enemies = enemies;
|
||||
this.extrawavetime = maxwavespace;
|
||||
}
|
||||
|
||||
void runWave(){
|
||||
@@ -241,6 +246,7 @@ public class Control extends Module{
|
||||
}
|
||||
|
||||
wavetime = waveSpacing();
|
||||
extrawavetime = maxwavespace;
|
||||
}
|
||||
|
||||
void printEnemies(int wave){
|
||||
@@ -320,10 +326,6 @@ public class Control extends Module{
|
||||
public void update(){
|
||||
|
||||
if(debug){
|
||||
|
||||
if(Inputs.keyUp(Keys.SPACE))
|
||||
Effects.sound("shoot", World.core.worldx(), World.core.worldy());
|
||||
|
||||
if(Inputs.keyUp(Keys.O)){
|
||||
Timers.mark();
|
||||
SaveIO.write(Gdx.files.local("mapsave.mins"));
|
||||
@@ -339,23 +341,23 @@ public class Control extends Module{
|
||||
|
||||
if(Inputs.keyUp(Keys.C)){
|
||||
for(Entity entity : Entities.all()){
|
||||
if(entity instanceof Enemy)
|
||||
if(entity instanceof Enemy){
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(Inputs.keyDown(Keys.SPACE)){
|
||||
Effects.shake(6, 4, Graphics.mouseWorld().x, Graphics.mouseWorld().y);
|
||||
}
|
||||
|
||||
if(Inputs.keyDown(Keys.Y)){
|
||||
new TestEnemy(0).set(player.x, player.y).add();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!GameState.is(State.menu)){
|
||||
|
||||
if(Inputs.keyUp("pause") && (GameState.is(State.paused) || GameState.is(State.playing))){
|
||||
GameState.set(GameState.is(State.playing) ? State.paused : State.playing);
|
||||
}
|
||||
|
||||
if(Inputs.keyUp("menu")){
|
||||
if(GameState.is(State.paused)){
|
||||
ui.hideMenu();
|
||||
@@ -381,21 +383,23 @@ public class Control extends Module{
|
||||
}
|
||||
}
|
||||
|
||||
extrawavetime -= delta();
|
||||
|
||||
if(enemies <= 0){
|
||||
wavetime -= delta();
|
||||
}
|
||||
|
||||
if(wavetime <= 0 || (debug && Inputs.keyUp(Keys.F))){
|
||||
if(wavetime <= 0 || (debug && Inputs.keyUp(Keys.F)) || extrawavetime <= 0){
|
||||
runWave();
|
||||
}
|
||||
|
||||
Entities.update();
|
||||
|
||||
if(!android){
|
||||
Input.doInput();
|
||||
}else{
|
||||
AndroidInput.doInput();
|
||||
}
|
||||
}
|
||||
|
||||
if(!android){
|
||||
Input.doInput();
|
||||
}else{
|
||||
AndroidInput.doInput();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,6 +145,13 @@ public class EffectLoader{
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
Effects.create("railsmoke", 30, e -> {
|
||||
Draw.color(Color.LIGHT_GRAY, Color.WHITE, e.ifract());
|
||||
float size = e.fract()*4f;
|
||||
Draw.rect("circle", e.x, e.y, size, size);
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
Effects.create("spawn", 23, e -> {
|
||||
Draw.thickness(2f);
|
||||
Draw.color(Hue.mix(Color.DARK_GRAY, Color.SCARLET, e.ifract()));
|
||||
|
||||
@@ -32,8 +32,9 @@ public class Mindustry extends ModuleCore {
|
||||
}
|
||||
|
||||
if(!GameState.is(State.paused)){
|
||||
Inputs.update();
|
||||
Timers.update();
|
||||
}
|
||||
|
||||
Inputs.update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import io.anuke.ucore.modules.SceneModule;
|
||||
import io.anuke.ucore.scene.actions.Actions;
|
||||
import io.anuke.ucore.scene.builders.*;
|
||||
import io.anuke.ucore.scene.ui.*;
|
||||
import io.anuke.ucore.scene.ui.Window.WindowStyle;
|
||||
import io.anuke.ucore.scene.ui.layout.*;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
@@ -112,6 +113,7 @@ public class UI extends SceneModule{
|
||||
levels = new LevelDialog();
|
||||
|
||||
prefs = new SettingsDialog();
|
||||
prefs.setStyle(Core.skin.get("dialog", WindowStyle.class));
|
||||
|
||||
menu = new MenuDialog();
|
||||
|
||||
@@ -125,6 +127,15 @@ public class UI extends SceneModule{
|
||||
prefs.checkPref("tutorial", "Show tutorial Window", true);
|
||||
prefs.checkPref("fps", "Show FPS", false);
|
||||
prefs.checkPref("noshadows", "Disable shadows", false);
|
||||
|
||||
prefs.hidden(()->{
|
||||
GameState.set(State.playing);
|
||||
});
|
||||
|
||||
prefs.shown(()->{
|
||||
GameState.set(State.paused);
|
||||
menu.hide();
|
||||
});
|
||||
|
||||
keys = new KeybindDialog();
|
||||
|
||||
@@ -216,7 +227,9 @@ public class UI extends SceneModule{
|
||||
ImageButton image = new ImageButton(Draw.region(r.result.name()), "select");
|
||||
|
||||
image.clicked(()->{
|
||||
if(Inventory.hasItems(r.requirements)){
|
||||
if(player.recipe == r){
|
||||
player.recipe = null;
|
||||
}else{
|
||||
player.recipe = r;
|
||||
updateRecipe();
|
||||
}
|
||||
@@ -228,8 +241,8 @@ public class UI extends SceneModule{
|
||||
image.update(()->{
|
||||
|
||||
boolean has = Inventory.hasItems(r.requirements);
|
||||
image.setDisabled(!has);
|
||||
image.setChecked(player.recipe == r && has);
|
||||
//image.setDisabled(!has);
|
||||
image.setChecked(player.recipe == r);
|
||||
//image.setTouchable(has ? Touchable.enabled : Touchable.disabled);
|
||||
image.getImage().setColor(has ? Color.WHITE : Color.GRAY);
|
||||
});
|
||||
@@ -283,16 +296,23 @@ public class UI extends SceneModule{
|
||||
float isize = Unit.dp.inPixels(40);
|
||||
|
||||
new imagebutton("icon-menu", isize, ()->{
|
||||
GameState.set(State.paused);
|
||||
showMenu();
|
||||
});
|
||||
|
||||
new imagebutton("icon-settings", isize, ()->{
|
||||
GameState.set(State.paused);
|
||||
prefs.show();
|
||||
});
|
||||
|
||||
new imagebutton("icon-pause", isize, ()->{
|
||||
//TODO pause
|
||||
});
|
||||
GameState.set(GameState.is(State.paused) ? State.playing : State.paused);
|
||||
}){{
|
||||
get().update(()->{
|
||||
get().getStyle().imageUp = Core.skin.getDrawable(GameState.is(State.paused) ? "icon-play" : "icon-pause");
|
||||
});
|
||||
}};
|
||||
}}.end();
|
||||
|
||||
row();
|
||||
@@ -306,6 +326,16 @@ public class UI extends SceneModule{
|
||||
add(fps).size(-1);
|
||||
|
||||
}}.end();
|
||||
|
||||
//paused table
|
||||
new table(){{
|
||||
visible(()->GameState.is(State.paused));
|
||||
atop();
|
||||
|
||||
new table("pane"){{
|
||||
new label("[orange]< paused >").scale(0.75f).pad(6);
|
||||
}}.end();
|
||||
}}.end();
|
||||
|
||||
//wave table...
|
||||
new table(){{
|
||||
@@ -431,7 +461,7 @@ public class UI extends SceneModule{
|
||||
scene.add(tools);
|
||||
|
||||
tools.setVisible(()->{
|
||||
return !GameState.is(State.menu) && android && player.recipe != null;
|
||||
return !GameState.is(State.menu) && android && player.recipe != null && Inventory.hasItems(player.recipe.requirements);
|
||||
});
|
||||
|
||||
tools.update(()->{
|
||||
@@ -488,7 +518,7 @@ public class UI extends SceneModule{
|
||||
reqlabel.setText(text);
|
||||
});
|
||||
|
||||
requirements.add(reqlabel);
|
||||
requirements.add(reqlabel).left();
|
||||
requirements.row();
|
||||
}
|
||||
|
||||
@@ -512,7 +542,7 @@ public class UI extends SceneModule{
|
||||
if(weapon != player.weapon)
|
||||
button.setColor(Color.GRAY);
|
||||
|
||||
weapontable.add(button).size(48, 52);
|
||||
weapontable.add(button).size(52, 56);
|
||||
|
||||
Table tiptable = new Table();
|
||||
String description = weapon.description;
|
||||
@@ -532,6 +562,10 @@ public class UI extends SceneModule{
|
||||
button.addListener(tip);
|
||||
|
||||
}
|
||||
|
||||
weapontable.addIButton("icon-menu", 8*3, ()->{
|
||||
upgrades.show();
|
||||
}).size(52, 56);
|
||||
}
|
||||
|
||||
public void showLoading(){
|
||||
|
||||
@@ -15,6 +15,8 @@ public class Vars{
|
||||
public static final float respawnduration = 60*4;
|
||||
//time between waves in frames
|
||||
public static final float wavespace = 35*60*(android ? 2 : 1);
|
||||
//waves can last no longer than 6 minutes, otherwise the next one spawns
|
||||
public static final float maxwavespace = 60*60*6;
|
||||
//how far away from spawn points the player can't place blocks
|
||||
public static final float enemyspawnspace = 65;
|
||||
//scale of the font
|
||||
|
||||
@@ -34,9 +34,16 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
|
||||
sniper = new BulletType(3f, 20){
|
||||
public void draw(Bullet b){
|
||||
Draw.color(Color.LIGHT_GRAY);
|
||||
Draw.rect("bullet", b.x, b.y, b.angle());
|
||||
Draw.thick(1f);
|
||||
Draw.lineAngleCenter(b.x, b.y, b.angle(), 3f);
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
public void update(Bullet b){
|
||||
if(Timers.get(b, "smoke", 4)){
|
||||
Effects.effect("railsmoke", b.x, b.y);
|
||||
}
|
||||
}
|
||||
},
|
||||
shell = new BulletType(1.1f, 80){
|
||||
{
|
||||
|
||||
@@ -14,7 +14,6 @@ import io.anuke.mindustry.world.World;
|
||||
import io.anuke.mindustry.world.blocks.Blocks;
|
||||
import io.anuke.mindustry.world.blocks.ProductionBlocks;
|
||||
import io.anuke.ucore.core.*;
|
||||
import io.anuke.ucore.scene.utils.Cursors;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
public class AndroidInput extends InputAdapter{
|
||||
@@ -87,11 +86,6 @@ public class AndroidInput extends InputAdapter{
|
||||
for(ItemStack stack : player.recipe.requirements){
|
||||
Inventory.removeItem(stack);
|
||||
}
|
||||
|
||||
if(!Inventory.hasItems(player.recipe.requirements)){
|
||||
player.recipe = null;
|
||||
Cursors.restoreCursor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,9 @@ import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.input.GestureDetector.GestureAdapter;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
|
||||
import io.anuke.mindustry.GameState;
|
||||
import io.anuke.mindustry.GameState.State;
|
||||
import io.anuke.mindustry.Inventory;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.World;
|
||||
import io.anuke.mindustry.world.blocks.Blocks;
|
||||
@@ -22,7 +25,7 @@ public class GestureHandler extends GestureAdapter{
|
||||
public boolean longPress(float x, float y){
|
||||
Tile tile = World.cursorTile();
|
||||
player.breaktime += Timers.delta();
|
||||
if(player.breaktime >= tile.block().breaktime){
|
||||
if(!GameState.is(State.menu) && player.breaktime >= tile.block().breaktime){
|
||||
Effects.effect("break", tile.worldx(), tile.worldy());
|
||||
Effects.shake(3f, 1f);
|
||||
tile.setBlock(Blocks.air);
|
||||
@@ -34,7 +37,7 @@ public class GestureHandler extends GestureAdapter{
|
||||
|
||||
@Override
|
||||
public boolean pan(float x, float y, float deltaX, float deltaY){
|
||||
if(player.recipe == null){
|
||||
if(player.recipe == null || !Inventory.hasItems(player.recipe.requirements)){
|
||||
player.x -= deltaX*Core.camera.zoom/Core.cameraScale;
|
||||
player.y += deltaY*Core.camera.zoom/Core.cameraScale;
|
||||
}else{
|
||||
|
||||
@@ -42,11 +42,12 @@ public class Input{
|
||||
|
||||
//TODO restore cursor when requirements are back
|
||||
|
||||
for(int i = 0; i < 9; i ++)
|
||||
for(int i = 0; i < 9; i ++){
|
||||
if(Inputs.keyUp(Keys.valueOf(""+(i+1))) && i < control.getWeapons().size){
|
||||
player.weapon = control.getWeapons().get(i);
|
||||
ui.updateWeapons();
|
||||
}
|
||||
}
|
||||
|
||||
if(Inputs.buttonUp(Buttons.LEFT) && player.recipe != null &&
|
||||
World.validPlace(World.tilex(), World.tiley(), player.recipe.result) && !ui.hasMouse() &&
|
||||
|
||||
@@ -119,6 +119,7 @@ public class ProductionBlocks{
|
||||
input = Item.stone;
|
||||
inputLiquid = Liquid.water;
|
||||
output = Item.coal;
|
||||
health = 50;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -137,6 +138,7 @@ public class ProductionBlocks{
|
||||
liquidCapacity = 41f;
|
||||
purifyTime = 90;
|
||||
output = Item.titanium;
|
||||
health = 70;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -113,7 +113,8 @@ public class WeaponBlocks{
|
||||
range = 120;
|
||||
reload = 120f;
|
||||
bullet = BulletType.shell;
|
||||
ammo = Item.stone;
|
||||
ammo = Item.coal;
|
||||
ammoMultiplier = 5;
|
||||
health = 110;
|
||||
}
|
||||
},
|
||||
@@ -128,7 +129,7 @@ public class WeaponBlocks{
|
||||
range = 60;
|
||||
reload = 4f;
|
||||
damage = 9;
|
||||
ammo = Item.stone;
|
||||
ammo = Item.coal;
|
||||
health = 110;
|
||||
}
|
||||
},
|
||||
@@ -140,7 +141,7 @@ public class WeaponBlocks{
|
||||
range = 70;
|
||||
reload = 20f;
|
||||
bullet = BulletType.shell;
|
||||
ammo = Item.stone;
|
||||
ammo = Item.coal;
|
||||
health = 140;
|
||||
}
|
||||
|
||||
@@ -162,8 +163,9 @@ public class WeaponBlocks{
|
||||
range = 60f;
|
||||
reload = 3f;
|
||||
bullet = BulletType.plasmaflame;
|
||||
ammo = Item.stone;
|
||||
ammo = Item.coal;
|
||||
health = 180;
|
||||
ammoMultiplier = 40;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -39,7 +39,6 @@ public class Drill extends Block{
|
||||
|
||||
@Override
|
||||
public void drawOver(Tile tile){
|
||||
|
||||
if(tile.floor() != resource && resource != null){
|
||||
Draw.colorl(0.85f + Mathf.absin(Timers.time(), 6f, 0.15f));
|
||||
Draw.rect("cross", tile.worldx(), tile.worldy());
|
||||
|
||||
Reference in New Issue
Block a user