Destroy units objective, WIP

This commit is contained in:
Anuken
2022-04-17 19:13:29 -04:00
parent d1cf1e2aba
commit 8364a6ac78
4 changed files with 52 additions and 29 deletions

View File

@@ -161,34 +161,6 @@ public class Control implements ApplicationListener, Loadable{
checkAutoUnlocks();
});
Events.on(BlockBuildEndEvent.class, e -> {
if(e.team == player.team()){
if(e.breaking){
state.stats.buildingsDeconstructed++;
}else{
state.stats.buildingsBuilt++;
}
}
});
Events.on(BlockDestroyEvent.class, e -> {
if(e.tile.team() == player.team()){
state.stats.buildingsDestroyed ++;
}
});
Events.on(UnitDestroyEvent.class, e -> {
if(e.unit.team() != player.team()){
state.stats.enemyUnitsDestroyed ++;
}
});
Events.on(UnitCreateEvent.class, e -> {
if(e.unit.team == state.rules.defaultTeam){
state.stats.unitsCreated++;
}
});
//delete save on campaign game over
Events.on(GameOverEvent.class, e -> {
if(state.isCampaign() && !net.client() && !headless){

View File

@@ -187,6 +187,34 @@ public class Logic implements ApplicationListener{
e.core.team.data().destroyToDerelict();
}
}));
Events.on(BlockBuildEndEvent.class, e -> {
if(e.team == state.rules.defaultTeam){
if(e.breaking){
state.stats.buildingsDeconstructed++;
}else{
state.stats.buildingsBuilt++;
}
}
});
Events.on(BlockDestroyEvent.class, e -> {
if(e.tile.team() == state.rules.defaultTeam){
state.stats.buildingsDestroyed ++;
}
});
Events.on(UnitDestroyEvent.class, e -> {
if(e.unit.team() != state.rules.defaultTeam){
state.stats.enemyUnitsDestroyed ++;
}
});
Events.on(UnitCreateEvent.class, e -> {
if(e.unit.team == state.rules.defaultTeam){
state.stats.unitsCreated++;
}
});
}
/** Adds starting items, resets wave time, and sets state to playing. */

View File

@@ -17,7 +17,7 @@ import static mindustry.Vars.*;
public class MapObjectives{
public static Prov<MapObjective>[] allObjectiveTypes = new Prov[]{
ResearchObjective::new, BuildCountObjective::new, UnitCountObjective::new, ItemObjective::new,
CommandModeObjective::new, CoreItemObjective::new, DestroyCoreObjective::new
CommandModeObjective::new, CoreItemObjective::new, DestroyCoreObjective::new, DestroyUnitsObjective::new
};
public static Prov<ObjectiveMarker>[] allMarkerTypes = new Prov[]{
@@ -142,6 +142,28 @@ public class MapObjectives{
}
}
/** Produce a certain amount of units. */
public static class DestroyUnitsObjective extends MapObjective{
public int count = 1;
public DestroyUnitsObjective(int count){
this.count = count;
}
public DestroyUnitsObjective(){
}
@Override
public String text(){
return Core.bundle.format("objective.destroyunits", count);
}
@Override
public boolean complete(){
return state.stats.enemyUnitsDestroyed >= count;
}
}
/** Command any unit to do anything. Always compete in headless mode. */
public static class CommandModeObjective extends MapObjective{