mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-11 11:17:11 +07:00
Added sector mission display and generation
This commit is contained in:
parent
a045ec9d46
commit
b2d61a93d9
@ -52,13 +52,17 @@ text.addplayers=Add/Remove Players
|
||||
text.customgame=Custom Game
|
||||
text.campaign=Campaign
|
||||
text.sectors=Sectors
|
||||
text.sector=Selected Sector: [LIGHT_GRAY]{0}
|
||||
text.sector=Sector: [LIGHT_GRAY]{0}
|
||||
text.sector.time=Time: [LIGHT_GRAY]{0}
|
||||
text.sector.deploy=Deploy
|
||||
text.sector.resume=Resume
|
||||
text.sector.unlocked=Sector completed!
|
||||
text.sector.locked=[scarlet][[Incomplete]
|
||||
text.sector.unexplored=[accent][[Unexplored]
|
||||
text.mission=Mission:[LIGHT_GRAY] {0}
|
||||
text.mission.wave=Survive [accent]{0}[] waves.
|
||||
text.mission.battle=Destroy the enemy base.
|
||||
text.none=<none>
|
||||
text.close=Close
|
||||
text.quit=Quit
|
||||
text.maps=Maps
|
||||
|
@ -33,6 +33,7 @@ Color: {
|
||||
lightgray: {a: 1, b: 0.65, g: 0.65, r: 0.65 }
|
||||
orange: {hex: "FFA500"},
|
||||
accent: {hex: "f4ba6e"},
|
||||
accentDark: {hex: "f4ba6e"},
|
||||
},
|
||||
TintedDrawable: {
|
||||
dialogDim: {name: white, color: {r: 0, g: 0, b: 0, a: 0.9} },
|
||||
|
@ -28,6 +28,8 @@ public class Sector{
|
||||
public transient Array<SpawnGroup> spawns = new Array<>();
|
||||
/**Ores that appear in this sector.*/
|
||||
public transient Array<Item> ores = new Array<>();
|
||||
/**Difficulty of the sector, measured by calculating distance from origin.*/
|
||||
public transient int difficulty;
|
||||
|
||||
public int getSeed(){
|
||||
return Bits.packInt(x, y);
|
||||
|
@ -10,6 +10,7 @@ import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.maps.generation.WorldGenerator.GenResult;
|
||||
import io.anuke.mindustry.maps.missions.BattleMission;
|
||||
import io.anuke.mindustry.maps.missions.WaveMission;
|
||||
import io.anuke.mindustry.world.ColorMapper;
|
||||
import io.anuke.mindustry.world.Edges;
|
||||
import io.anuke.ucore.core.Settings;
|
||||
@ -130,15 +131,23 @@ public class Sectors{
|
||||
}
|
||||
|
||||
private void initSector(Sector sector){
|
||||
sector.mission = new BattleMission();
|
||||
sector.difficulty = (int)(Mathf.dst(sector.x, sector.y)/2);
|
||||
|
||||
if(sector.difficulty < 1){
|
||||
sector.mission = new WaveMission(30);
|
||||
}else{
|
||||
sector.mission = Mathf.choose(
|
||||
new BattleMission(sector.difficulty),
|
||||
new WaveMission(30 + sector.difficulty*5 + Mathf.randomSeed(sector.getSeed(), 0, 5)*5)
|
||||
);
|
||||
}
|
||||
|
||||
//add all ores for now since material differences aren't well handled yet
|
||||
sector.ores.addAll(Items.tungsten, Items.coal, Items.lead, Items.thorium, Items.titanium);
|
||||
}
|
||||
|
||||
private int round2(int i){
|
||||
if(i < 0){
|
||||
i --;
|
||||
}
|
||||
if(i < 0) i --;
|
||||
return i/2*2;
|
||||
}
|
||||
|
||||
|
@ -5,8 +5,19 @@ import io.anuke.mindustry.content.blocks.StorageBlocks;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.maps.Sector;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
|
||||
public class BattleMission implements Mission{
|
||||
private final int difficulty;
|
||||
|
||||
public BattleMission(int difficulty){
|
||||
this.difficulty = difficulty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String displayString(){
|
||||
return Bundles.get("text.mission.battle");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(Tile[][] tiles, Sector sector){
|
||||
|
@ -5,6 +5,7 @@ import io.anuke.mindustry.world.Tile;
|
||||
|
||||
public interface Mission{
|
||||
boolean isComplete();
|
||||
String displayString();
|
||||
|
||||
default void generate(Tile[][] tiles, Sector sector){}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package io.anuke.mindustry.maps.missions;
|
||||
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class WaveMission implements Mission{
|
||||
@ -9,6 +11,11 @@ public class WaveMission implements Mission{
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String displayString(){
|
||||
return Bundles.format("text.mission.wave", target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isComplete(){
|
||||
return state.wave >= target;
|
||||
|
@ -12,7 +12,6 @@ import io.anuke.ucore.scene.Element;
|
||||
import io.anuke.ucore.scene.event.ClickListener;
|
||||
import io.anuke.ucore.scene.event.InputEvent;
|
||||
import io.anuke.ucore.scene.event.InputListener;
|
||||
import io.anuke.ucore.scene.ui.TextButton;
|
||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
import io.anuke.ucore.scene.utils.Cursors;
|
||||
import io.anuke.ucore.scene.utils.ScissorStack;
|
||||
@ -37,18 +36,21 @@ public class SectorsDialog extends FloatingDialog{
|
||||
|
||||
addCloseButton();
|
||||
|
||||
content().label(() -> Bundles.format("text.sector", selected == null ? "<none>" :
|
||||
content().label(() -> Bundles.format("text.sector", selected == null ? Bundles.get("text.none") :
|
||||
(selected.x + ", " + selected.y + (!selected.complete && selected.saveID != -1 ? " " + Bundles.get("text.sector.locked") : ""))
|
||||
+ (selected.saveID == -1 ? " " + Bundles.get("text.sector.unexplored") :
|
||||
(selected.hasSave() ? " [accent]/[white] " + Bundles.format("text.sector.time", selected.getSave().getPlayTime()) : ""))));
|
||||
content().row();
|
||||
content().label(() -> Bundles.format("text.mission", selected == null ? Bundles.get("text.none") : selected.mission.displayString()));
|
||||
content().row();
|
||||
content().add(new SectorView()).grow();
|
||||
content().row();
|
||||
buttons().addImageTextButton("$text.sector.deploy", "icon-play", 10*3, () -> {
|
||||
hide();
|
||||
|
||||
ui.loadLogic(() -> world.sectors().playSector(selected));
|
||||
}).size(230f, 64f).name("deploy-button").disabled(b -> selected == null);
|
||||
}).size(230f, 64f).disabled(b -> selected == null)
|
||||
.update(t -> t.setText(selected != null && selected.hasSave() ? "$text.sector.resume" : "$text.sector.deploy"));
|
||||
|
||||
if(debug){
|
||||
buttons().addButton("unlock", () -> world.sectors().completeSector(selected.x, selected.y)).size(230f, 64f).disabled(b -> selected == null);
|
||||
@ -56,7 +58,6 @@ public class SectorsDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
void selectSector(Sector sector){
|
||||
buttons().<TextButton>find("deploy-button").setText(sector.hasSave() ? "$text.sector.resume" : "$text.sector.deploy");
|
||||
selected = sector;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user