diff --git a/core/src/io/anuke/mindustry/Renderer.java b/core/src/io/anuke/mindustry/Renderer.java index 6933d9ad13..6496823282 100644 --- a/core/src/io/anuke/mindustry/Renderer.java +++ b/core/src/io/anuke/mindustry/Renderer.java @@ -126,6 +126,12 @@ public class Renderer extends RendererModule{ //render the entire map if(floorCache == null || floorCache.length != chunksx || floorCache[0].length != chunksy){ floorCache = new Cache[chunksx][chunksy]; + + for(int x = 0; x < chunksx; x ++){ + for(int y = 0; y < chunksy; y ++){ + renderCache(x, y); + } + } } OrthographicCamera camera = Core.camera; diff --git a/core/src/io/anuke/mindustry/UI.java b/core/src/io/anuke/mindustry/UI.java index 142e10fe6b..11c9c129cf 100644 --- a/core/src/io/anuke/mindustry/UI.java +++ b/core/src/io/anuke/mindustry/UI.java @@ -435,7 +435,7 @@ public class UI extends SceneModule{ new table(){{ new table("pane"){{ - new label(()->"Respawning in " + (int)(control.getRespawnTime()/60)).scale(0.75f).pad(10); + new label(()->"[orange]Respawning in " + (int)(control.getRespawnTime()/60)).scale(0.75f).pad(10); visible(()->control.getRespawnTime() > 0 && !GameState.is(State.menu)); diff --git a/core/src/io/anuke/mindustry/entities/enemies/Enemy.java b/core/src/io/anuke/mindustry/entities/enemies/Enemy.java index 133b58ea97..332667fa3e 100644 --- a/core/src/io/anuke/mindustry/entities/enemies/Enemy.java +++ b/core/src/io/anuke/mindustry/entities/enemies/Enemy.java @@ -161,7 +161,6 @@ public class Enemy extends DestructibleEntity{ @Override public void draw(){ - Draw.color(); String region = ClassReflection.getSimpleName(getClass()).toLowerCase() + "-t" + Mathf.clamp(tier, 1, 3); @@ -170,6 +169,7 @@ public class Enemy extends DestructibleEntity{ Draw.getShader(Outline.class).region = Draw.region(region); Draw.shader(Outline.class); + Draw.color(); Draw.rect(region, x, y, direction.angle()-90); Draw.shader(); } diff --git a/core/src/io/anuke/mindustry/entities/enemies/TankEnemy.java b/core/src/io/anuke/mindustry/entities/enemies/TankEnemy.java index 52a95bbb59..75c43a8ac7 100644 --- a/core/src/io/anuke/mindustry/entities/enemies/TankEnemy.java +++ b/core/src/io/anuke/mindustry/entities/enemies/TankEnemy.java @@ -14,12 +14,13 @@ public class TankEnemy extends Enemy{ speed = 0.2f; reload = 90f; bullet = BulletType.small; + length = 3f; } void shoot(){ vector.set(length, 0).rotate(direction.angle()); - Angles.shotgun(3, 4f, direction.angle(), f->{ + Angles.shotgun(3, 8f, direction.angle(), f->{ Bullet out = new Bullet(bullet, this, x+vector.x, y+vector.y, f).add(); out.damage = (int)(damage*Vars.multiplier); }); diff --git a/core/src/io/anuke/mindustry/input/AndroidInput.java b/core/src/io/anuke/mindustry/input/AndroidInput.java index 78bfadbb40..ccb784514d 100644 --- a/core/src/io/anuke/mindustry/input/AndroidInput.java +++ b/core/src/io/anuke/mindustry/input/AndroidInput.java @@ -14,6 +14,7 @@ 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.ui.layout.Unit; import io.anuke.ucore.util.Mathf; public class AndroidInput extends InputAdapter{ @@ -101,7 +102,7 @@ public class AndroidInput extends InputAdapter{ public static void doInput(){ if(Gdx.input.isTouched(0) - && Mathf.near2d(lmousex, lmousey, Gdx.input.getX(0), Gdx.input.getY(0), 50) + && Mathf.near2d(lmousex, lmousey, Gdx.input.getX(0), Gdx.input.getY(0), Unit.dp.inPixels(50)) && !ui.hasMouse() /*&& (player.recipe == null || mode == PlaceMode.touch)*/){ warmup += Timers.delta(); @@ -127,8 +128,8 @@ public class AndroidInput extends InputAdapter{ mousey = ly; }else{ warmup = 0; - lmousex = Gdx.input.getX(0); - lmousey = Gdx.input.getY(0); + //lmousex = Gdx.input.getX(0); + //lmousey = Gdx.input.getY(0); player.breaktime = 0; mousex = Mathf.clamp(mousex, 0, Gdx.graphics.getWidth()); diff --git a/core/src/io/anuke/mindustry/io/SaveIO.java b/core/src/io/anuke/mindustry/io/SaveIO.java index ab25f56b3f..a65eef4d87 100644 --- a/core/src/io/anuke/mindustry/io/SaveIO.java +++ b/core/src/io/anuke/mindustry/io/SaveIO.java @@ -59,6 +59,7 @@ import io.anuke.ucore.entities.Entity; * spawn lane (byte) * x (float) * y (float) + * tier (byte) * health (int) * * @@ -82,7 +83,7 @@ import io.anuke.ucore.entities.Entity; */ public class SaveIO{ /**Save file version ID. Should be incremented every breaking release.*/ - private static final int fileVersionID = 6; + private static final int fileVersionID = 7; private static FormatProvider provider = null; @@ -91,7 +92,11 @@ public class SaveIO{ Enemy.class, FastEnemy.class, RapidEnemy.class, - FlamerEnemy.class + FlamerEnemy.class, + TankEnemy.class, + BlastEnemy.class, + MortarEnemy.class, + TestEnemy.class ); private static final ObjectMap, Byte> idEnemies = new ObjectMap, Byte>(){{ @@ -186,6 +191,7 @@ public class SaveIO{ stream.writeByte(enemy.spawn); //lane stream.writeFloat(enemy.x); //x stream.writeFloat(enemy.y); //y + stream.writeByte(enemy.tier); //tier stream.writeInt(enemy.health); //health } } @@ -308,6 +314,7 @@ public class SaveIO{ int lane = stream.readByte(); float x = stream.readFloat(); float y = stream.readFloat(); + byte tier = stream.readByte(); int health = stream.readInt(); try{ @@ -315,6 +322,7 @@ public class SaveIO{ enemy.health = health; enemy.x = x; enemy.y = y; + enemy.tier = tier; enemy.add(); enemiesToUpdate.add(enemy); }catch (Exception e){ diff --git a/core/src/io/anuke/mindustry/ui/SaveDialog.java b/core/src/io/anuke/mindustry/ui/SaveDialog.java index ec3df63741..89e555c3a4 100644 --- a/core/src/io/anuke/mindustry/ui/SaveDialog.java +++ b/core/src/io/anuke/mindustry/ui/SaveDialog.java @@ -2,6 +2,7 @@ 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; @@ -68,13 +69,17 @@ public class SaveDialog extends Dialog{ @Override public void run(){ hide(); + Vars.ui.hideLoading(); try{ SaveIO.saveToSlot(slot); - }catch (Exception e){ - Vars.ui.showError("[orange]Failed to save game!"); - return; + }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()); } - Vars.ui.hideLoading(); + } }, 5f/60f); } diff --git a/core/src/io/anuke/mindustry/world/blocks/types/Drill.java b/core/src/io/anuke/mindustry/world/blocks/types/Drill.java index 54d0374b91..720401bebd 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/Drill.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/Drill.java @@ -21,8 +21,9 @@ public class Drill extends Block{ @Override public void update(Tile tile){ - - if(tile.floor() == resource && Timers.get(tile, 60 * time)){ + + //drills can only hold up to 10 items at a time + if(tile.floor() == resource && Timers.get(tile, 60 * time) && tile.entity.totalItems() < 10){ offloadNear(tile, result); Effects.effect("spark", tile.worldx(), tile.worldy()); } diff --git a/desktop/mindustry-saves/0.mins b/desktop/mindustry-saves/0.mins index da7b817352..5e0bc3db65 100644 Binary files a/desktop/mindustry-saves/0.mins and b/desktop/mindustry-saves/0.mins differ diff --git a/desktop/mindustry-saves/2.mins b/desktop/mindustry-saves/2.mins new file mode 100644 index 0000000000..d52c495f97 Binary files /dev/null and b/desktop/mindustry-saves/2.mins differ