diff --git a/core/assets-raw/sprites/mechs/player.png b/core/assets-raw/sprites/mechs/mech-standard.png similarity index 100% rename from core/assets-raw/sprites/mechs/player.png rename to core/assets-raw/sprites/mechs/mech-standard.png diff --git a/core/assets/sprites/sprites.atlas b/core/assets/sprites/sprites.atlas index 83f43602cf..8d713650bc 100644 --- a/core/assets/sprites/sprites.atlas +++ b/core/assets/sprites/sprites.atlas @@ -664,7 +664,7 @@ blocks/oil index: -1 blocks/oiledge rotate: false - xy: 456, 423 + xy: 470, 423 size: 12, 12 orig: 12, 12 offset: 0, 0 @@ -1579,9 +1579,9 @@ laserend orig: 18, 18 offset: 0, 0 index: -1 -mechs/player +mechs/mech-standard rotate: false - xy: 470, 423 + xy: 456, 423 size: 12, 12 orig: 12, 12 offset: 0, 0 diff --git a/core/assets/sprites/sprites.png b/core/assets/sprites/sprites.png index d39424c80a..5238973934 100644 Binary files a/core/assets/sprites/sprites.png and b/core/assets/sprites/sprites.png differ diff --git a/core/src/io/anuke/mindustry/core/Control.java b/core/src/io/anuke/mindustry/core/Control.java index 63dc8719f6..c9eaab991a 100644 --- a/core/src/io/anuke/mindustry/core/Control.java +++ b/core/src/io/anuke/mindustry/core/Control.java @@ -159,6 +159,14 @@ public class Control extends Module{ //multiplying by 2 so you start with more time in the beginning wavetime = waveSpacing()*2; + if(mode == GameMode.sandbox){ + for(Item type : Item.values()){ + items.put(type, 999999999); + } + } + + ui.updateItems(); + GameState.set(State.playing); } @@ -236,7 +244,7 @@ public class Control extends Module{ int index = i; float range = 12f; - Timers.run(index*50f, ()->{ + Timers.run(index*5f, ()->{ try{ Enemy enemy = ClassReflection.newInstance(spawn.type); enemy.set(tile.worldx() + Mathf.range(range), tile.worldy() + Mathf.range(range)); diff --git a/core/src/io/anuke/mindustry/core/Renderer.java b/core/src/io/anuke/mindustry/core/Renderer.java index 37ce907625..e1b5203697 100644 --- a/core/src/io/anuke/mindustry/core/Renderer.java +++ b/core/src/io/anuke/mindustry/core/Renderer.java @@ -409,7 +409,8 @@ public class Renderer extends RendererModule{ Draw.thickness(2f); Draw.linecrect(x + offset.x, y + offset.y, tilesize * player.recipe.result.width + si, tilesize * player.recipe.result.height + si); - player.recipe.result.drawPlace(tilex, tiley, valid); + player.recipe.result.drawPlace(tilex, tiley, player.rotation, valid); + Draw.thickness(2f); if(player.recipe.result.rotate){ Draw.color("orange"); @@ -420,7 +421,7 @@ public class Renderer extends RendererModule{ Draw.thickness(1f); Draw.color("scarlet"); for(SpawnPoint spawn : control.getSpawnPoints()){ - Draw.dashcircle(spawn.start.worldx(), spawn.start.worldy(), enemyspawnspace); + Draw.dashCircle(spawn.start.worldx(), spawn.start.worldy(), enemyspawnspace); } if(valid) diff --git a/core/src/io/anuke/mindustry/core/UI.java b/core/src/io/anuke/mindustry/core/UI.java index a4c95044a7..cfe5ab9774 100644 --- a/core/src/io/anuke/mindustry/core/UI.java +++ b/core/src/io/anuke/mindustry/core/UI.java @@ -379,6 +379,10 @@ public class UI extends SceneModule{ about.show(); } + public boolean onDialog(){ + return scene.getKeyboardFocus() instanceof Dialog; + } + public void showUpgrades(){ upgrades.show(); } diff --git a/core/src/io/anuke/mindustry/entities/BulletType.java b/core/src/io/anuke/mindustry/entities/BulletType.java index 23818dfb76..698b8f35d2 100644 --- a/core/src/io/anuke/mindustry/entities/BulletType.java +++ b/core/src/io/anuke/mindustry/entities/BulletType.java @@ -132,10 +132,10 @@ public abstract class BulletType extends BaseBulletType{ DamageArea.damage(!(b.owner instanceof Enemy), b.x, b.y, 25f, (int)(damage * 2f/3f)); } }, - titanshell = new BulletType(1.8f, 60){ + titanshell = new BulletType(1.8f, 40){ { lifetime = 70f; - hitsize = 11f; + hitsize = 15f; } public void draw(Bullet b){ diff --git a/core/src/io/anuke/mindustry/entities/EnemySpawn.java b/core/src/io/anuke/mindustry/entities/EnemySpawn.java index 27805bc200..6ecabd473f 100644 --- a/core/src/io/anuke/mindustry/entities/EnemySpawn.java +++ b/core/src/io/anuke/mindustry/entities/EnemySpawn.java @@ -13,9 +13,11 @@ public class EnemySpawn{ /**The spacing, in waves, of spawns. 2 = spawns every other wave*/ protected int spacing = 1; /**How many waves need to pass after the start of this spawn for the tier to increase by one*/ - protected int tierscale = 15; + protected int tierscale = 14; /**How many less enemies there are, every time the tier increases*/ protected int tierscaleback = 1; + /**The tier this spawn starts at.*/ + protected int tier = 1; /**Maximum amount of enemies that spawn*/ protected int max = 17; /**How many waves need to pass before the amount of enemies increases by 1*/ @@ -35,6 +37,6 @@ public class EnemySpawn{ } public int tier(int wave, int lane){ - return Mathf.clamp(1 + (wave-after)/tierscale, 1, Enemy.maxtier); + return Mathf.clamp(tier + (wave-after)/tierscale, 1, Enemy.maxtier); } } diff --git a/core/src/io/anuke/mindustry/entities/Player.java b/core/src/io/anuke/mindustry/entities/Player.java index 4d051f6d63..1ecbfa51b1 100644 --- a/core/src/io/anuke/mindustry/entities/Player.java +++ b/core/src/io/anuke/mindustry/entities/Player.java @@ -10,6 +10,7 @@ import com.badlogic.gdx.math.Vector2; import io.anuke.mindustry.Vars; import io.anuke.mindustry.entities.effect.Fx; import io.anuke.mindustry.input.Input; +import io.anuke.mindustry.resource.Mech; import io.anuke.mindustry.resource.Recipe; import io.anuke.mindustry.resource.Weapon; import io.anuke.ucore.core.*; @@ -18,6 +19,7 @@ import io.anuke.ucore.util.Angles; public class Player extends DestructibleEntity{ public Weapon weapon; + public Mech mech = Mech.standard; public float breaktime = 0; public Recipe recipe; @@ -50,9 +52,9 @@ public class Player extends DestructibleEntity{ @Override public void draw(){ if(Vars.snapCamera && Settings.getBool("smoothcam") && Settings.getBool("pixelate")){ - Draw.rect("player", (int)x, (int)y, direction.angle()-90); + Draw.rect("mech-"+mech.name(), (int)x, (int)y, direction.angle()-90); }else{ - Draw.rect("player", x, y, direction.angle()-90); + Draw.rect("mech-"+mech.name(), x, y, direction.angle()-90); } } diff --git a/core/src/io/anuke/mindustry/entities/TileEntity.java b/core/src/io/anuke/mindustry/entities/TileEntity.java index c78833f629..2e730f7cae 100644 --- a/core/src/io/anuke/mindustry/entities/TileEntity.java +++ b/core/src/io/anuke/mindustry/entities/TileEntity.java @@ -79,7 +79,7 @@ public class TileEntity extends Entity{ } public boolean collide(Bullet other){ - return other.owner instanceof Enemy; + return other.owner instanceof Enemy; //TODO } @Override diff --git a/core/src/io/anuke/mindustry/entities/WaveCreator.java b/core/src/io/anuke/mindustry/entities/WaveCreator.java index bdc7a1fc6b..9833ccaf9b 100644 --- a/core/src/io/anuke/mindustry/entities/WaveCreator.java +++ b/core/src/io/anuke/mindustry/entities/WaveCreator.java @@ -53,11 +53,18 @@ public class WaveCreator{ amount = 1; }}, + new EnemySpawn(Enemy.class){{ + scaling = 3; + after = 8; + spacing = 4; + tier = 2; + }}, + new EnemySpawn(TitanEnemy.class){{ after = 6; amount = 2; spacing = 5; - scaling = 3; + scaling = 2; }}, new EnemySpawn(FlamerEnemy.class){{ @@ -67,6 +74,13 @@ public class WaveCreator{ scaling = 2; }}, + new EnemySpawn(EmpEnemy.class){{ + after = 15; + amount = 1; + spacing = 5; + scaling = 1; + }}, + new EnemySpawn(BlastEnemy.class){{ after = 4 + 5 + 5; amount = 3; diff --git a/core/src/io/anuke/mindustry/entities/enemies/BlastEnemy.java b/core/src/io/anuke/mindustry/entities/enemies/BlastEnemy.java index 8b174a5b68..3ef4bf68c2 100644 --- a/core/src/io/anuke/mindustry/entities/enemies/BlastEnemy.java +++ b/core/src/io/anuke/mindustry/entities/enemies/BlastEnemy.java @@ -27,10 +27,20 @@ public class BlastEnemy extends Enemy{ } if(target != null && target.distanceTo(this) < range){ - Bullet b = new Bullet(BulletType.blast, this, x, y, 0).add(); - b.damage = BulletType.blast.damage + (tier-1) * 40; - damage(999); + explode(); } } + + @Override + public void onDeath(){ + super.onDeath(); + explode(); + } + + void explode(){ + Bullet b = new Bullet(BulletType.blast, this, x, y, 0).add(); + b.damage = BulletType.blast.damage + (tier-1) * 40; + damage(999); + } } diff --git a/core/src/io/anuke/mindustry/entities/enemies/EmpEnemy.java b/core/src/io/anuke/mindustry/entities/enemies/EmpEnemy.java index 5215719e37..fc5c3abf03 100644 --- a/core/src/io/anuke/mindustry/entities/enemies/EmpEnemy.java +++ b/core/src/io/anuke/mindustry/entities/enemies/EmpEnemy.java @@ -6,8 +6,8 @@ public class EmpEnemy extends Enemy{ public EmpEnemy() { - speed = 0.27f; - reload = 70; + speed = 0.3f; + reload = 60; maxhealth = 210; range = 80f; bullet = BulletType.emp; diff --git a/core/src/io/anuke/mindustry/entities/enemies/Enemy.java b/core/src/io/anuke/mindustry/entities/enemies/Enemy.java index 88d4660797..50ac0286b1 100644 --- a/core/src/io/anuke/mindustry/entities/enemies/Enemy.java +++ b/core/src/io/anuke/mindustry/entities/enemies/Enemy.java @@ -175,7 +175,7 @@ public class Enemy extends DestructibleEntity{ } maxhealth *= tier; - speed += 0.04f * tier + Mathf.range(0.1f); + speed += 0.04f * tier /*+ Mathf.range(0.1f)*/; reload /= Math.max(tier / 1.5f, 1f); range += tier * 5; speed = Math.max(speed, 0.07f); diff --git a/core/src/io/anuke/mindustry/entities/enemies/FortressEnemy.java b/core/src/io/anuke/mindustry/entities/enemies/FortressEnemy.java index a925814e1c..e87a602ade 100644 --- a/core/src/io/anuke/mindustry/entities/enemies/FortressEnemy.java +++ b/core/src/io/anuke/mindustry/entities/enemies/FortressEnemy.java @@ -15,9 +15,9 @@ public class FortressEnemy extends Enemy{ public FortressEnemy() { - speed = 0.2f; + speed = 0.25f; reload = 90; - maxhealth = 700; + maxhealth = 800; range = 70f; bullet = BulletType.yellowshell; hitbox.setSize(10f); diff --git a/core/src/io/anuke/mindustry/entities/enemies/HealerEnemy.java b/core/src/io/anuke/mindustry/entities/enemies/HealerEnemy.java index 886662d797..96ae2578bb 100644 --- a/core/src/io/anuke/mindustry/entities/enemies/HealerEnemy.java +++ b/core/src/io/anuke/mindustry/entities/enemies/HealerEnemy.java @@ -15,9 +15,9 @@ public class HealerEnemy extends Enemy{ public HealerEnemy() { - speed = 0.2f; - reload = 14; - maxhealth = 130; + speed = 0.25f; + reload = 10; + maxhealth = 200; range = 90f; bullet = BulletType.shot; range = 30f; diff --git a/core/src/io/anuke/mindustry/entities/enemies/TitanEnemy.java b/core/src/io/anuke/mindustry/entities/enemies/TitanEnemy.java index d7c78920d5..8b6d6cbfab 100644 --- a/core/src/io/anuke/mindustry/entities/enemies/TitanEnemy.java +++ b/core/src/io/anuke/mindustry/entities/enemies/TitanEnemy.java @@ -9,9 +9,9 @@ public class TitanEnemy extends Enemy{ public TitanEnemy() { - speed = 0.22f; + speed = 0.26f; reload = 30; - maxhealth = 421; + maxhealth = 430; range = 60f; bullet = BulletType.small; hitbox.setSize(7f); diff --git a/core/src/io/anuke/mindustry/input/Input.java b/core/src/io/anuke/mindustry/input/Input.java index 7dc2c67d96..0479e879bb 100644 --- a/core/src/io/anuke/mindustry/input/Input.java +++ b/core/src/io/anuke/mindustry/input/Input.java @@ -25,7 +25,7 @@ public class Input{ //player is dead if(player.health <= 0) return; - if(Inputs.scrolled() && GameState.is(State.playing)){ + if(Inputs.scrolled() && !GameState.is(State.menu) && !Vars.ui.onDialog()){ Vars.renderer.scaleCamera(Inputs.scroll()); } diff --git a/core/src/io/anuke/mindustry/resource/Mech.java b/core/src/io/anuke/mindustry/resource/Mech.java index 944bf8d5d4..7080cb7ec4 100644 --- a/core/src/io/anuke/mindustry/resource/Mech.java +++ b/core/src/io/anuke/mindustry/resource/Mech.java @@ -1,16 +1,15 @@ package io.anuke.mindustry.resource; public enum Mech{ - normal("default"), - scout("scout"){{ + standard, + scout{{ }}; - public final String name; public float speedBoost = 1f, damageBoost = 1f; public int regenRate = 10; public int health = 20; - private Mech(String name){ - this.name = name; + private Mech(){ + } } diff --git a/core/src/io/anuke/mindustry/resource/Recipe.java b/core/src/io/anuke/mindustry/resource/Recipe.java index 06c6295380..d1307dcc3a 100644 --- a/core/src/io/anuke/mindustry/resource/Recipe.java +++ b/core/src/io/anuke/mindustry/resource/Recipe.java @@ -43,8 +43,8 @@ public enum Recipe{ mortarturret(weapon, WeaponBlocks.mortarturret, stack(Item.steel, 20), stack(Item.titanium, 15)), teslaturret(weapon, WeaponBlocks.teslaturret, stack(Item.steel, 10), stack(Item.titanium, 15), stack(Item.dirium, 15)), plasmaturret(weapon, WeaponBlocks.plasmaturret, stack(Item.steel, 10), stack(Item.titanium, 10), stack(Item.dirium, 15)), - chainturret(weapon, WeaponBlocks.chainturret, stack(Item.steel, 35), stack(Item.titanium, 25), stack(Item.dirium, 35)), - titanturret(weapon, WeaponBlocks.titanturret, stack(Item.steel, 50), stack(Item.titanium, 45), stack(Item.dirium, 55)), + chainturret(weapon, WeaponBlocks.chainturret, stack(Item.steel, 50), stack(Item.titanium, 25), stack(Item.dirium, 35)), + titanturret(weapon, WeaponBlocks.titanturret, stack(Item.steel, 70), stack(Item.titanium, 50), stack(Item.dirium, 55)), smelter(crafting, ProductionBlocks.smelter, stack(Item.stone, 40), stack(Item.iron, 40)), crucible(crafting, ProductionBlocks.crucible, stack(Item.titanium, 40), stack(Item.steel, 40)), diff --git a/core/src/io/anuke/mindustry/ui/LoadDialog.java b/core/src/io/anuke/mindustry/ui/LoadDialog.java index 5baf7f27d9..a094b7d3dc 100644 --- a/core/src/io/anuke/mindustry/ui/LoadDialog.java +++ b/core/src/io/anuke/mindustry/ui/LoadDialog.java @@ -1,8 +1,6 @@ package io.anuke.mindustry.ui; import com.badlogic.gdx.utils.Align; -import com.badlogic.gdx.utils.Timer; -import com.badlogic.gdx.utils.Timer.Task; import io.anuke.mindustry.Vars; import io.anuke.mindustry.core.GameState; @@ -19,19 +17,18 @@ import io.anuke.ucore.scene.ui.layout.Unit; //TODO unified save/load dialogs public class LoadDialog extends FloatingDialog{ ScrollPane pane; - - public LoadDialog(){ + + public LoadDialog() { this("Load Game"); } - + public LoadDialog(String title) { super(title); setup(); - shown(() -> { setup(); - Timers.runTask(2f, ()-> Core.scene.setScrollFocus(pane)); + Timers.runTask(2f, () -> Core.scene.setScrollFocus(pane)); }); addCloseButton(); @@ -42,11 +39,11 @@ public class LoadDialog extends FloatingDialog{ content().add("Select a save slot.").padBottom(2); content().row(); - + Table slots = new Table(); pane = new ScrollPane(slots); pane.setFadeScrollBars(false); - + slots.padRight(Unit.dp.inPixels(24)); for(int i = 0; i < Vars.saveSlots; i++){ @@ -55,14 +52,12 @@ public class LoadDialog extends FloatingDialog{ TextButton button = new TextButton("[accent]Slot " + (i + 1)); button.pad(Unit.dp.inPixels(12)); button.getLabelCell().top().left().growX(); - + button.row(); - - Label info = new Label("[gray]" + (!SaveIO.isSaveValid(i) ? "" : SaveIO.getMode(slot) + ", " + - SaveIO.getMap(slot) + - ", Wave " + SaveIO.getWave(slot) + "\nLast Saved: " + SaveIO.getTimeString(i))); + + Label info = new Label("[gray]" + (!SaveIO.isSaveValid(i) ? "" : SaveIO.getMode(slot) + ", " + SaveIO.getMap(slot) + ", Wave " + SaveIO.getWave(slot) + "\nLast Saved: " + SaveIO.getTimeString(i))); info.setAlignment(Align.center, Align.center); - + button.add(info).padBottom(3).padTop(7); button.row(); //button.addImage("white", Color.GRAY) @@ -73,37 +68,33 @@ public class LoadDialog extends FloatingDialog{ slots.add(button).size(404, 104).pad(4).units(Unit.dp); slots.row(); } - + content().add(pane); } - + public void modifyButton(TextButton button, int slot){ button.setDisabled(!SaveIO.isSaveValid(slot)); button.clicked(() -> { if(!button.isDisabled()){ Vars.ui.showLoading(); - Timer.schedule(new Task(){ - @Override - public void run(){ - Vars.ui.hideLoading(); - hide(); - try{ - SaveIO.loadFromSlot(slot); - GameState.set(State.playing); - Vars.ui.hideMenu(); - }catch(Exception e){ - e.printStackTrace(); - Vars.ui.hideMenu(); - GameState.set(State.menu); - Vars.control.reset(); - Vars.ui.showError("[orange]Save file corrupted or invalid!"); - return; - } - + Timers.runTask(3f, () -> { + Vars.ui.hideLoading(); + hide(); + try{ + SaveIO.loadFromSlot(slot); + GameState.set(State.playing); + Vars.ui.hideMenu(); + }catch(Exception e){ + e.printStackTrace(); + Vars.ui.hideMenu(); + GameState.set(State.menu); + Vars.control.reset(); + Vars.ui.showError("[orange]Save file corrupted or invalid!"); + return; } - }, 3f/60f); + }); } }); } diff --git a/core/src/io/anuke/mindustry/ui/SaveDialog.java b/core/src/io/anuke/mindustry/ui/SaveDialog.java index 733fdf5f7a..64140e40ed 100644 --- a/core/src/io/anuke/mindustry/ui/SaveDialog.java +++ b/core/src/io/anuke/mindustry/ui/SaveDialog.java @@ -1,11 +1,10 @@ package io.anuke.mindustry.ui; -import com.badlogic.gdx.utils.Timer; -import com.badlogic.gdx.utils.Timer.Task; import com.badlogic.gdx.utils.reflect.ClassReflection; import io.anuke.mindustry.Vars; import io.anuke.mindustry.io.SaveIO; +import io.anuke.ucore.core.Timers; import io.anuke.ucore.scene.ui.ConfirmDialog; import io.anuke.ucore.scene.ui.TextButton; import io.anuke.ucore.scene.ui.layout.Cell; @@ -13,48 +12,44 @@ import io.anuke.ucore.scene.ui.layout.Unit; //TODO unified save/load dialogs public class SaveDialog extends LoadDialog{ - - public SaveDialog(){ + + public SaveDialog() { super("Save Game"); } - + @Override public void modifyButton(TextButton button, int slot){ - button.clicked(()->{ + button.clicked(() -> { if(SaveIO.isSaveValid(slot)){ - new ConfirmDialog("Overwrite", "Are you sure you want to overwrite\nthis save slot?", ()->{ + new ConfirmDialog("Overwrite", "Are you sure you want to overwrite\nthis save slot?", () -> { save(slot); - }){{ - content().pad(16); - for(Cell cell : getButtonTable().getCells()) - cell.size(110, 45).pad(4).units(Unit.dp); - }}.show(); + }){ + { + content().pad(16); + for(Cell cell : getButtonTable().getCells()) + cell.size(110, 45).pad(4).units(Unit.dp); + } + }.show(); }else{ save(slot); } }); } - + void save(int slot){ Vars.ui.showLoading("[orange]Saving..."); - - Timer.schedule(new Task(){ - @Override - public void run(){ - hide(); - Vars.ui.hideLoading(); - try{ - SaveIO.saveToSlot(slot); - }catch (Throwable e){ - e = (e.getCause() == null ? e : e.getCause()); - - Vars.ui.showError("[orange]Failed to save game!\n[white]" + - ClassReflection.getSimpleName(e.getClass()) + ": " + e.getMessage() + "\n" + - "at " + e.getStackTrace()[0].getFileName() + ":"+ e.getStackTrace()[0].getLineNumber()); - } - + + Timers.runTask(5f, () -> { + hide(); + Vars.ui.hideLoading(); + try{ + SaveIO.saveToSlot(slot); + }catch(Throwable e){ + e = (e.getCause() == null ? e : e.getCause()); + + Vars.ui.showError("[orange]Failed to save game!\n[white]" + ClassReflection.getSimpleName(e.getClass()) + ": " + e.getMessage() + "\n" + "at " + e.getStackTrace()[0].getFileName() + ":" + e.getStackTrace()[0].getLineNumber()); } - }, 5f/60f); + }); } } diff --git a/core/src/io/anuke/mindustry/ui/fragments/BlocksFragment.java b/core/src/io/anuke/mindustry/ui/fragments/BlocksFragment.java index e77c6ef22a..053ac5bc2f 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/BlocksFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/BlocksFragment.java @@ -101,7 +101,7 @@ public class BlocksFragment implements Fragment{ image.update(()->{ boolean canPlace = !control.getTutorial().active() || control.getTutorial().canPlace(); - boolean has = control.hasItems(r.requirements) && canPlace; + boolean has = (control.hasItems(r.requirements)) && canPlace; //image.setDisabled(!has); image.setChecked(player.recipe == r); image.setTouchable(canPlace ? Touchable.enabled : Touchable.disabled); diff --git a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java index 10c1a67fd4..34cf66d8f5 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java @@ -24,12 +24,14 @@ import io.anuke.ucore.scene.builders.label; import io.anuke.ucore.scene.builders.table; import io.anuke.ucore.scene.ui.Image; import io.anuke.ucore.scene.ui.Label; +import io.anuke.ucore.scene.ui.layout.Cell; import io.anuke.ucore.scene.ui.layout.Table; import io.anuke.ucore.scene.ui.layout.Unit; import io.anuke.ucore.util.Profiler; public class HudFragment implements Fragment{ private Table itemtable, respawntable; + private Cell itemcell; private Array tempItems = new Array<>(); public void build(){ @@ -63,6 +65,8 @@ public class HudFragment implements Fragment{ row(); itemtable = new table("button").end().top().left().fillX().size(-1).get(); + itemtable.setVisible(()-> control.getMode() != GameMode.sandbox); + itemcell = get().getCell(itemtable); get().setVisible(()->!GameState.is(State.menu)); @@ -167,6 +171,10 @@ public class HudFragment implements Fragment{ itemtable.clear(); itemtable.left(); + if(control.getMode() == GameMode.sandbox){ + return; + } + tempItems.clear(); for(Item item : control.getItems().keys()){ tempItems.add(item); @@ -174,8 +182,13 @@ public class HudFragment implements Fragment{ tempItems.sort(); for(Item stack : tempItems){ + int amount = control.getAmount(stack); + String formatted = Mindustry.formatter.format(amount); + if(amount > 99999999){ + formatted = "inf"; + } Image image = new Image(Draw.region("icon-" + stack.name())); - Label label = new Label("" + Mindustry.formatter.format(control.getAmount(stack))); + Label label = new Label(formatted); label.setFontScale(fontscale*1.5f); itemtable.add(image).size(8*3).units(Unit.dp); itemtable.add(label).left(); diff --git a/core/src/io/anuke/mindustry/world/Block.java b/core/src/io/anuke/mindustry/world/Block.java index eb4e2e8d0d..f4b9dd24fb 100644 --- a/core/src/io/anuke/mindustry/world/Block.java +++ b/core/src/io/anuke/mindustry/world/Block.java @@ -79,7 +79,7 @@ public class Block{ public void drawOver(Tile tile){} public void drawPixelOverlay(Tile tile){} - public void drawPlace(int x, int y, boolean valid){} + public void drawPlace(int x, int y, int rotation, boolean valid){} public void postInit(){} public void getStats(Array list){ diff --git a/core/src/io/anuke/mindustry/world/Generator.java b/core/src/io/anuke/mindustry/world/Generator.java index b6109f5243..6368a8e597 100644 --- a/core/src/io/anuke/mindustry/world/Generator.java +++ b/core/src/io/anuke/mindustry/world/Generator.java @@ -78,7 +78,7 @@ public class Generator{ if(floor == Blocks.stone || floor == Blocks.grass || floor == Blocks.blackstone || floor == Blocks.snow || floor == Blocks.sand){ - if(Noise.nnoise(x, y, 8, 1) > 0.2){ + if(Noise.nnoise(x, y, 8, 1) > 0.21){ floor = Blocks.iron; } @@ -86,7 +86,7 @@ public class Generator{ floor = Blocks.coal; } - if(Noise.nnoise(x + 9999, y + 9999, 8, 1) > 0.264){ + if(Noise.nnoise(x + 9999, y + 9999, 8, 1) > 0.27){ floor = Blocks.titanium; } diff --git a/core/src/io/anuke/mindustry/world/Tile.java b/core/src/io/anuke/mindustry/world/Tile.java index a520001be9..8023812382 100644 --- a/core/src/io/anuke/mindustry/world/Tile.java +++ b/core/src/io/anuke/mindustry/world/Tile.java @@ -207,8 +207,8 @@ public class Tile{ } public void changed(){ - if(entity != null && entity.added){ - entity.remove(); + if(entity != null){ + if(entity.added) entity.remove(); entity = null; } diff --git a/core/src/io/anuke/mindustry/world/World.java b/core/src/io/anuke/mindustry/world/World.java index f43180d32b..35c96e8692 100644 --- a/core/src/io/anuke/mindustry/world/World.java +++ b/core/src/io/anuke/mindustry/world/World.java @@ -326,7 +326,7 @@ public class World extends Module{ if(tile == null) return; - Block block = tile.block(); + Block block = tile.isLinked() ? tile.getLinked().block() : tile.block(); Recipe result = null; for(Recipe recipe : Recipe.values()){ @@ -420,7 +420,7 @@ public class World extends Module{ other = other.getLinked(); } - if(other == null || other.entity == null ||(tile != null && other.entity == tile.entity)) continue; + if(other == null || other.entity == null || (tile != null && other.entity == tile.entity)) continue; TileEntity e = other.entity; diff --git a/core/src/io/anuke/mindustry/world/blocks/DefenseBlocks.java b/core/src/io/anuke/mindustry/world/blocks/DefenseBlocks.java index 0ba7330681..c764d7c2c8 100644 --- a/core/src/io/anuke/mindustry/world/blocks/DefenseBlocks.java +++ b/core/src/io/anuke/mindustry/world/blocks/DefenseBlocks.java @@ -72,7 +72,7 @@ public class DefenseBlocks{ + "Uses small amounts of power."; formalName = "repair turret"; range = 30; - reload = 40f; + reload = 60f; health = 60; } }, @@ -83,7 +83,8 @@ public class DefenseBlocks{ + "Uses power."; formalName = "repair turret II"; range = 44; - reload = 20f; + reload = 30f; + powerUsed = 0.15f; health = 90; } }, diff --git a/core/src/io/anuke/mindustry/world/blocks/ProductionBlocks.java b/core/src/io/anuke/mindustry/world/blocks/ProductionBlocks.java index bfb64aff8f..1d120eb1eb 100644 --- a/core/src/io/anuke/mindustry/world/blocks/ProductionBlocks.java +++ b/core/src/io/anuke/mindustry/world/blocks/ProductionBlocks.java @@ -227,8 +227,8 @@ public class ProductionBlocks{ formalName = "thermal generator"; //TODO generateLiquid = Liquid.lava; - inputLiquid = 20f; - generatePower = 1f; + inputLiquid = 25f; + generatePower = 0.5f; powerCapacity = 40f; description = "Generates power from lava."; fullDescription = "Generates power from lava. Outputs power as lasers to its 4 sides."; diff --git a/core/src/io/anuke/mindustry/world/blocks/WeaponBlocks.java b/core/src/io/anuke/mindustry/world/blocks/WeaponBlocks.java index 3e315e9c0e..fdba3d7e5d 100644 --- a/core/src/io/anuke/mindustry/world/blocks/WeaponBlocks.java +++ b/core/src/io/anuke/mindustry/world/blocks/WeaponBlocks.java @@ -182,7 +182,7 @@ public class WeaponBlocks{ inaccuracy = 8f; formalName = "chain turret"; range = 80f; - reload = 7f; + reload = 8f; bullet = BulletType.chain; ammo = Item.uranium; health = 430; @@ -219,7 +219,7 @@ public class WeaponBlocks{ { formalName = "titan cannon"; range = 120f; - reload = 20f; + reload = 23f; bullet = BulletType.titanshell; ammo = Item.uranium; health = 800; diff --git a/core/src/io/anuke/mindustry/world/blocks/types/defense/PowerTurret.java b/core/src/io/anuke/mindustry/world/blocks/types/defense/PowerTurret.java index ec105ee656..c78702388b 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/defense/PowerTurret.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/defense/PowerTurret.java @@ -38,7 +38,7 @@ public class PowerTurret extends Turret implements PowerAcceptor{ Vector2 offset = getPlaceOffset(); Draw.color("green"); - Draw.dashcircle(tile.worldx() + offset.x, tile.worldy() + offset.y, range); + Draw.dashCircle(tile.worldx() + offset.x, tile.worldy() + offset.y, range); Draw.reset(); drawPowerBar(tile); diff --git a/core/src/io/anuke/mindustry/world/blocks/types/defense/RepairTurret.java b/core/src/io/anuke/mindustry/world/blocks/types/defense/RepairTurret.java index c7a08a8487..c696738a36 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/defense/RepairTurret.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/defense/RepairTurret.java @@ -42,6 +42,10 @@ public class RepairTurret extends PowerTurret{ return; } + if(entity.blockTarget != null && entity.blockTarget.dead){ + entity.blockTarget = null; + } + if(Timers.get(entity, "blocktarget", targetInterval)){ entity.blockTarget = Vars.world.findTileTarget(tile.worldx(), tile.worldy(), tile, range, true); } @@ -64,7 +68,7 @@ public class RepairTurret extends PowerTurret{ @Override public void drawPixelOverlay(Tile tile){ Draw.color("green"); - Draw.dashcircle(tile.worldx(), tile.worldy(), range); + Draw.dashCircle(tile.worldx(), tile.worldy(), range); Draw.reset(); drawPowerBar(tile); diff --git a/core/src/io/anuke/mindustry/world/blocks/types/defense/Turret.java b/core/src/io/anuke/mindustry/world/blocks/types/defense/Turret.java index b0cb9402f8..745fd289d3 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/defense/Turret.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/defense/Turret.java @@ -103,7 +103,7 @@ public class Turret extends Block{ Vector2 offset = getPlaceOffset(); Draw.color("green"); - Draw.dashcircle(tile.worldx() + offset.x, tile.worldy() + offset.y, range); + Draw.dashCircle(tile.worldx() + offset.x, tile.worldy() + offset.y, range); Draw.reset(); TurretEntity entity = tile.entity(); @@ -116,10 +116,10 @@ public class Turret extends Block{ } @Override - public void drawPlace(int x, int y, boolean valid){ + public void drawPlace(int x, int y, int rotation, boolean valid){ Draw.color(Color.PURPLE); Draw.thick(1f); - Draw.dashcircle(x*Vars.tilesize, y*Vars.tilesize, range); + Draw.dashCircle(x*Vars.tilesize, y*Vars.tilesize, range); } @Override diff --git a/core/src/io/anuke/mindustry/world/blocks/types/distribution/PowerBooster.java b/core/src/io/anuke/mindustry/world/blocks/types/distribution/PowerBooster.java index fab0f3f77f..5fb43a82ca 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/distribution/PowerBooster.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/distribution/PowerBooster.java @@ -25,7 +25,14 @@ public class PowerBooster extends Generator{ super.drawPixelOverlay(tile); Draw.color("yellow"); - Draw.dashcircle(tile.worldx(), tile.worldy(), powerRange * Vars.tilesize); + Draw.dashCircle(tile.worldx(), tile.worldy(), powerRange * Vars.tilesize); + Draw.reset(); + } + + @Override + public void drawPlace(int x, int y, int rotation, boolean valid){ + Draw.color("purple"); + Draw.dashCircle(x * Vars.tilesize, y * Vars.tilesize, laserRange * Vars.tilesize); Draw.reset(); } diff --git a/core/src/io/anuke/mindustry/world/blocks/types/production/Drill.java b/core/src/io/anuke/mindustry/world/blocks/types/production/Drill.java index f9a67be841..05225780bf 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/production/Drill.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/production/Drill.java @@ -45,7 +45,7 @@ public class Drill extends Block{ @Override public void drawOver(Tile tile){ - if(tile.floor() != resource && !(resource.drops.equals(tile.floor().drops)) && resource != null){ + if(tile.floor() != resource && resource != null && !(resource.drops.equals(tile.floor().drops))){ Draw.colorl(0.85f + Mathf.absin(Timers.time(), 6f, 0.15f)); Draw.rect("cross", tile.worldx(), tile.worldy()); Draw.color(); diff --git a/core/src/io/anuke/mindustry/world/blocks/types/production/Generator.java b/core/src/io/anuke/mindustry/world/blocks/types/production/Generator.java index c8061930f0..ae498ce50c 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/production/Generator.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/production/Generator.java @@ -18,6 +18,7 @@ import io.anuke.ucore.util.*; public class Generator extends PowerBlock{ public static final int powerTime = 2; + public static boolean drawRangeOverlay = false; public int laserRange = 6; public int laserDirections = 4; @@ -29,21 +30,71 @@ public class Generator extends PowerBlock{ public Generator(String name) { super(name); } - + @Override public void getStats(Array list){ super.getStats(list); - + if(hasLasers){ list.add("[powerinfo]Laser range: " + laserRange + " blocks"); - list.add("[powerinfo]Max power transfer/second: " + Strings.toFixed(powerSpeed*2, 2)); + list.add("[powerinfo]Max power transfer/second: " + Strings.toFixed(powerSpeed * 2, 2)); } - + if(explosive){ list.add("[orange]Highly explosive!"); } } + @Override + public void drawPixelOverlay(Tile tile){ + super.drawPixelOverlay(tile); + + if(drawRangeOverlay){ + int rotation = tile.getRotation(); + if(hasLasers){ + Draw.color("yellow"); + Draw.thick(2f); + + for(int i = 0; i < laserDirections; i++){ + int dir = Mathf.mod(i + rotation - laserDirections / 2, 4); + float lx = Geometry.getD4Points()[dir].x, ly = Geometry.getD4Points()[dir].y; + float dx = lx * laserRange * Vars.tilesize; + float dy = ly * laserRange * Vars.tilesize; + + Draw.dashLine( + tile.worldx() + lx * Vars.tilesize / 2, + tile.worldy() + ly * Vars.tilesize / 2, + tile.worldx() + dx - lx * Vars.tilesize, + tile.worldy() + dy - ly * Vars.tilesize, 9); + } + + Draw.reset(); + } + } + } + + @Override + public void drawPlace(int x, int y, int rotation, boolean valid){ + if(hasLasers){ + Draw.color("purple"); + Draw.thick(2f); + + for(int i = 0; i < laserDirections; i++){ + int dir = Mathf.mod(i + rotation - laserDirections / 2, 4); + float lx = Geometry.getD4Points()[dir].x, ly = Geometry.getD4Points()[dir].y; + float dx = lx * laserRange * Vars.tilesize; + float dy = ly * laserRange * Vars.tilesize; + Draw.dashLine( + x * Vars.tilesize + lx * Vars.tilesize / 2, + y * Vars.tilesize + ly * Vars.tilesize / 2, + x * Vars.tilesize + dx - lx * Vars.tilesize, + y * Vars.tilesize + dy - ly * Vars.tilesize, 9); + } + + Draw.reset(); + } + } + @Override public void onDestroyed(Tile tile){ if(explosive){ @@ -58,7 +109,7 @@ public class Generator extends PowerBlock{ Effects.effect(Fx.shockwave, x, y); Timers.run(12f + Mathf.random(20f), () -> { - tile.damageNearby(4, 40, 0f); + tile.damageNearby(4, 60, 0f); }); Effects.sound(explosionSound, x, y); @@ -68,7 +119,7 @@ public class Generator extends PowerBlock{ super.onDestroyed(tile); } } - + @Override public void drawOver(Tile tile){ PowerEntity entity = tile.entity(); @@ -79,12 +130,12 @@ public class Generator extends PowerBlock{ }else{ Draw.alpha(0.5f); } - drawLaserTo(tile, (tile.getRotation() + i) - laserDirections/2); + drawLaserTo(tile, (tile.getRotation() + i) - laserDirections / 2); } - + Draw.color(); } - + @Override public boolean acceptsPower(Tile tile){ return false; @@ -94,11 +145,12 @@ public class Generator extends PowerBlock{ PowerEntity entity = tile.entity(); for(int i = 0; i < laserDirections; i++){ - int rot = (tile.getRotation() + i) - laserDirections/2; + int rot = (tile.getRotation() + i) - laserDirections / 2; Tile target = laserTarget(tile, rot); - - if(target == null || isInterfering(target, rot)) continue; - + + if(target == null || isInterfering(target, rot)) + continue; + PowerAcceptor p = (PowerAcceptor) target.block(); if(p.acceptsPower(target) && entity.power >= powerSpeed){ float accepted = p.addPower(target, powerSpeed); @@ -114,12 +166,10 @@ public class Generator extends PowerBlock{ if(target != null){ boolean interfering = isInterfering(target, rotation); - - Tmp.v1.set(Angles.translation(rotation * 90, target.block().width * Vars.tilesize/2 + 2f + - (interfering ? - Vector2.dst(tile.worldx(), tile.worldy(), target.worldx(), target.worldy()) / 2f - Vars.tilesize/2f * target.block().width - 1 : 0))); - - Angles.translation(rotation * 90, width * Vars.tilesize/2 + 2f); + + Tmp.v1.set(Angles.translation(rotation * 90, target.block().width * Vars.tilesize / 2 + 2f + (interfering ? Vector2.dst(tile.worldx(), tile.worldy(), target.worldx(), target.worldy()) / 2f - Vars.tilesize / 2f * target.block().width - 1 : 0))); + + Angles.translation(rotation * 90, width * Vars.tilesize / 2 + 2f); if(!interfering){ Draw.tint(Hue.mix(Color.GRAY, Color.WHITE, 0.904f + Mathf.sin(Timers.time(), 1.7f, 0.06f))); @@ -129,21 +179,20 @@ public class Generator extends PowerBlock{ Effects.effect(Fx.laserspark, target.worldx() - Tmp.v1.x, target.worldy() - Tmp.v1.y); } } - + float r = interfering ? 0.8f : 0f; - Draw.laser("laser", "laserend", tile.worldx() + Angles.x(), tile.worldy() + Angles.y(), - target.worldx() - Tmp.v1.x + Mathf.range(r), target.worldy() - Tmp.v1.y + Mathf.range(r), 0.7f + Mathf.sin(Timers.time(), 2f, 0.1f * 0)); + Draw.laser("laser", "laserend", tile.worldx() + Angles.x(), tile.worldy() + Angles.y(), target.worldx() - Tmp.v1.x + Mathf.range(r), target.worldy() - Tmp.v1.y + Mathf.range(r), 0.7f + Mathf.sin(Timers.time(), 2f, 0.1f * 0)); Draw.color(); } } - + protected boolean isInterfering(Tile target, int rotation){ if(target.block() instanceof Generator){ - Generator other = (Generator)target.block(); + Generator other = (Generator) target.block(); int relrot = (rotation + 2) % 4; - if(other.hasLasers && Math.abs(target.getRotation() - relrot) <= other.laserDirections/2){ + if(other.hasLasers && Math.abs(target.getRotation() - relrot) <= other.laserDirections / 2){ return true; } } @@ -160,7 +209,7 @@ public class Generator extends PowerBlock{ for(i = 1; i < laserRange; i++){ Tile other = Vars.world.tile(tile.x + i * point.x, tile.y + i * point.y); - + if(other != null && other.block() instanceof PowerAcceptor){ Tile linked = other.getLinked(); if(linked == null || linked instanceof PowerAcceptor){ diff --git a/desktop/mindustry-saves/2.mins b/desktop/mindustry-saves/2.mins index 94eac02a14..651006157e 100644 Binary files a/desktop/mindustry-saves/2.mins and b/desktop/mindustry-saves/2.mins differ diff --git a/desktop/mindustry-saves/3.mins b/desktop/mindustry-saves/3.mins index 93ba885bfc..c6304ac3d3 100644 Binary files a/desktop/mindustry-saves/3.mins and b/desktop/mindustry-saves/3.mins differ diff --git a/desktop/mindustry-saves/4.mins b/desktop/mindustry-saves/4.mins new file mode 100644 index 0000000000..f50a640545 Binary files /dev/null and b/desktop/mindustry-saves/4.mins differ diff --git a/desktop/mindustry-saves/6.mins b/desktop/mindustry-saves/6.mins new file mode 100644 index 0000000000..a9e038a2fe Binary files /dev/null and b/desktop/mindustry-saves/6.mins differ diff --git a/desktop/mindustry-saves/7.mins b/desktop/mindustry-saves/7.mins new file mode 100644 index 0000000000..e9cf74f853 Binary files /dev/null and b/desktop/mindustry-saves/7.mins differ