From 8e80af26d755d34f9496c791fd9f8f73a7ce6d05 Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 6 Dec 2017 09:26:39 -0500 Subject: [PATCH] More bugfixes --- android/AndroidManifest.xml | 4 +- build.gradle | 2 +- .../anuke/mindustry/input/AndroidInput.java | 95 +++++++++--------- .../mindustry/ui/fragments/HudFragment.java | 8 +- .../blocks/types/defense/ShieldBlock.java | 7 +- desktop/mindustry-saves/7.mins | Bin 3906 -> 3824 bytes 6 files changed, 61 insertions(+), 55 deletions(-) diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 97ccaace35..ae5c163889 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="18" + android:versionName="3.02b" > diff --git a/build.gradle b/build.gradle index 6e977b8ab4..5371ac6f3b 100644 --- a/build.gradle +++ b/build.gradle @@ -79,7 +79,7 @@ project(":core") { apply plugin: "java" dependencies { - compile 'com.github.Anuken:ucore:92dc170f0e' + compile 'com.github.Anuken:ucore:a64bf7e' compile "com.badlogicgames.gdx:gdx:$gdxVersion" compile "com.badlogicgames.gdx:gdx-ai:1.8.1" } diff --git a/core/src/io/anuke/mindustry/input/AndroidInput.java b/core/src/io/anuke/mindustry/input/AndroidInput.java index d11401a025..0bca99eca2 100644 --- a/core/src/io/anuke/mindustry/input/AndroidInput.java +++ b/core/src/io/anuke/mindustry/input/AndroidInput.java @@ -3,17 +3,17 @@ package io.anuke.mindustry.input; import static io.anuke.mindustry.Vars.*; import com.badlogic.gdx.Gdx; -import com.badlogic.gdx.Input.Buttons; import com.badlogic.gdx.Input.Keys; import com.badlogic.gdx.InputAdapter; import com.badlogic.gdx.math.Vector2; import io.anuke.mindustry.Vars; +import io.anuke.mindustry.core.GameState; +import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.resource.ItemStack; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.types.Configurable; import io.anuke.ucore.core.Graphics; -import io.anuke.ucore.core.Inputs; import io.anuke.ucore.core.Timers; import io.anuke.ucore.scene.ui.layout.Unit; import io.anuke.ucore.util.Mathf; @@ -25,101 +25,104 @@ public class AndroidInput extends InputAdapter{ private static float lmousex, lmousey; private static float warmup; private static float warmupDelay = 20; - + @Override - public boolean keyDown (int keycode) { + public boolean keyDown(int keycode){ if(keycode == Keys.E){ place(); } return false; } - + @Override - public boolean touchUp (int screenX, int screenY, int pointer, int button) { + public boolean touchUp(int screenX, int screenY, int pointer, int button){ brokeBlock = false; return false; } - + @Override - public boolean touchDown (int screenX, int screenY, int pointer, int button) { + public boolean touchDown(int screenX, int screenY, int pointer, int button){ ui.hideTooltip(); if(pointer == 0){ lmousex = screenX; lmousey = screenY; } warmup = 0; + + if(!GameState.is(State.menu)){ + Tile cursor = Vars.world.tile(Mathf.scl2(Graphics.mouseWorld().x, tilesize), Mathf.scl2(Graphics.mouseWorld().y, tilesize)); + if(cursor != null && !Vars.ui.hasMouse()){ + Tile linked = cursor.isLinked() ? cursor.getLinked() : cursor; + if(linked != null && linked.block() instanceof Configurable){ + Vars.ui.showConfig(linked); + }else if(!Vars.ui.hasConfigMouse()){ + Vars.ui.hideConfig(); + } + } + } return false; } - + public static Tile selected(){ Vector2 vec = Graphics.world(mousex, mousey); return Vars.world.tile(Mathf.scl2(vec.x, tilesize), Mathf.scl2(vec.y, tilesize)); } - + public static void breakBlock(){ Tile tile = selected(); player.breaktime += Timers.delta(); - + if(player.breaktime >= tile.block().breaktime){ brokeBlock = true; Vars.world.breakBlock(tile.x, tile.y); player.breaktime = 0f; } } - + public static void place(){ Vector2 vec = Graphics.world(mousex, mousey); - + int tilex = Mathf.scl2(vec.x, tilesize); int tiley = Mathf.scl2(vec.y, tilesize); - - if(player.recipe != null && - Vars.world.validPlace(tilex, tiley, player.recipe.result)){ - + + if(player.recipe != null && Vars.world.validPlace(tilex, tiley, player.recipe.result)){ + Vars.world.placeBlock(tilex, tiley, player.recipe.result, player.rotation); - + for(ItemStack stack : player.recipe.requirements){ Vars.control.removeItem(stack); } } } - + public static void doInput(){ - Tile cursor = selected(); - - //TODO test - if(Inputs.buttonUp(Buttons.LEFT) && cursor != null){ - Tile linked = cursor.isLinked() ? cursor.getLinked() : cursor; - if(linked != null && linked.block() instanceof Configurable){ - Vars.ui.showConfig(linked); - }else if(!Vars.ui.hasConfigMouse()){ - Vars.ui.hideConfig(); - } - } - - if(Gdx.input.isTouched(0) - && Mathf.near2d(lmousex, lmousey, Gdx.input.getX(0), Gdx.input.getY(0), Unit.dp.inPixels(50)) - && !ui.hasMouse() /*&& (player.recipe == null || mode == PlaceMode.touch)*/){ + + if(Gdx.input.isTouched(0) && 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(); - + float lx = mousex, ly = mousey; - + mousex = Gdx.input.getX(0); mousey = Gdx.input.getY(0); - + Tile sel = selected(); - - if(sel == null) return; - + + if(sel == null) + return; + if(warmup > warmupDelay && Vars.world.validBreak(sel.x, sel.y)){ player.breaktime += Timers.delta(); - + if(player.breaktime > selected().block().breaktime){ breakBlock(); player.breaktime = 0; } } - + mousex = lx; mousey = ly; }else{ @@ -127,17 +130,17 @@ public class AndroidInput extends InputAdapter{ //lmousex = Gdx.input.getX(0); //lmousey = Gdx.input.getY(0); player.breaktime = 0; - + mousex = Mathf.clamp(mousex, 0, Gdx.graphics.getWidth()); mousey = Mathf.clamp(mousey, 0, Gdx.graphics.getHeight()); } } - + public static int touches(){ int sum = 0; - for(int i = 0; i < 10; i ++){ + for(int i = 0; i < 10; i++){ if(Gdx.input.isTouched(i)) - sum ++; + sum++; } return sum; } diff --git a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java index 9b93767d85..d80c08810c 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java @@ -175,10 +175,11 @@ public class HudFragment implements Fragment{ new label(()-> control.getEnemiesRemaining() > 0 ? control.getEnemiesRemaining() + " enemies" : (control.getTutorial().active() || Vars.control.getMode() == GameMode.sandbox) ? "waiting..." : "Wave in " + (int) (control.getWaveCountdown() / 60f)) - .minWidth(140).left(); + .minWidth(140).units(Unit.dp).left(); get().pad(Unit.dp.inPixels(12)); - }}.left().padLeft(-6).end(); + get().padLeft(6); + }}.left().end(); playButton(uheight); //get().padTop(Unit.dp.inPixels(1)); @@ -190,7 +191,8 @@ public class HudFragment implements Fragment{ private void playButton(float uheight){ new imagebutton("icon-play", Unit.dp.inPixels(30f), ()->{ Vars.control.runWave(); - }).height(uheight).fillX().padTop(-8f).padBottom(-12f).padRight(-18f).padLeft(-10f).width(40f).units(Unit.dp).update(l->{ + }).height(uheight).fillX().right().padTop(-8f).padBottom(-12f).padRight(-36) + .padLeft(-10f).width(40f).units(Unit.dp).update(l->{ boolean vis = Vars.control.getMode() == GameMode.sandbox && Vars.control.getEnemiesRemaining() <= 0; boolean paused = GameState.is(State.paused) || !vis; diff --git a/core/src/io/anuke/mindustry/world/blocks/types/defense/ShieldBlock.java b/core/src/io/anuke/mindustry/world/blocks/types/defense/ShieldBlock.java index 75033ab71e..b700e15750 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/defense/ShieldBlock.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/defense/ShieldBlock.java @@ -17,13 +17,14 @@ import io.anuke.ucore.util.Strings; public class ShieldBlock extends PowerBlock{ public float shieldRadius = 40f; public float powerDrain = 0.005f; - public float powerPerDamage = 0.1f; + public float powerPerDamage = 0.2f; public float maxRadius = 40f; - public float radiusPowerScale = 7.5f; + public float radiusScale = 80f; public ShieldBlock(String name) { super(name); voltage = powerDrain; + powerCapacity = 30f; health = 100; } @@ -57,7 +58,7 @@ public class ShieldBlock extends PowerBlock{ } } - entity.shield.radius = Mathf.lerp(entity.shield.radius, Math.min(entity.power * radiusPowerScale, maxRadius), Timers.delta() * 0.05f); + entity.shield.radius = Mathf.lerp(entity.shield.radius, Math.min(entity.power / powerCapacity * radiusScale, maxRadius), Timers.delta() * 0.05f); } diff --git a/desktop/mindustry-saves/7.mins b/desktop/mindustry-saves/7.mins index e9bd698ec7002006a7e9d7b78bcaf4b4c943043c..d4afecb81ddbc83d43490d96e5b16f5c055a5f73 100644 GIT binary patch literal 3824 zcmZwJT~JhI7zgl|6>a*ssEfu*kbwPCh_TIu3k_R65G!bolKF{Bi#lq8l9VM0f=M9I z7wWQ#ibV0@R}RL6q7sRsq5^B<$e3EwMO>6uUD|Wb?*C6Nof*&k-v9HS=e+0aIR}+e z&nOkP(&m5dFEvgnWzzO2rG1l|Gpqm6Oc{IB6XVpx(jt?-3zJ>s7&WovkrLe*D?4|% z?6PIzSQV}E zdo^4;ReCR2eX2lKm9EtK2U{yaTSz8t)gyI<2{(SBL^D48rnqlQlG3rwTFsai)_X^ zsGI6rk1S&Y)IbeV9UD>Yp}KOBU7@a0e^P&M#=L3oLw@Q$)v^WECGt&?P2Pa1A3{?; zh9(w5b<{!X8g*bh=5=V$6%$0o7AIBPwO}Q^>muYNWcT*fLa4P*Ugq5;W@zfhs0o6iTzCf2L zl$*+-Hc$mrGu296pkDqGoztl7uaK2c311^~Q0dgn8dP(sX!*-3n>>G$sF=MfOtMtH zV3&WfA!BpMxM{CGQ}5AA#q2YBBZ|n`ixkEC(03PAMorj{YRvx8*Ag3=Nxv2Hi8Tjv zu11mqgGB$^d zqw8=3;;7Vv$l9pMhma*5HqMZ&kL}7dPJXb%s0~qZ^~jv{q4N_TPvkBp1rp{JKUh} z^#{{WMKvNzY&1F>4Lr)Vc7lAD53!p4E#{f!L6uFqoN9&!DL-XvMRopBDEb(*m|A!o znfoMEMct5xN;WxLRvVOl8e0AXm0DVWr zbs=+7iPUE51hw@i91+(IRZ%t><6>O<3qX6j4dde1pL54P^ku=9JL|NH*Wdv1#m z;t3%_)>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