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

@@ -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);