Player State reset / Improved messages / Round end time
This commit is contained in:
@@ -151,7 +151,7 @@ public class NetClient extends Module{
|
|||||||
|
|
||||||
@Remote(variants = Variant.both)
|
@Remote(variants = Variant.both)
|
||||||
public static void onInfoMessage(String message){
|
public static void onInfoMessage(String message){
|
||||||
threads.runGraphics(() -> ui.showInfo(message));
|
threads.runGraphics(() -> ui.showText("", message));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Remote(variants = Variant.both)
|
@Remote(variants = Variant.both)
|
||||||
|
|||||||
@@ -664,7 +664,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
dead = true;
|
dead = true;
|
||||||
trail.clear();
|
trail.clear();
|
||||||
health = maxHealth();
|
health = maxHealth();
|
||||||
mech = (mobile ? Mechs.starterMobile : Mechs.starterDesktop);
|
mech = (isMobile ? Mechs.starterMobile : Mechs.starterDesktop);
|
||||||
placeQueue.clear();
|
placeQueue.clear();
|
||||||
|
|
||||||
add();
|
add();
|
||||||
|
|||||||
@@ -39,10 +39,12 @@ import static io.anuke.mindustry.Vars.*;
|
|||||||
import static io.anuke.ucore.util.Log.*;
|
import static io.anuke.ucore.util.Log.*;
|
||||||
|
|
||||||
public class ServerControl extends Module{
|
public class ServerControl extends Module{
|
||||||
|
private static final int roundExtraTime = 12;
|
||||||
|
|
||||||
private final CommandHandler handler = new CommandHandler("");
|
private final CommandHandler handler = new CommandHandler("");
|
||||||
private ShuffleMode mode;
|
private ShuffleMode mode;
|
||||||
//consecutive sector losses
|
|
||||||
private int gameOvers;
|
private int gameOvers;
|
||||||
|
private boolean inExtraRound;
|
||||||
|
|
||||||
public ServerControl(String[] args){
|
public ServerControl(String[] args){
|
||||||
Settings.defaultList(
|
Settings.defaultList(
|
||||||
@@ -89,10 +91,10 @@ public class ServerControl extends Module{
|
|||||||
}
|
}
|
||||||
|
|
||||||
Events.on(GameOverEvent.class, () -> {
|
Events.on(GameOverEvent.class, () -> {
|
||||||
|
if(inExtraRound) return;
|
||||||
info("Game over!");
|
info("Game over!");
|
||||||
|
|
||||||
if(mode != ShuffleMode.off){
|
if(mode != ShuffleMode.off){
|
||||||
Call.onInfoMessage("Game over!");
|
|
||||||
if(world.getSector() == null){
|
if(world.getSector() == null){
|
||||||
if(world.maps().all().size > 0){
|
if(world.maps().all().size > 0){
|
||||||
Array<Map> maps = mode == ShuffleMode.both ? world.maps().all() :
|
Array<Map> maps = mode == ShuffleMode.both ? world.maps().all() :
|
||||||
@@ -104,13 +106,18 @@ public class ServerControl extends Module{
|
|||||||
while(map == previous) map = maps.random();
|
while(map == previous) map = maps.random();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Call.onInfoMessage("[SCARLET]Game over![]\nNext selected map:[accent] "+map.name+"[]"
|
||||||
|
+ (map.meta.author() != null ? " by[accent] " + map.meta.author() + "[]" : "") + "."+
|
||||||
|
"\nNew game begins in " + roundExtraTime + " seconds.");
|
||||||
|
|
||||||
info("Selected next map to be {0}.", map.name);
|
info("Selected next map to be {0}.", map.name);
|
||||||
|
|
||||||
Map fmap = map;
|
Map fmap = map;
|
||||||
|
|
||||||
play(() -> world.loadMap(fmap));
|
play(true, () -> world.loadMap(fmap));
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
Call.onInfoMessage("Sector has been lost.\nRe-deploying in " + roundExtraTime + " seconds.");
|
||||||
if(gameOvers >= 2){
|
if(gameOvers >= 2){
|
||||||
Settings.putInt("sector_y", Settings.getInt("sector_y") < 0 ? Settings.getInt("sector_y") + 1 : Settings.getInt("sector_y") - 1);
|
Settings.putInt("sector_y", Settings.getInt("sector_y") < 0 ? Settings.getInt("sector_y") + 1 : Settings.getInt("sector_y") - 1);
|
||||||
Settings.save();
|
Settings.save();
|
||||||
@@ -197,7 +204,7 @@ public class ServerControl extends Module{
|
|||||||
|
|
||||||
}else{
|
}else{
|
||||||
Log.info("&ly&fiNo map specified. Loading sector {0}, {1}.", Settings.getInt("sector_x"), Settings.getInt("sector_y"));
|
Log.info("&ly&fiNo map specified. Loading sector {0}, {1}.", Settings.getInt("sector_x"), Settings.getInt("sector_y"));
|
||||||
playSectorMap();
|
playSectorMap(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
info("Map loaded.");
|
info("Map loaded.");
|
||||||
@@ -845,6 +852,10 @@ public class ServerControl extends Module{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void playSectorMap(){
|
private void playSectorMap(){
|
||||||
|
playSectorMap(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void playSectorMap(boolean wait){
|
||||||
int x = Settings.getInt("sector_x"), y = Settings.getInt("sector_y");
|
int x = Settings.getInt("sector_x"), y = Settings.getInt("sector_y");
|
||||||
if(world.sectors().get(x, y) == null){
|
if(world.sectors().get(x, y) == null){
|
||||||
world.sectors().createSector(x, y);
|
world.sectors().createSector(x, y);
|
||||||
@@ -852,22 +863,32 @@ public class ServerControl extends Module{
|
|||||||
|
|
||||||
world.sectors().get(x, y).completedMissions = 0;
|
world.sectors().get(x, y).completedMissions = 0;
|
||||||
|
|
||||||
play(() -> world.loadSector(world.sectors().get(x, y)));
|
play(wait, () -> world.loadSector(world.sectors().get(x, y)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void play(Runnable run){
|
private void play(boolean wait, Runnable run){
|
||||||
Array<Player> players = new Array<>();
|
inExtraRound = true;
|
||||||
for(Player p : playerGroup.all()){
|
Runnable r = () -> {
|
||||||
players.add(p);
|
Array<Player> players = new Array<>();
|
||||||
p.setDead(true);
|
for(Player p : playerGroup.all()){
|
||||||
}
|
players.add(p);
|
||||||
logic.reset();
|
p.setDead(true);
|
||||||
Call.onWorldDataBegin();
|
}
|
||||||
run.run();
|
logic.reset();
|
||||||
logic.play();
|
Call.onWorldDataBegin();
|
||||||
for(Player p : players){
|
run.run();
|
||||||
p.add();
|
logic.play();
|
||||||
netServer.sendWorldData(p, p.con.id);
|
for(Player p : players){
|
||||||
|
p.reset();
|
||||||
|
netServer.sendWorldData(p, p.con.id);
|
||||||
|
}
|
||||||
|
inExtraRound = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
if(wait){
|
||||||
|
Timers.runTask(60f * roundExtraTime, r);
|
||||||
|
}else{
|
||||||
|
r.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -891,11 +912,10 @@ public class ServerControl extends Module{
|
|||||||
world.sectors().save();
|
world.sectors().save();
|
||||||
gameOvers = 0;
|
gameOvers = 0;
|
||||||
Settings.putInt("sector_x", world.getSector().x + world.getSector().size);
|
Settings.putInt("sector_x", world.getSector().x + world.getSector().size);
|
||||||
|
|
||||||
Settings.save();
|
Settings.save();
|
||||||
|
|
||||||
netServer.kickAll(KickReason.sectorComplete);
|
Call.onInfoMessage("[accent]Sector conquered![]\n" + roundExtraTime + " seconds until deployment in next sector.");
|
||||||
logic.reset();
|
|
||||||
playSectorMap();
|
playSectorMap();
|
||||||
}else if(world.getSector().currentMission().isComplete()){
|
}else if(world.getSector().currentMission().isComplete()){
|
||||||
//increment completed missions, check next index next frame
|
//increment completed missions, check next index next frame
|
||||||
|
|||||||
Reference in New Issue
Block a user