Somewhat functional rule selection
This commit is contained in:
@@ -642,7 +642,7 @@ public class Player extends Unit implements BuilderTrait, ShooterTrait{
|
||||
}
|
||||
|
||||
protected void updateFlying(){
|
||||
if(Units.invalidateTarget(target, this) && !(target instanceof TileEntity && ((TileEntity)target).damaged() && target.isValid() && ((TileEntity)target).isAdded() && target.getTeam() == team && mech.canHeal && dst(target) < getWeapon().bullet.range())){
|
||||
if(Units.invalidateTarget(target, this) && !(target instanceof TileEntity && ((TileEntity)target).damaged() && target.isValid() && target.getTeam() == team && mech.canHeal && dst(target) < getWeapon().bullet.range())){
|
||||
target = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -296,6 +296,11 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(){
|
||||
return !isDead() && tile.entity == this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityGroup targetGroup(){
|
||||
return tileGroup;
|
||||
|
||||
@@ -55,6 +55,7 @@ public class Map implements Comparable<Map>{
|
||||
Vars.data.modified();
|
||||
}
|
||||
|
||||
/** This creates a new instance.*/
|
||||
public Rules rules(){
|
||||
return JsonIO.read(Rules.class, tags.get("rules", "{}"));
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@ import static io.anuke.mindustry.Vars.tilesize;
|
||||
|
||||
public class CustomRulesDialog extends FloatingDialog{
|
||||
private Table main;
|
||||
public Rules rules;
|
||||
private Rules rules;
|
||||
private Supplier<Rules> resetter;
|
||||
|
||||
public CustomRulesDialog(){
|
||||
super("$mode.custom");
|
||||
@@ -22,9 +23,9 @@ public class CustomRulesDialog extends FloatingDialog{
|
||||
addCloseButton();
|
||||
}
|
||||
|
||||
public void show(Rules rules){
|
||||
public void show(Rules rules, Supplier<Rules> resetter){
|
||||
this.rules = rules;
|
||||
// this.selectedGamemode = gamemode;
|
||||
this.resetter = resetter;
|
||||
show();
|
||||
}
|
||||
|
||||
@@ -33,12 +34,12 @@ public class CustomRulesDialog extends FloatingDialog{
|
||||
cont.pane(m -> main = m);
|
||||
main.margin(10f);
|
||||
main.addButton("$settings.reset", () -> {
|
||||
//rules = selectedGamemode.get();
|
||||
rules = resetter.get();
|
||||
setup();
|
||||
}).size(300f, 50f);
|
||||
main.left().defaults().fillX().left().pad(5);
|
||||
main.row();
|
||||
|
||||
|
||||
title("$rules.title.waves");
|
||||
check("$rules.waves", b -> rules.waves = b, () -> rules.waves);
|
||||
check("$rules.wavetimer", b -> rules.waveTimer = b, () -> rules.waveTimer, () -> rules.waves);
|
||||
@@ -47,8 +48,8 @@ public class CustomRulesDialog extends FloatingDialog{
|
||||
number("$rules.dropzoneradius", false, f -> rules.dropZoneRadius = f * tilesize, () -> rules.dropZoneRadius / tilesize, () -> rules.waves);
|
||||
|
||||
title("$rules.title.respawns");
|
||||
check("$rules.limitedRespawns", b -> rules.limitedRespawns= b, () -> rules.limitedRespawns);
|
||||
number("$rules.respawns", true, f -> rules.respawns = (int) f, () -> rules.respawns, () -> rules.limitedRespawns);
|
||||
check("$rules.limitedRespawns", b -> rules.limitedRespawns = b, () -> rules.limitedRespawns);
|
||||
number("$rules.respawns", true, f -> rules.respawns = (int)f, () -> rules.respawns, () -> rules.limitedRespawns);
|
||||
number("$rules.respawntime", f -> rules.respawnTime = f * 60f, () -> rules.respawnTime / 60f);
|
||||
|
||||
title("$rules.title.resourcesbuilding");
|
||||
@@ -78,11 +79,11 @@ public class CustomRulesDialog extends FloatingDialog{
|
||||
main.table(t -> {
|
||||
t.left();
|
||||
t.add(text).left().padRight(5)
|
||||
.update(a->a.setColor(condition.get() ? Color.WHITE : Color.GRAY));
|
||||
.update(a -> a.setColor(condition.get() ? Color.WHITE : Color.GRAY));
|
||||
Platform.instance.addDialog(t.addField((integer ? (int)prov.get() : prov.get()) + "", s -> cons.accept(Strings.parseFloat(s)))
|
||||
.padRight(100f)
|
||||
.update(a -> a.setDisabled(!condition.get()))
|
||||
.valid(Strings::canParsePositiveFloat).width(120f) .left().get());
|
||||
.padRight(100f)
|
||||
.update(a -> a.setDisabled(!condition.get()))
|
||||
.valid(Strings::canParsePositiveFloat).width(120f).left().get());
|
||||
}).padTop(0);
|
||||
main.row();
|
||||
}
|
||||
|
||||
@@ -4,14 +4,14 @@ import io.anuke.arc.Core;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.scene.event.Touchable;
|
||||
import io.anuke.arc.scene.ui.*;
|
||||
import io.anuke.arc.scene.ui.ScrollPane;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.arc.util.Scaling;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.maps.Map;
|
||||
import io.anuke.mindustry.ui.BorderImage;
|
||||
|
||||
import static io.anuke.mindustry.Vars.state;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class MapPlayDialog extends FloatingDialog{
|
||||
Difficulty difficulty = Difficulty.normal;
|
||||
@@ -21,18 +21,14 @@ public class MapPlayDialog extends FloatingDialog{
|
||||
|
||||
public MapPlayDialog(){
|
||||
super("");
|
||||
addCloseButton();
|
||||
}
|
||||
|
||||
public void show(Map map){
|
||||
title.setText(map.name());
|
||||
cont.clearChildren();
|
||||
|
||||
selectedGamemode = Gamemode.survival;
|
||||
rules = selectedGamemode.apply(new Rules());
|
||||
rules = map.rules();
|
||||
|
||||
Table selmode = new Table();
|
||||
ButtonGroup<TextButton> group = new ButtonGroup<>();
|
||||
selmode.add("$level.mode").colspan(4);
|
||||
selmode.row();
|
||||
int i = 0;
|
||||
@@ -47,11 +43,9 @@ public class MapPlayDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
modes.addButton(mode.toString(), "toggle", () -> {
|
||||
selectedGamemode = mode;
|
||||
//rules = mode.get();
|
||||
//dialog.selectedGamemode = null;
|
||||
dialog.rules = null;
|
||||
}).update(b -> b.setChecked(selectedGamemode == mode)).group(group).size(140f, 54f);
|
||||
selectedGamemode = selectedGamemode == mode ? null : mode;
|
||||
rules = mode.apply(map.rules());
|
||||
}).update(b -> b.setChecked(selectedGamemode == mode)).size(140f, 54f);
|
||||
if(i++ % 2 == 1) modes.row();
|
||||
}
|
||||
selmode.add(modes);
|
||||
@@ -83,7 +77,7 @@ public class MapPlayDialog extends FloatingDialog{
|
||||
difficulty = (ds[Mathf.mod(difficulty.ordinal() + 1, ds.length)]);
|
||||
state.wavetime = difficulty.waveTime;
|
||||
}).width(s);
|
||||
sdif.addButton("$customize", () -> dialog.show(rules)).width(140).padLeft(10);
|
||||
sdif.addButton("$customize", () -> dialog.show(rules, () -> rules = (selectedGamemode == null ? map.rules() : selectedGamemode.apply(map.rules())))).width(140).padLeft(10);
|
||||
|
||||
cont.add(sdif);
|
||||
cont.row();
|
||||
@@ -93,6 +87,15 @@ public class MapPlayDialog extends FloatingDialog{
|
||||
}
|
||||
cont.add(new BorderImage(map.texture, 3f)).grow().get().setScaling(Scaling.fit);
|
||||
|
||||
buttons.clearChildren();
|
||||
addCloseButton();
|
||||
|
||||
buttons.addImageTextButton("$play", "icon-play", 8*3, () -> {
|
||||
control.playMap(map, rules);
|
||||
hide();
|
||||
ui.custom.hide();
|
||||
}).size(210f, 64f);
|
||||
|
||||
show();
|
||||
}
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ public class HudFragment extends Fragment{
|
||||
|
||||
Table wavesMain, editorMain;
|
||||
|
||||
cont.stack(wavesMain = new Table(), editorMain = new Table());
|
||||
cont.stack(wavesMain = new Table(), editorMain = new Table()).height(e -> wavesMain.isVisible() ? wavesMain.getPrefHeight() : editorMain.getPrefHeight());
|
||||
|
||||
{
|
||||
wavesMain.visible(() -> shown && !state.isEditor());
|
||||
|
||||
Reference in New Issue
Block a user