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.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.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.web.unsupported=The web version does not support this feature! Download the game to use it.
text.gameover=Your core has been destroyed text.gameover=Game Over
text.pvp.gameover=The[accent] {0}[] team is victorious! text.gameover.pvp=The[accent] {0}[] team is victorious!
text.sector.gameover=This sector has been lost. Re-deploy? text.sector.gameover=This sector has been lost. Re-deploy?
text.sector.retry=Retry text.sector.retry=Retry
text.highscore=[accent]New highscore! 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.entities.EntityQuery;
import io.anuke.ucore.modules.Module; import io.anuke.ucore.modules.Module;
import io.anuke.ucore.util.Atlas; import io.anuke.ucore.util.Atlas;
import io.anuke.mindustry.gen.Call;
import static io.anuke.mindustry.Vars.*; import static io.anuke.mindustry.Vars.*;
@@ -154,7 +155,7 @@ public class Control extends Module{
threads.runGraphics(() -> { threads.runGraphics(() -> {
Effects.shake(5, 6, Core.camera.position.x, Core.camera.position.y); Effects.shake(5, 6, Core.camera.position.x, Core.camera.position.y);
//the restart dialog can show info for any number of scenarios //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()); Events.fire(new WaveEvent());
} }
//this never triggers in PvP; only for checking sector game-overs
private void checkGameOver(){ private void checkGameOver(){
if(!state.mode.isPvp && state.teams.get(defaultTeam).cores.size == 0 && !state.gameOver){ if(!state.mode.isPvp && state.teams.get(defaultTeam).cores.size == 0 && !state.gameOver){
state.gameOver = true; state.gameOver = true;

View File

@@ -414,6 +414,12 @@ public class NetServer extends Module{
Log.info("&y{0} has connected.", player.name); 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(){ public boolean isWaitingForPlayers(){
return state.mode.isPvp && playerGroup.size() < 2; return state.mode.isPvp && playerGroup.size() < 2;
} }

View File

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