Made game-overs remote events

This commit is contained in:
Anuken 2018-10-13 21:58:17 -04:00
parent 870f5caca9
commit 0aabc09b82
5 changed files with 15 additions and 9 deletions

View file

@ -11,8 +11,8 @@ text.link.wiki.description=official Mindustry wiki
text.linkfail=Failed to open link!\nThe URL has been copied to your cliboard.
text.editor.web=The web version does not support the editor!\nDownload the game to use it.
text.web.unsupported=The web version does not support this feature! Download the game to use it.
text.gameover=Your core has been destroyed
text.pvp.gameover=The[accent] {0}[] team is victorious!
text.gameover=Game Over
text.gameover.pvp=The[accent] {0}[] team is victorious!
text.sector.gameover=This sector has been lost. Re-deploy?
text.sector.retry=Retry
text.highscore=[accent]New highscore!

View file

@ -27,6 +27,7 @@ import io.anuke.ucore.entities.Entities;
import io.anuke.ucore.entities.EntityQuery;
import io.anuke.ucore.modules.Module;
import io.anuke.ucore.util.Atlas;
import io.anuke.mindustry.gen.Call;
import static io.anuke.mindustry.Vars.*;
@ -154,7 +155,7 @@ public class Control extends Module{
threads.runGraphics(() -> {
Effects.shake(5, 6, Core.camera.position.x, Core.camera.position.y);
//the restart dialog can show info for any number of scenarios
ui.restart.show(event);
Call.onGameOver(event.winner);
});
});

View file

@ -78,7 +78,6 @@ public class Logic extends Module{
Events.fire(new WaveEvent());
}
//this never triggers in PvP; only for checking sector game-overs
private void checkGameOver(){
if(!state.mode.isPvp && state.teams.get(defaultTeam).cores.size == 0 && !state.gameOver){
state.gameOver = true;

View file

@ -414,6 +414,12 @@ public class NetServer extends Module{
Log.info("&y{0} has connected.", player.name);
}
@Remote(called = Loc.both)
public static void onGameOver(Team winner){
threads.runGraphics(() -> ui.restart.show(winner));
state.set(State.menu);
}
public boolean isWaitingForPlayers(){
return state.mode.isPvp && playerGroup.size() < 2;
}

View file

@ -1,14 +1,14 @@
package io.anuke.mindustry.ui.dialogs;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.game.EventType.GameOverEvent;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.maps.Sector;
import io.anuke.ucore.util.Bundles;
import static io.anuke.mindustry.Vars.*;
public class RestartDialog extends FloatingDialog{
private GameOverEvent event;
private Team winner;
public RestartDialog(){
super("$text.gameover");
@ -16,8 +16,8 @@ public class RestartDialog extends FloatingDialog{
shown(this::rebuild);
}
public void show(GameOverEvent event){
this.event = event;
public void show(Team winner){
this.winner = winner;
show();
}
@ -28,7 +28,7 @@ public class RestartDialog extends FloatingDialog{
buttons().margin(10);
if(state.mode.isPvp){
content().add(Bundles.format("text.gameover.pvp", event.winner.localized())).pad(6);
content().add(Bundles.format("text.gameover.pvp",winner.localized())).pad(6);
buttons().addButton("$text.menu", () -> {
hide();
state.set(State.menu);