PvP game over condition
This commit is contained in:
@@ -12,6 +12,7 @@ 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=Your core has been destroyed
|
||||||
|
text.pvp.gameover=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!
|
||||||
@@ -653,6 +654,13 @@ block.rtg-generator.name=RTG Generator
|
|||||||
block.spectre.name=Spectre
|
block.spectre.name=Spectre
|
||||||
block.meltdown.name=Meltdown
|
block.meltdown.name=Meltdown
|
||||||
|
|
||||||
|
team.blue.name=blue
|
||||||
|
team.red.name=red
|
||||||
|
team.orange.name=orange
|
||||||
|
team.none.name=gray
|
||||||
|
team.green.name=green
|
||||||
|
team.purple.name=purple
|
||||||
|
|
||||||
unit.alpha-drone.name=Alpha Drone
|
unit.alpha-drone.name=Alpha Drone
|
||||||
unit.spirit.name=Spirit Drone
|
unit.spirit.name=Spirit Drone
|
||||||
unit.spirit.description=The starter drone unit. Spawns in the core by default. Automatically mines ores, collects items and repairs blocks.
|
unit.spirit.description=The starter drone unit. Spawns in the core by default. Automatically mines ores, collects items and repairs blocks.
|
||||||
|
|||||||
@@ -153,8 +153,8 @@ 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);
|
||||||
ui.restart.show();
|
//the restart dialog can show info for any number of scenarios
|
||||||
state.set(State.menu);
|
ui.restart.show(event);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import io.anuke.mindustry.core.GameState.State;
|
|||||||
import io.anuke.mindustry.entities.TileEntity;
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
import io.anuke.mindustry.game.EventType.*;
|
import io.anuke.mindustry.game.EventType.*;
|
||||||
import io.anuke.mindustry.game.GameMode;
|
import io.anuke.mindustry.game.GameMode;
|
||||||
|
import io.anuke.mindustry.game.Team;
|
||||||
import io.anuke.mindustry.game.Teams;
|
import io.anuke.mindustry.game.Teams;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.type.ItemStack;
|
import io.anuke.mindustry.type.ItemStack;
|
||||||
@@ -81,7 +82,23 @@ public class Logic extends Module{
|
|||||||
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;
|
||||||
Events.fire(new GameOverEvent());
|
Events.fire(new GameOverEvent(waveTeam));
|
||||||
|
}else if(state.mode.isPvp){
|
||||||
|
Team alive = null;
|
||||||
|
|
||||||
|
for(Team team : Team.all){
|
||||||
|
if(state.teams.get(team).cores.size > 0){
|
||||||
|
if(alive != null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
alive = team;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(alive != null && !state.gameOver){
|
||||||
|
state.gameOver = true;
|
||||||
|
Events.fire(new GameOverEvent(alive));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,11 @@ public class EventType{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class GameOverEvent implements Event{
|
public static class GameOverEvent implements Event{
|
||||||
|
public final Team winner;
|
||||||
|
|
||||||
|
public GameOverEvent(Team winner){
|
||||||
|
this.winner = winner;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package io.anuke.mindustry.game;
|
package io.anuke.mindustry.game;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
import io.anuke.ucore.util.Bundles;
|
||||||
|
|
||||||
public enum Team{
|
public enum Team{
|
||||||
none(Color.DARK_GRAY),
|
none(Color.DARK_GRAY),
|
||||||
@@ -18,4 +19,8 @@ public enum Team{
|
|||||||
this.color = color;
|
this.color = color;
|
||||||
intColor = Color.rgba8888(color);
|
intColor = Color.rgba8888(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String localized(){
|
||||||
|
return Bundles.get("team." + name() + ".name");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +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.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;
|
||||||
|
|
||||||
public RestartDialog(){
|
public RestartDialog(){
|
||||||
super("$text.gameover");
|
super("$text.gameover");
|
||||||
@@ -14,13 +16,25 @@ public class RestartDialog extends FloatingDialog{
|
|||||||
shown(this::rebuild);
|
shown(this::rebuild);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void show(GameOverEvent event){
|
||||||
|
this.event = event;
|
||||||
|
show();
|
||||||
|
}
|
||||||
|
|
||||||
void rebuild(){
|
void rebuild(){
|
||||||
buttons().clear();
|
buttons().clear();
|
||||||
content().clear();
|
content().clear();
|
||||||
|
|
||||||
buttons().margin(10);
|
buttons().margin(10);
|
||||||
|
|
||||||
if(world.getSector() == null){
|
if(state.mode.isPvp){
|
||||||
|
content().add(Bundles.format("text.gameover.pvp", event.winner.localized())).pad(6);
|
||||||
|
buttons().addButton("$text.menu", () -> {
|
||||||
|
hide();
|
||||||
|
state.set(State.menu);
|
||||||
|
logic.reset();
|
||||||
|
}).size(130f, 60f);
|
||||||
|
}else if(world.getSector() == null){
|
||||||
if(control.isHighScore()){
|
if(control.isHighScore()){
|
||||||
content().add("$text.highscore").pad(6);
|
content().add("$text.highscore").pad(6);
|
||||||
content().row();
|
content().row();
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ public class ServerControl extends Module{
|
|||||||
private final CommandHandler handler = new CommandHandler("");
|
private final CommandHandler handler = new CommandHandler("");
|
||||||
private int gameOvers;
|
private int gameOvers;
|
||||||
private boolean inExtraRound;
|
private boolean inExtraRound;
|
||||||
private Team winnerTeam;
|
|
||||||
private Task lastTask;
|
private Task lastTask;
|
||||||
|
|
||||||
public ServerControl(String[] args){
|
public ServerControl(String[] args){
|
||||||
@@ -121,8 +120,8 @@ public class ServerControl extends Module{
|
|||||||
while(map == previous) map = maps.random();
|
while(map == previous) map = maps.random();
|
||||||
}
|
}
|
||||||
|
|
||||||
Call.onInfoMessage((state.mode.isPvp && winnerTeam != null
|
Call.onInfoMessage((state.mode.isPvp
|
||||||
? "[YELLOW]The " + winnerTeam.name() + " team is victorious![]" : "[SCARLET]Game over![]")
|
? "[YELLOW]The " + event.winner.name() + " team is victorious![]" : "[SCARLET]Game over![]")
|
||||||
+ "\nNext selected map:[accent] "+map.name+"[]"
|
+ "\nNext selected map:[accent] "+map.name+"[]"
|
||||||
+ (map.meta.author() != null ? " by[accent] " + map.meta.author() + "[]" : "") + "."+
|
+ (map.meta.author() != null ? " by[accent] " + map.meta.author() + "[]" : "") + "."+
|
||||||
"\nNew game begins in " + roundExtraTime + " seconds.");
|
"\nNew game begins in " + roundExtraTime + " seconds.");
|
||||||
@@ -650,7 +649,7 @@ public class ServerControl extends Module{
|
|||||||
|
|
||||||
info("&lyCore destroyed.");
|
info("&lyCore destroyed.");
|
||||||
inExtraRound = false;
|
inExtraRound = false;
|
||||||
Events.fire(new GameOverEvent());
|
Events.fire(new GameOverEvent(Team.red));
|
||||||
});
|
});
|
||||||
|
|
||||||
handler.register("traceblock", "<x> <y>", "Prints debug info about a block", arg -> {
|
handler.register("traceblock", "<x> <y>", "Prints debug info about a block", arg -> {
|
||||||
@@ -882,29 +881,10 @@ public class ServerControl extends Module{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkPvPGameOver(){
|
|
||||||
Team alive = null;
|
|
||||||
|
|
||||||
for(Team team : Team.all){
|
|
||||||
if(state.teams.get(team).cores.size > 0){
|
|
||||||
if(alive != null){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
alive = team;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(alive != null && !state.gameOver){
|
|
||||||
state.gameOver = true;
|
|
||||||
winnerTeam = alive;
|
|
||||||
Events.fire(new GameOverEvent());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
if(!inExtraRound && state.mode.isPvp){
|
if(!inExtraRound && state.mode.isPvp){
|
||||||
checkPvPGameOver();
|
// checkPvPGameOver();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user