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