UI bug cleanup, testing, balancing of repair turrets
This commit is contained in:
@@ -293,7 +293,7 @@ public class NetServer extends Module{
|
||||
|
||||
public void handleBlockDamaged(TileEntity entity){
|
||||
BlockUpdatePacket packet = new BlockUpdatePacket();
|
||||
packet.health = entity.health;
|
||||
packet.health = (int)entity.health;
|
||||
packet.position = entity.tile.packedPosition();
|
||||
Net.send(packet, SendMode.udp);
|
||||
}
|
||||
|
||||
@@ -391,7 +391,7 @@ public class Renderer extends RendererModule{
|
||||
target = tile.getLinked();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -20,10 +20,12 @@ import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class TileEntity extends Entity{
|
||||
private static final boolean friendlyFire = false;
|
||||
|
||||
public Tile tile;
|
||||
public int[] items = new int[Item.getAllItems().size];
|
||||
public Timer timer;
|
||||
public int maxhealth, health;
|
||||
public float health;
|
||||
public boolean dead = false;
|
||||
public boolean added;
|
||||
|
||||
@@ -33,9 +35,8 @@ public class TileEntity extends Entity{
|
||||
this.added = added;
|
||||
x = tile.worldx();
|
||||
y = tile.worldy();
|
||||
|
||||
maxhealth = tile.block().health;
|
||||
health = maxhealth;
|
||||
|
||||
health = tile.block().health;
|
||||
|
||||
timer = new Timer(tile.block().timers);
|
||||
|
||||
@@ -101,13 +102,13 @@ public class TileEntity extends Entity{
|
||||
}
|
||||
|
||||
public boolean collide(Bullet other){
|
||||
return other.owner instanceof Enemy;
|
||||
return other.owner instanceof Enemy || friendlyFire;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ public class Save12 extends SaveFileVersion {
|
||||
|
||||
if(tile.entity != null){
|
||||
stream.writeByte(tile.getRotation()); //rotation
|
||||
stream.writeInt(tile.entity.health); //health
|
||||
stream.writeInt((int)tile.entity.health); //health
|
||||
int amount = 0;
|
||||
for(int i = 0; i < tile.entity.items.length; i ++){
|
||||
if(tile.entity.items[i] > 0) amount ++;
|
||||
|
||||
@@ -290,7 +290,7 @@ public class Save13 extends SaveFileVersion {
|
||||
|
||||
if(tile.entity != null){
|
||||
stream.writeByte(tile.getRotation()); //rotation
|
||||
stream.writeShort(tile.entity.health); //health
|
||||
stream.writeShort((short)tile.entity.health); //health
|
||||
byte amount = 0;
|
||||
for(int i = 0; i < tile.entity.items.length; i ++){
|
||||
if(tile.entity.items[i] > 0) amount ++;
|
||||
|
||||
@@ -319,7 +319,7 @@ public class Save14 extends SaveFileVersion{
|
||||
|
||||
if(tile.entity != null){
|
||||
stream.writeByte(tile.getRotation()); //rotation
|
||||
stream.writeShort(tile.entity.health); //health
|
||||
stream.writeShort((short)tile.entity.health); //health
|
||||
byte amount = 0;
|
||||
for(int i = 0; i < tile.entity.items.length; i ++){
|
||||
if(tile.entity.items[i] > 0) amount ++;
|
||||
|
||||
@@ -324,7 +324,7 @@ public class Save15 extends SaveFileVersion {
|
||||
|
||||
if(tile.entity != null){
|
||||
stream.writeByte(tile.getRotation()); //rotation
|
||||
stream.writeShort(tile.entity.health); //health
|
||||
stream.writeShort((short)tile.entity.health); //health
|
||||
byte amount = 0;
|
||||
for(int i = 0; i < tile.entity.items.length; i ++){
|
||||
if(tile.entity.items[i] > 0) amount ++;
|
||||
|
||||
@@ -174,7 +174,7 @@ public class NetworkIO {
|
||||
|
||||
if(tile.entity != null){
|
||||
stream.writeShort(tile.getPackedData());
|
||||
stream.writeShort(tile.entity.health); //health
|
||||
stream.writeShort((short)tile.entity.health); //health
|
||||
|
||||
//items
|
||||
for(int i = 0; i < tile.entity.items.length; i ++){
|
||||
|
||||
@@ -26,6 +26,12 @@ public class PausedDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
void setup(){
|
||||
update(() -> {
|
||||
if(GameState.is(State.menu) && isShown()){
|
||||
hide();
|
||||
}
|
||||
});
|
||||
|
||||
shown(() -> {
|
||||
wasPaused = GameState.is(State.paused);
|
||||
if(!Net.active()) GameState.set(State.paused);
|
||||
@@ -36,7 +42,7 @@ public class PausedDialog extends FloatingDialog{
|
||||
|
||||
content().addButton("$text.back", () -> {
|
||||
hide();
|
||||
if(!wasPaused || Net.active())
|
||||
if((!wasPaused || Net.active()) && !GameState.is(State.menu))
|
||||
GameState.set(State.playing);
|
||||
});
|
||||
|
||||
@@ -46,7 +52,7 @@ public class PausedDialog extends FloatingDialog{
|
||||
content().row();
|
||||
content().addButton("$text.savegame", () -> {
|
||||
save.show();
|
||||
});
|
||||
}).disabled(b -> Vars.world.getMap().id == -1);
|
||||
|
||||
content().row();
|
||||
content().addButton("$text.loadgame", () -> {
|
||||
@@ -81,13 +87,15 @@ public class PausedDialog extends FloatingDialog{
|
||||
|
||||
new imagebutton("icon-play-2", isize, () -> {
|
||||
hide();
|
||||
if(!wasPaused)
|
||||
if(!wasPaused && !GameState.is(State.menu))
|
||||
GameState.set(State.playing);
|
||||
}).text("$text.back").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();
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
||||
|
||||
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.ucore.core.Timers;
|
||||
import io.anuke.ucore.scene.ui.TextButton;
|
||||
@@ -12,6 +13,12 @@ public class SaveDialog extends LoadDialog{
|
||||
|
||||
public SaveDialog() {
|
||||
super("$text.savegame");
|
||||
|
||||
update(() -> {
|
||||
if(GameState.is(State.menu) && isShown()){
|
||||
hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void addSetup(){
|
||||
|
||||
@@ -223,10 +223,10 @@ public class HudFragment implements Fragment{
|
||||
}
|
||||
|
||||
private void playButton(float uheight){
|
||||
new imagebutton("icon-play", 30f, ()->{
|
||||
new imagebutton("icon-play", 30f, () -> {
|
||||
Vars.control.runWave();
|
||||
}).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;
|
||||
|
||||
l.setVisible(vis);
|
||||
|
||||
@@ -15,6 +15,7 @@ import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Strings;
|
||||
|
||||
public class RepairTurret extends PowerTurret{
|
||||
float repairPercent = 1f / 150f;
|
||||
|
||||
public RepairTurret(String name) {
|
||||
super(name);
|
||||
@@ -55,11 +56,13 @@ public class RepairTurret extends PowerTurret{
|
||||
float target = entity.angleTo(entity.blockTarget);
|
||||
entity.rotation = Mathf.slerp(entity.rotation, target, 0.16f*Timers.delta());
|
||||
|
||||
int maxhealth = entity.blockTarget.tile.block().health;
|
||||
|
||||
if(entity.timer.get(timerReload, reload) && Angles.angleDist(target, entity.rotation) < shootCone){
|
||||
entity.blockTarget.health++;
|
||||
entity.blockTarget.health += maxhealth * repairPercent;
|
||||
|
||||
if(entity.blockTarget.health > entity.blockTarget.maxhealth)
|
||||
entity.blockTarget.health = entity.blockTarget.maxhealth;
|
||||
if(entity.blockTarget.health > maxhealth)
|
||||
entity.blockTarget.health = maxhealth;
|
||||
|
||||
entity.power -= powerUsed;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user