mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-09 23:37:51 +07:00
Tutorial sector prototype / New mission display
This commit is contained in:
@ -60,10 +60,11 @@ text.sector.unexplored=[accent][[Unexplored]
|
||||
text.mission=Mission:[LIGHT_GRAY] {0}
|
||||
text.mission.complete=Mission complete!
|
||||
text.mission.complete.body=Sector {0},{1} has been conquered.
|
||||
text.mission.wave=Survive [accent]{0}[] waves.
|
||||
text.mission.wave=Survive [accent]{0} []waves.
|
||||
text.mission.battle=Destroy the enemy base.
|
||||
text.mission.resource=Obtain {0} x{1}
|
||||
text.mission.block=Create '{0}' structure
|
||||
text.mission.block=Create {0}
|
||||
text.mission.unit=Create {0} Unit
|
||||
text.none=<none>
|
||||
text.close=Close
|
||||
text.quit=Quit
|
||||
|
@ -48,7 +48,7 @@ public class Vars{
|
||||
public static final int maxNameLength = 40;
|
||||
public static final float itemSize = 5f;
|
||||
public static final int tilesize = 8;
|
||||
public static final int sectorSize = 150;
|
||||
public static final int sectorSize = 140;
|
||||
public static final int mapPadding = 3;
|
||||
public static final int invalidSector = Integer.MAX_VALUE;
|
||||
public static Locale[] locales;
|
||||
|
@ -375,6 +375,7 @@ public class Control extends Module{
|
||||
Platform.instance.updateRPC();
|
||||
}
|
||||
|
||||
//TODO move sector code into logic class
|
||||
//check unlocked sectors
|
||||
if(world.getSector() != null && !world.getSector().complete){
|
||||
//all assigned missions are complete
|
||||
@ -385,9 +386,10 @@ public class Control extends Module{
|
||||
world.sectors().save();
|
||||
ui.missions.show(world.getSector());
|
||||
}else if(world.getSector().currentMission().isComplete()){
|
||||
state.mode = world.getSector().currentMission().getMode();
|
||||
world.getSector().currentMission().onComplete();
|
||||
//increment completed missions, check next index next frame
|
||||
world.getSector().completedMissions ++;
|
||||
state.mode = world.getSector().currentMission().getMode();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,9 +42,7 @@ public class EventType{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from the logic thread. Do not access graphics here!
|
||||
*/
|
||||
/**Called from the logic thread. Do not access graphics here!*/
|
||||
public static class TileChangeEvent implements Event{
|
||||
public final Tile tile;
|
||||
|
||||
|
@ -22,6 +22,7 @@ public enum GameMode{
|
||||
hidden = true;
|
||||
enemyCheat = false;
|
||||
showPads = true;
|
||||
showMission = false;
|
||||
}},
|
||||
pvp{{
|
||||
showPads = true;
|
||||
@ -32,7 +33,7 @@ public enum GameMode{
|
||||
respawnTime = 60 * 10;
|
||||
}};
|
||||
|
||||
public boolean infiniteResources, disableWaveTimer, disableWaves, hidden, enemyCheat, isPvp, showPads;
|
||||
public boolean infiniteResources, disableWaveTimer, disableWaves, showMission = true, hidden, enemyCheat, isPvp, showPads;
|
||||
public float enemyCoreBuildRadius = 400f;
|
||||
public float respawnTime = 60 * 4;
|
||||
|
||||
|
@ -3,18 +3,17 @@ package io.anuke.mindustry.maps;
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.badlogic.gdx.graphics.Pixmap.Format;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.math.GridPoint2;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.content.Items;
|
||||
import io.anuke.mindustry.content.UnitTypes;
|
||||
import io.anuke.mindustry.content.blocks.*;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.io.SaveIO;
|
||||
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.maps.missions.*;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.world.ColorMapper;
|
||||
import io.anuke.mindustry.world.Edges;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.core.Settings;
|
||||
import io.anuke.ucore.entities.Entities;
|
||||
@ -177,9 +176,16 @@ public class Sectors{
|
||||
Sector sector = get(x, y);
|
||||
sector.complete = true;
|
||||
|
||||
//TODO work for unique width + height?
|
||||
for(GridPoint2 point : Edges.getEdges(sector.width)){
|
||||
createSector(sector.x + point.x, sector.y + point.y);
|
||||
for(int sx = 0; sx < sector.width + 2; sx++){
|
||||
for(int sy = 0; sy < sector.height + 2; sy++){
|
||||
if((sx == 0 || sy == 0 || sx == sector.width + 1 || sy == sector.height + 1) &&
|
||||
!((sx == 0 && sy == 0)
|
||||
|| (sx == 0 && sy == sector.height+1)
|
||||
|| (sx == sector.width+1 && sy == 0)
|
||||
|| (sx == sector.width+1 && sy == sector.height+1))){
|
||||
createSector(sector.x + sx - 1, sector.y + sy - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -244,7 +250,27 @@ public class Sectors{
|
||||
sector.difficulty = (int)(Mathf.dst(sector.x, sector.y));
|
||||
|
||||
if(sector.difficulty == 0){
|
||||
sector.missions.add(new WaveMission(10));
|
||||
//TODO make specfic expansion sector have specific ores
|
||||
sector.missions.addAll(Array.with(
|
||||
new ItemMission(Items.copper, 30),
|
||||
new BlockMission(ProductionBlocks.mechanicalDrill),
|
||||
new BlockMission(DistributionBlocks.conveyor),
|
||||
new ItemMission(Items.copper, 40),
|
||||
new BlockMission(TurretBlocks.duo),
|
||||
new WaveMission(5),
|
||||
new ExpandMission(1, 0),
|
||||
new ItemMission(Items.lead, 30),
|
||||
new BlockMission(CraftingBlocks.smelter),
|
||||
new ItemMission(Items.densealloy, 30),
|
||||
new BlockMission(PowerBlocks.combustionGenerator),
|
||||
new BlockMission(PowerBlocks.powerNode),
|
||||
new BlockMission(CraftingBlocks.siliconsmelter),
|
||||
new ItemMission(Items.silicon, 30),
|
||||
new BlockMission(UnitBlocks.daggerFactory),
|
||||
new UnitMission(UnitTypes.dagger),
|
||||
new ExpandMission(0, 1),
|
||||
new BattleMission()
|
||||
));
|
||||
}else{
|
||||
sector.missions.add(Mathf.randomSeed(sector.getSeed() + 1) < waveChance ? new WaveMission(Math.min(sector.difficulty*5 + Mathf.randomSeed(sector.getSeed(), 0, 3)*5, 100))
|
||||
: new BattleMission());
|
||||
@ -265,8 +291,8 @@ public class Sectors{
|
||||
sector.startingItems = Array.with(new ItemStack(Items.copper, 700), new ItemStack(Items.lead, 200), new ItemStack(Items.densealloy, 130));
|
||||
}else if(sector.difficulty > 1){ //more starter items for faster start
|
||||
sector.startingItems = Array.with(new ItemStack(Items.copper, 400), new ItemStack(Items.lead, 100));
|
||||
}else{ //base starting items to prevent grinding much
|
||||
sector.startingItems = Array.with(new ItemStack(Items.copper, 130));
|
||||
}else{ //empty default
|
||||
sector.startingItems = Array.with();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -241,6 +241,7 @@ public class WorldGenerator{
|
||||
return generateTile(result, sectorX, sectorY, localX, localY, detailed, null);
|
||||
}
|
||||
|
||||
//TODO include tile in result
|
||||
/**
|
||||
* Gets the generation result from a specific sector at specific coordinates.
|
||||
* @param result where to put the generation results
|
||||
|
@ -13,12 +13,13 @@ public abstract class ActionMission implements Mission{
|
||||
this.runner = runner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete(){
|
||||
threads.run(runner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isComplete(){
|
||||
if(runner != null){
|
||||
threads.run(runner);
|
||||
runner = null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -9,11 +9,11 @@ import io.anuke.ucore.util.Bundles;
|
||||
import static io.anuke.mindustry.Vars.state;
|
||||
|
||||
/**A mission that is completed when the player obtains items in their core.*/
|
||||
public class ResourceMission implements Mission{
|
||||
public class ItemMission implements Mission{
|
||||
private final Item item;
|
||||
private final int amount;
|
||||
|
||||
public ResourceMission(Item item, int amount){
|
||||
public ItemMission(Item item, int amount){
|
||||
this.item = item;
|
||||
this.amount = amount;
|
||||
}
|
@ -2,6 +2,7 @@ package io.anuke.mindustry.maps.missions;
|
||||
|
||||
import com.badlogic.gdx.math.GridPoint2;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.content.blocks.StorageBlocks;
|
||||
import io.anuke.mindustry.game.GameMode;
|
||||
import io.anuke.mindustry.game.SpawnGroup;
|
||||
@ -13,7 +14,16 @@ import io.anuke.ucore.scene.ui.layout.Table;
|
||||
public interface Mission{
|
||||
boolean isComplete();
|
||||
String displayString();
|
||||
GameMode getMode();
|
||||
|
||||
default GameMode getMode(){
|
||||
return GameMode.noWaves;
|
||||
}
|
||||
|
||||
default void onComplete(){
|
||||
if(!Vars.headless){
|
||||
//TODO show 'mission complete' message somewhere
|
||||
}
|
||||
}
|
||||
|
||||
default void display(Table table){
|
||||
table.add(displayString());
|
||||
|
35
core/src/io/anuke/mindustry/maps/missions/UnitMission.java
Normal file
35
core/src/io/anuke/mindustry/maps/missions/UnitMission.java
Normal file
@ -0,0 +1,35 @@
|
||||
package io.anuke.mindustry.maps.missions;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.entities.units.BaseUnit;
|
||||
import io.anuke.mindustry.entities.units.UnitType;
|
||||
import io.anuke.mindustry.game.GameMode;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
|
||||
public class UnitMission implements Mission{
|
||||
private final UnitType type;
|
||||
|
||||
public UnitMission(UnitType type){
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isComplete(){
|
||||
for(BaseUnit unit : Vars.unitGroups[Vars.defaultTeam.ordinal()].all()){
|
||||
if(unit.getType() == type){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String displayString(){
|
||||
return Bundles.format("text.mission.unit", type.localizedName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameMode getMode(){
|
||||
return GameMode.noWaves;
|
||||
}
|
||||
}
|
@ -37,7 +37,7 @@ public class WaveMission implements Mission{
|
||||
|
||||
@Override
|
||||
public String displayString(){
|
||||
return Bundles.format("text.mission.wave", target);
|
||||
return Bundles.format("text.mission.wave", state.wave);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -320,17 +320,9 @@ public class HudFragment extends Fragment{
|
||||
IntFormat timef = new IntFormat("text.wave.waiting");
|
||||
|
||||
table.background("button");
|
||||
table.left().table(text -> {
|
||||
text.left();
|
||||
text.label(() -> wavef.get(state.wave)).left().get().setFontScale(fontScale * 1.5f);
|
||||
text.row();
|
||||
text.label(() -> unitGroups[Team.red.ordinal()].size() > 0 && state.mode.disableWaveTimer ?
|
||||
getEnemiesRemaining() : (state.mode.disableWaveTimer) ? "$text.waiting" :
|
||||
timef.get((int) (state.wavetime / 60f))).minWidth(126).left();
|
||||
});
|
||||
table.left().labelWrap(() -> world.getSector() == null ? wavef.get(state.wave) : world.getSector().currentMission().displayString()).left().growX();
|
||||
|
||||
table.add().growX();
|
||||
table.visible(() -> !state.mode.disableWaves);
|
||||
table.visible(() -> !((world.getSector() == null && state.mode.disableWaves) || !state.mode.showMission));
|
||||
|
||||
playButton(uheight);
|
||||
}
|
||||
|
@ -913,6 +913,7 @@ public class ServerControl extends Module{
|
||||
|
||||
playSectorMap();
|
||||
}else if(world.getSector().currentMission().isComplete()){
|
||||
world.getSector().currentMission().onComplete();
|
||||
//increment completed missions, check next index next frame
|
||||
world.getSector().completedMissions ++;
|
||||
}
|
||||
|
Reference in New Issue
Block a user