mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-02 20:33:50 +07:00
More bugfixes
This commit is contained in:
parent
aafe7fb74a
commit
8e80af26d7
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="io.anuke.mindustry"
|
||||
android:versionCode="16"
|
||||
android:versionName="3.0b" >
|
||||
android:versionCode="18"
|
||||
android:versionName="3.02b" >
|
||||
|
||||
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="25" />
|
||||
|
||||
|
@ -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"
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user