UI bug cleanup, testing, balancing of repair turrets

This commit is contained in:
Anuken
2018-01-26 18:29:31 -05:00
parent 6c30fe9fcf
commit 8e6f628f5b
14 changed files with 47 additions and 28 deletions

View File

@@ -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="61" android:versionCode="62"
android:versionName="3.3b12" > android:versionName="3.3b123" >
<uses-feature android:glEsVersion="0x00020000" android:required="true" /> <uses-feature android:glEsVersion="0x00020000" android:required="true" />
<uses-permission android:name="com.android.vending.BILLING" /> <uses-permission android:name="com.android.vending.BILLING" />

View File

@@ -22,7 +22,7 @@ allprojects {
appName = "Mindustry" appName = "Mindustry"
gdxVersion = '1.9.8' gdxVersion = '1.9.8'
aiVersion = '1.8.1' aiVersion = '1.8.1'
uCoreVersion = 'd5ca764'; uCoreVersion = 'd5ca764'
} }
repositories { repositories {
@@ -90,12 +90,12 @@ project(":core") {
apply plugin: "java" apply plugin: "java"
dependencies { dependencies {
boolean comp = System.properties["release"] == null || System.properties["release"].equals("false"); boolean comp = System.properties["release"] == null || System.properties["release"].equals("false")
if(!comp){ if(!comp){
println("NOTICE: Compiling release build.") println("NOTICE: Compiling release build.")
}else{ }else{
println("Compiling DEBUG build."); println("Compiling DEBUG build.")
} }
if(new File('../uCore').exists() && comp){ if(new File('../uCore').exists() && comp){

View File

@@ -293,7 +293,7 @@ public class NetServer extends Module{
public void handleBlockDamaged(TileEntity entity){ public void handleBlockDamaged(TileEntity entity){
BlockUpdatePacket packet = new BlockUpdatePacket(); BlockUpdatePacket packet = new BlockUpdatePacket();
packet.health = entity.health; packet.health = (int)entity.health;
packet.position = entity.tile.packedPosition(); packet.position = entity.tile.packedPosition();
Net.send(packet, SendMode.udp); Net.send(packet, SendMode.udp);
} }

View File

@@ -391,7 +391,7 @@ public class Renderer extends RendererModule{
target = tile.getLinked(); target = tile.getLinked();
if(target.entity != null) if(target.entity != null)
drawHealth(target.drawx(), target.drawy() - 3f - target.block().height / 2f * Vars.tilesize, target.entity.health, target.entity.maxhealth); drawHealth(target.drawx(), target.drawy() - 3f - target.block().height / 2f * Vars.tilesize, target.entity.health, target.entity.tile.block().health);
target.block().drawSelect(target); target.block().drawSelect(target);
} }

View File

@@ -20,10 +20,12 @@ import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
public class TileEntity extends Entity{ public class TileEntity extends Entity{
private static final boolean friendlyFire = false;
public Tile tile; public Tile tile;
public int[] items = new int[Item.getAllItems().size]; public int[] items = new int[Item.getAllItems().size];
public Timer timer; public Timer timer;
public int maxhealth, health; public float health;
public boolean dead = false; public boolean dead = false;
public boolean added; public boolean added;
@@ -34,8 +36,7 @@ public class TileEntity extends Entity{
x = tile.worldx(); x = tile.worldx();
y = tile.worldy(); y = tile.worldy();
maxhealth = tile.block().health; health = tile.block().health;
health = maxhealth;
timer = new Timer(tile.block().timers); timer = new Timer(tile.block().timers);
@@ -101,13 +102,13 @@ public class TileEntity extends Entity{
} }
public boolean collide(Bullet other){ public boolean collide(Bullet other){
return other.owner instanceof Enemy; return other.owner instanceof Enemy || friendlyFire;
} }
@Override @Override
public void update(){ public void update(){
if(health != 0 && health < tile.block().health && !(tile.block() instanceof Wall) && if(health != 0 && health < tile.block().health && !(tile.block() instanceof Wall) &&
Mathf.chance(0.009f*Timers.delta()*(1f-(float)health/maxhealth))){ Mathf.chance(0.009f*Timers.delta()*(1f-health/tile.block().health))){
Effects.effect(Fx.smoke, x+Mathf.range(4), y+Mathf.range(4)); Effects.effect(Fx.smoke, x+Mathf.range(4), y+Mathf.range(4));
} }

View File

@@ -261,7 +261,7 @@ public class Save12 extends SaveFileVersion {
if(tile.entity != null){ if(tile.entity != null){
stream.writeByte(tile.getRotation()); //rotation stream.writeByte(tile.getRotation()); //rotation
stream.writeInt(tile.entity.health); //health stream.writeInt((int)tile.entity.health); //health
int amount = 0; int amount = 0;
for(int i = 0; i < tile.entity.items.length; i ++){ for(int i = 0; i < tile.entity.items.length; i ++){
if(tile.entity.items[i] > 0) amount ++; if(tile.entity.items[i] > 0) amount ++;

View File

@@ -290,7 +290,7 @@ public class Save13 extends SaveFileVersion {
if(tile.entity != null){ if(tile.entity != null){
stream.writeByte(tile.getRotation()); //rotation stream.writeByte(tile.getRotation()); //rotation
stream.writeShort(tile.entity.health); //health stream.writeShort((short)tile.entity.health); //health
byte amount = 0; byte amount = 0;
for(int i = 0; i < tile.entity.items.length; i ++){ for(int i = 0; i < tile.entity.items.length; i ++){
if(tile.entity.items[i] > 0) amount ++; if(tile.entity.items[i] > 0) amount ++;

View File

@@ -319,7 +319,7 @@ public class Save14 extends SaveFileVersion{
if(tile.entity != null){ if(tile.entity != null){
stream.writeByte(tile.getRotation()); //rotation stream.writeByte(tile.getRotation()); //rotation
stream.writeShort(tile.entity.health); //health stream.writeShort((short)tile.entity.health); //health
byte amount = 0; byte amount = 0;
for(int i = 0; i < tile.entity.items.length; i ++){ for(int i = 0; i < tile.entity.items.length; i ++){
if(tile.entity.items[i] > 0) amount ++; if(tile.entity.items[i] > 0) amount ++;

View File

@@ -324,7 +324,7 @@ public class Save15 extends SaveFileVersion {
if(tile.entity != null){ if(tile.entity != null){
stream.writeByte(tile.getRotation()); //rotation stream.writeByte(tile.getRotation()); //rotation
stream.writeShort(tile.entity.health); //health stream.writeShort((short)tile.entity.health); //health
byte amount = 0; byte amount = 0;
for(int i = 0; i < tile.entity.items.length; i ++){ for(int i = 0; i < tile.entity.items.length; i ++){
if(tile.entity.items[i] > 0) amount ++; if(tile.entity.items[i] > 0) amount ++;

View File

@@ -174,7 +174,7 @@ public class NetworkIO {
if(tile.entity != null){ if(tile.entity != null){
stream.writeShort(tile.getPackedData()); stream.writeShort(tile.getPackedData());
stream.writeShort(tile.entity.health); //health stream.writeShort((short)tile.entity.health); //health
//items //items
for(int i = 0; i < tile.entity.items.length; i ++){ for(int i = 0; i < tile.entity.items.length; i ++){

View File

@@ -26,6 +26,12 @@ public class PausedDialog extends FloatingDialog{
} }
void setup(){ void setup(){
update(() -> {
if(GameState.is(State.menu) && isShown()){
hide();
}
});
shown(() -> { shown(() -> {
wasPaused = GameState.is(State.paused); wasPaused = GameState.is(State.paused);
if(!Net.active()) GameState.set(State.paused); if(!Net.active()) GameState.set(State.paused);
@@ -36,7 +42,7 @@ public class PausedDialog extends FloatingDialog{
content().addButton("$text.back", () -> { content().addButton("$text.back", () -> {
hide(); hide();
if(!wasPaused || Net.active()) if((!wasPaused || Net.active()) && !GameState.is(State.menu))
GameState.set(State.playing); GameState.set(State.playing);
}); });
@@ -46,7 +52,7 @@ public class PausedDialog extends FloatingDialog{
content().row(); content().row();
content().addButton("$text.savegame", () -> { content().addButton("$text.savegame", () -> {
save.show(); save.show();
}); }).disabled(b -> Vars.world.getMap().id == -1);
content().row(); content().row();
content().addButton("$text.loadgame", () -> { content().addButton("$text.loadgame", () -> {
@@ -81,13 +87,15 @@ public class PausedDialog extends FloatingDialog{
new imagebutton("icon-play-2", isize, () -> { new imagebutton("icon-play-2", isize, () -> {
hide(); hide();
if(!wasPaused) if(!wasPaused && !GameState.is(State.menu))
GameState.set(State.playing); GameState.set(State.playing);
}).text("$text.back").padTop(4f); }).text("$text.back").padTop(4f);
new imagebutton("icon-tools", isize, ui.settings::show).text("$text.settings").padTop(4f); new imagebutton("icon-tools", isize, ui.settings::show).text("$text.settings").padTop(4f);
new imagebutton("icon-save", isize, save::show).text("$text.save").padTop(4f); imagebutton sa = new imagebutton("icon-save", isize, save::show);
sa.text("$text.save").padTop(4f);
sa.cell.disabled(b -> Vars.world.getMap().id == -1);
content().row(); content().row();

View File

@@ -1,8 +1,9 @@
package io.anuke.mindustry.ui.dialogs; package io.anuke.mindustry.ui.dialogs;
import com.badlogic.gdx.utils.reflect.ClassReflection; import com.badlogic.gdx.utils.reflect.ClassReflection;
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.io.Saves.SaveSlot; import io.anuke.mindustry.io.Saves.SaveSlot;
import io.anuke.ucore.core.Timers; import io.anuke.ucore.core.Timers;
import io.anuke.ucore.scene.ui.TextButton; import io.anuke.ucore.scene.ui.TextButton;
@@ -12,6 +13,12 @@ public class SaveDialog extends LoadDialog{
public SaveDialog() { public SaveDialog() {
super("$text.savegame"); super("$text.savegame");
update(() -> {
if(GameState.is(State.menu) && isShown()){
hide();
}
});
} }
public void addSetup(){ public void addSetup(){

View File

@@ -223,10 +223,10 @@ public class HudFragment implements Fragment{
} }
private void playButton(float uheight){ private void playButton(float uheight){
new imagebutton("icon-play", 30f, ()->{ new imagebutton("icon-play", 30f, () -> {
Vars.control.runWave(); Vars.control.runWave();
}).height(uheight).fillX().right().padTop(-8f).padBottom(-12f).padRight(-36).width(40f).update(l->{ }).height(uheight).fillX().right().padTop(-8f).padBottom(-12f).padRight(-36).width(40f).update(l->{
boolean vis = Vars.control.getMode().toggleWaves && Vars.control.getEnemiesRemaining() <= 0 && (Net.server() || !Net.active()); boolean vis = Vars.control.getEnemiesRemaining() <= 0 && (Net.server() || !Net.active());
boolean paused = GameState.is(State.paused) || !vis; boolean paused = GameState.is(State.paused) || !vis;
l.setVisible(vis); l.setVisible(vis);

View File

@@ -15,6 +15,7 @@ import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Strings; import io.anuke.ucore.util.Strings;
public class RepairTurret extends PowerTurret{ public class RepairTurret extends PowerTurret{
float repairPercent = 1f / 150f;
public RepairTurret(String name) { public RepairTurret(String name) {
super(name); super(name);
@@ -55,11 +56,13 @@ public class RepairTurret extends PowerTurret{
float target = entity.angleTo(entity.blockTarget); float target = entity.angleTo(entity.blockTarget);
entity.rotation = Mathf.slerp(entity.rotation, target, 0.16f*Timers.delta()); entity.rotation = Mathf.slerp(entity.rotation, target, 0.16f*Timers.delta());
if(entity.timer.get(timerReload, reload) && Angles.angleDist(target, entity.rotation) < shootCone){ int maxhealth = entity.blockTarget.tile.block().health;
entity.blockTarget.health++;
if(entity.blockTarget.health > entity.blockTarget.maxhealth) if(entity.timer.get(timerReload, reload) && Angles.angleDist(target, entity.rotation) < shootCone){
entity.blockTarget.health = entity.blockTarget.maxhealth; entity.blockTarget.health += maxhealth * repairPercent;
if(entity.blockTarget.health > maxhealth)
entity.blockTarget.health = maxhealth;
entity.power -= powerUsed; entity.power -= powerUsed;
} }