Added content mission / Working implementation of preset sectors
This commit is contained in:
@@ -2,6 +2,7 @@ package io.anuke.mindustry.maps;
|
||||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.content.Items;
|
||||
import io.anuke.mindustry.content.Liquids;
|
||||
import io.anuke.mindustry.content.Mechs;
|
||||
import io.anuke.mindustry.content.blocks.*;
|
||||
import io.anuke.mindustry.entities.units.UnitCommand;
|
||||
@@ -24,15 +25,6 @@ public class SectorPresets{
|
||||
Array.with(),
|
||||
1));
|
||||
|
||||
//water mission
|
||||
add(new SectorPreset(-2, 0,
|
||||
Structs.array(
|
||||
Missions.blockRecipe(LiquidBlocks.mechanicalPump),
|
||||
Missions.blockRecipe(ProductionBlocks.cultivator)
|
||||
),
|
||||
Array.with(Items.copper, Items.lead, Items.copper),
|
||||
2));
|
||||
|
||||
//command center mission
|
||||
add(new SectorPreset(2, 0,
|
||||
Structs.array(
|
||||
@@ -45,7 +37,7 @@ public class SectorPresets{
|
||||
Array.with(Items.copper, Items.lead, Items.copper),
|
||||
2));
|
||||
|
||||
//reconstructor mission
|
||||
//pad mission
|
||||
add(new SectorPreset(0, -2,
|
||||
Structs.array(
|
||||
Missions.blockRecipe(mobile ? UpgradeBlocks.tridentPad : UpgradeBlocks.deltaPad),
|
||||
@@ -56,10 +48,13 @@ public class SectorPresets{
|
||||
2));
|
||||
|
||||
//oil mission
|
||||
add(new SectorPreset(0, 1,
|
||||
add(new SectorPreset(-2, 0,
|
||||
Structs.array(
|
||||
Missions.blockRecipe(ProductionBlocks.cultivator),
|
||||
Missions.blockRecipe(CraftingBlocks.biomatterCompressor)
|
||||
Missions.blockRecipe(ProductionBlocks.waterExtractor),
|
||||
new ContentMission(Items.biomatter),
|
||||
Missions.blockRecipe(CraftingBlocks.biomatterCompressor),
|
||||
new ContentMission(Liquids.oil)
|
||||
),
|
||||
Array.with(Items.copper, Items.lead, Items.copper, Items.titanium),
|
||||
2));
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.badlogic.gdx.graphics.Pixmap.Format;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Json;
|
||||
import io.anuke.mindustry.content.Items;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.entities.units.BaseUnit;
|
||||
@@ -71,7 +72,6 @@ public class Sectors{
|
||||
threads.runGraphics(() -> ui.showError("$text.sector.corrupted"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**If a sector is not yet unlocked, returns null.*/
|
||||
@@ -243,7 +243,7 @@ public class Sectors{
|
||||
|
||||
for(int cx = 0; cx < sector.width; cx++){
|
||||
for(int cy = 0; cy < sector.height; cy++){
|
||||
grid.put(x + cx, y + cy, sector);
|
||||
grid.put(sector.x + cx, sector.y + cy, sector);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ public class FortressGenerator{
|
||||
seeder.get(PowerBlocks.thoriumReactor, tile -> tile.block() instanceof Drill && gen.random.chance(0.2) && gen.drillItem(tile.x, tile.y, (Drill)tile.block()) == Items.thorium && gen.random.chance(0.3)),
|
||||
|
||||
//water extractors
|
||||
seeder.get(ProductionBlocks.waterextractor, tile -> tile.block() instanceof NuclearReactor && gen.random.chance(0.5)),
|
||||
seeder.get(ProductionBlocks.waterExtractor, tile -> tile.block() instanceof NuclearReactor && gen.random.chance(0.5)),
|
||||
|
||||
//mend cores
|
||||
seeder.get(DefenseBlocks.mendProjector, tile -> tile.block() instanceof PowerGenerator && gen.random.chance(0.03)),
|
||||
|
||||
@@ -1,54 +1,12 @@
|
||||
package io.anuke.mindustry.maps.missions;
|
||||
|
||||
import io.anuke.mindustry.game.EventType.BlockBuildEvent;
|
||||
import io.anuke.mindustry.game.GameMode;
|
||||
import io.anuke.mindustry.type.Recipe;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.ucore.core.Events;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
|
||||
import static io.anuke.mindustry.Vars.defaultTeam;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
/**A mission in which the player must place a block somewhere.*/
|
||||
public class BlockMission extends Mission{
|
||||
private final Block block;
|
||||
private boolean complete;
|
||||
public class BlockMission extends ContentMission{
|
||||
|
||||
static{
|
||||
Events.on(BlockBuildEvent.class, event -> {
|
||||
if(world.getSector() != null && event.team == defaultTeam){
|
||||
Mission mission = world.getSector().currentMission();
|
||||
if(mission instanceof BlockMission){
|
||||
BlockMission block = (BlockMission)world.getSector().currentMission();
|
||||
if(block.block == event.tile.block()){
|
||||
block.complete = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public BlockMission(Block block){
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset(){
|
||||
complete = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isComplete(){
|
||||
return complete;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String displayString(){
|
||||
return Bundles.format("text.mission.block", block.formalName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameMode getMode(){
|
||||
return GameMode.noWaves;
|
||||
public BlockMission(Block block) {
|
||||
super(Recipe.getByResult(block));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package io.anuke.mindustry.maps.missions;
|
||||
|
||||
import io.anuke.mindustry.game.UnlockableContent;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
|
||||
public class ContentMission extends Mission {
|
||||
private final UnlockableContent content;
|
||||
private boolean done;
|
||||
|
||||
public ContentMission(UnlockableContent content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContentUsed(UnlockableContent content) {
|
||||
if(content == this.content){
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isComplete() {
|
||||
return done;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
done = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String displayString() {
|
||||
return Bundles.format("text.mission.create", content.localizedName());
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import io.anuke.mindustry.content.blocks.StorageBlocks;
|
||||
import io.anuke.mindustry.game.GameMode;
|
||||
import io.anuke.mindustry.game.SpawnGroup;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.game.UnlockableContent;
|
||||
import io.anuke.mindustry.maps.Sector;
|
||||
import io.anuke.mindustry.maps.generation.Generation;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
@@ -43,6 +44,11 @@ public abstract class Mission{
|
||||
return this;
|
||||
}
|
||||
|
||||
/**Called when a specified piece of content is 'used' by a block.*/
|
||||
public void onContentUsed(UnlockableContent content){
|
||||
|
||||
}
|
||||
|
||||
/**Draw mission overlay.*/
|
||||
public void drawOverlay(){
|
||||
|
||||
|
||||
Reference in New Issue
Block a user