mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-18 11:47:47 +07:00
More bugfixes
This commit is contained in:
@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="io.anuke.mindustry"
|
package="io.anuke.mindustry"
|
||||||
android:versionCode="16"
|
android:versionCode="18"
|
||||||
android:versionName="3.0b" >
|
android:versionName="3.02b" >
|
||||||
|
|
||||||
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="25" />
|
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="25" />
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ project(":core") {
|
|||||||
apply plugin: "java"
|
apply plugin: "java"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'com.github.Anuken:ucore:92dc170f0e'
|
compile 'com.github.Anuken:ucore:a64bf7e'
|
||||||
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
|
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
|
||||||
compile "com.badlogicgames.gdx:gdx-ai:1.8.1"
|
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 static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.Input.Buttons;
|
|
||||||
import com.badlogic.gdx.Input.Keys;
|
import com.badlogic.gdx.Input.Keys;
|
||||||
import com.badlogic.gdx.InputAdapter;
|
import com.badlogic.gdx.InputAdapter;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
|
|
||||||
import io.anuke.mindustry.Vars;
|
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.resource.ItemStack;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.blocks.types.Configurable;
|
import io.anuke.mindustry.world.blocks.types.Configurable;
|
||||||
import io.anuke.ucore.core.Graphics;
|
import io.anuke.ucore.core.Graphics;
|
||||||
import io.anuke.ucore.core.Inputs;
|
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
@ -25,101 +25,104 @@ public class AndroidInput extends InputAdapter{
|
|||||||
private static float lmousex, lmousey;
|
private static float lmousex, lmousey;
|
||||||
private static float warmup;
|
private static float warmup;
|
||||||
private static float warmupDelay = 20;
|
private static float warmupDelay = 20;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyDown (int keycode) {
|
public boolean keyDown(int keycode){
|
||||||
if(keycode == Keys.E){
|
if(keycode == Keys.E){
|
||||||
place();
|
place();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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;
|
brokeBlock = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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();
|
ui.hideTooltip();
|
||||||
if(pointer == 0){
|
if(pointer == 0){
|
||||||
lmousex = screenX;
|
lmousex = screenX;
|
||||||
lmousey = screenY;
|
lmousey = screenY;
|
||||||
}
|
}
|
||||||
warmup = 0;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Tile selected(){
|
public static Tile selected(){
|
||||||
Vector2 vec = Graphics.world(mousex, mousey);
|
Vector2 vec = Graphics.world(mousex, mousey);
|
||||||
return Vars.world.tile(Mathf.scl2(vec.x, tilesize), Mathf.scl2(vec.y, tilesize));
|
return Vars.world.tile(Mathf.scl2(vec.x, tilesize), Mathf.scl2(vec.y, tilesize));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void breakBlock(){
|
public static void breakBlock(){
|
||||||
Tile tile = selected();
|
Tile tile = selected();
|
||||||
player.breaktime += Timers.delta();
|
player.breaktime += Timers.delta();
|
||||||
|
|
||||||
if(player.breaktime >= tile.block().breaktime){
|
if(player.breaktime >= tile.block().breaktime){
|
||||||
brokeBlock = true;
|
brokeBlock = true;
|
||||||
Vars.world.breakBlock(tile.x, tile.y);
|
Vars.world.breakBlock(tile.x, tile.y);
|
||||||
player.breaktime = 0f;
|
player.breaktime = 0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void place(){
|
public static void place(){
|
||||||
Vector2 vec = Graphics.world(mousex, mousey);
|
Vector2 vec = Graphics.world(mousex, mousey);
|
||||||
|
|
||||||
int tilex = Mathf.scl2(vec.x, tilesize);
|
int tilex = Mathf.scl2(vec.x, tilesize);
|
||||||
int tiley = Mathf.scl2(vec.y, tilesize);
|
int tiley = Mathf.scl2(vec.y, tilesize);
|
||||||
|
|
||||||
if(player.recipe != null &&
|
if(player.recipe != null && Vars.world.validPlace(tilex, tiley, player.recipe.result)){
|
||||||
Vars.world.validPlace(tilex, tiley, player.recipe.result)){
|
|
||||||
|
|
||||||
Vars.world.placeBlock(tilex, tiley, player.recipe.result, player.rotation);
|
Vars.world.placeBlock(tilex, tiley, player.recipe.result, player.rotation);
|
||||||
|
|
||||||
for(ItemStack stack : player.recipe.requirements){
|
for(ItemStack stack : player.recipe.requirements){
|
||||||
Vars.control.removeItem(stack);
|
Vars.control.removeItem(stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void doInput(){
|
public static void doInput(){
|
||||||
Tile cursor = selected();
|
|
||||||
|
if(Gdx.input.isTouched(0) && Mathf.near2d(lmousex, lmousey, Gdx.input.getX(0), Gdx.input.getY(0), Unit.dp.inPixels(50))
|
||||||
//TODO test
|
&& !ui.hasMouse() /*
|
||||||
if(Inputs.buttonUp(Buttons.LEFT) && cursor != null){
|
* && (player.recipe == null || mode ==
|
||||||
Tile linked = cursor.isLinked() ? cursor.getLinked() : cursor;
|
* PlaceMode.touch)
|
||||||
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)*/){
|
|
||||||
warmup += Timers.delta();
|
warmup += Timers.delta();
|
||||||
|
|
||||||
float lx = mousex, ly = mousey;
|
float lx = mousex, ly = mousey;
|
||||||
|
|
||||||
mousex = Gdx.input.getX(0);
|
mousex = Gdx.input.getX(0);
|
||||||
mousey = Gdx.input.getY(0);
|
mousey = Gdx.input.getY(0);
|
||||||
|
|
||||||
Tile sel = selected();
|
Tile sel = selected();
|
||||||
|
|
||||||
if(sel == null) return;
|
if(sel == null)
|
||||||
|
return;
|
||||||
|
|
||||||
if(warmup > warmupDelay && Vars.world.validBreak(sel.x, sel.y)){
|
if(warmup > warmupDelay && Vars.world.validBreak(sel.x, sel.y)){
|
||||||
player.breaktime += Timers.delta();
|
player.breaktime += Timers.delta();
|
||||||
|
|
||||||
if(player.breaktime > selected().block().breaktime){
|
if(player.breaktime > selected().block().breaktime){
|
||||||
breakBlock();
|
breakBlock();
|
||||||
player.breaktime = 0;
|
player.breaktime = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mousex = lx;
|
mousex = lx;
|
||||||
mousey = ly;
|
mousey = ly;
|
||||||
}else{
|
}else{
|
||||||
@ -127,17 +130,17 @@ public class AndroidInput extends InputAdapter{
|
|||||||
//lmousex = Gdx.input.getX(0);
|
//lmousex = Gdx.input.getX(0);
|
||||||
//lmousey = Gdx.input.getY(0);
|
//lmousey = Gdx.input.getY(0);
|
||||||
player.breaktime = 0;
|
player.breaktime = 0;
|
||||||
|
|
||||||
mousex = Mathf.clamp(mousex, 0, Gdx.graphics.getWidth());
|
mousex = Mathf.clamp(mousex, 0, Gdx.graphics.getWidth());
|
||||||
mousey = Mathf.clamp(mousey, 0, Gdx.graphics.getHeight());
|
mousey = Mathf.clamp(mousey, 0, Gdx.graphics.getHeight());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int touches(){
|
public static int touches(){
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
for(int i = 0; i < 10; i ++){
|
for(int i = 0; i < 10; i++){
|
||||||
if(Gdx.input.isTouched(i))
|
if(Gdx.input.isTouched(i))
|
||||||
sum ++;
|
sum++;
|
||||||
}
|
}
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
@ -175,10 +175,11 @@ public class HudFragment implements Fragment{
|
|||||||
new label(()-> control.getEnemiesRemaining() > 0 ?
|
new label(()-> control.getEnemiesRemaining() > 0 ?
|
||||||
control.getEnemiesRemaining() + " enemies" :
|
control.getEnemiesRemaining() + " enemies" :
|
||||||
(control.getTutorial().active() || Vars.control.getMode() == GameMode.sandbox) ? "waiting..." : "Wave in " + (int) (control.getWaveCountdown() / 60f))
|
(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));
|
get().pad(Unit.dp.inPixels(12));
|
||||||
}}.left().padLeft(-6).end();
|
get().padLeft(6);
|
||||||
|
}}.left().end();
|
||||||
|
|
||||||
playButton(uheight);
|
playButton(uheight);
|
||||||
//get().padTop(Unit.dp.inPixels(1));
|
//get().padTop(Unit.dp.inPixels(1));
|
||||||
@ -190,7 +191,8 @@ public class HudFragment implements Fragment{
|
|||||||
private void playButton(float uheight){
|
private void playButton(float uheight){
|
||||||
new imagebutton("icon-play", Unit.dp.inPixels(30f), ()->{
|
new imagebutton("icon-play", Unit.dp.inPixels(30f), ()->{
|
||||||
Vars.control.runWave();
|
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 vis = Vars.control.getMode() == GameMode.sandbox && Vars.control.getEnemiesRemaining() <= 0;
|
||||||
boolean paused = GameState.is(State.paused) || !vis;
|
boolean paused = GameState.is(State.paused) || !vis;
|
||||||
|
|
||||||
|
@ -17,13 +17,14 @@ import io.anuke.ucore.util.Strings;
|
|||||||
public class ShieldBlock extends PowerBlock{
|
public class ShieldBlock extends PowerBlock{
|
||||||
public float shieldRadius = 40f;
|
public float shieldRadius = 40f;
|
||||||
public float powerDrain = 0.005f;
|
public float powerDrain = 0.005f;
|
||||||
public float powerPerDamage = 0.1f;
|
public float powerPerDamage = 0.2f;
|
||||||
public float maxRadius = 40f;
|
public float maxRadius = 40f;
|
||||||
public float radiusPowerScale = 7.5f;
|
public float radiusScale = 80f;
|
||||||
|
|
||||||
public ShieldBlock(String name) {
|
public ShieldBlock(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
voltage = powerDrain;
|
voltage = powerDrain;
|
||||||
|
powerCapacity = 30f;
|
||||||
health = 100;
|
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.
Reference in New Issue
Block a user