Abort round countdown if status changed.

This commit is contained in:
UnknownShadow200 2017-06-29 16:27:08 +10:00
parent 0714e9c59c
commit 78e1acfdd5
2 changed files with 25 additions and 6 deletions

View File

@ -227,7 +227,7 @@ namespace MCGalaxy.Commands.Fun {
if (game.Players.Count < 2) { if (game.Players.Count < 2) {
Player.Message(p, "At least two players must join countdown before a round can begin."); return; Player.Message(p, "At least two players must join countdown before a round can begin."); return;
} }
game.Status = CountdownGameStatus.RoundCountdown; break; break;
} }
switch (speed) { switch (speed) {

View File

@ -53,10 +53,11 @@ namespace MCGalaxy.Games {
#region Round #region Round
public void BeginRound(Player p) { public void BeginRound(Player p) {
Status = CountdownGameStatus.RoundCountdown;
ResetMap(); ResetMap();
SetGlassTube(Block.glass, Block.glass); SetGlassTube(Block.glass, Block.glass);
Map.ChatLevel("Countdown is about to start!"); Map.ChatLevel("Countdown is about to start!");
Map.BuildAccess.Min = LevelPermission.Nobody; if (Status != CountdownGameStatus.RoundCountdown) return;
int midX = Map.Width / 2, midY = Map.Height / 2, midZ = Map.Length / 2; int midX = Map.Width / 2, midY = Map.Height / 2, midZ = Map.Length / 2;
int xSpawn = (midX * 32 + 16); int xSpawn = (midX * 32 + 16);
@ -76,15 +77,21 @@ namespace MCGalaxy.Games {
Thread.Sleep(2000); Thread.Sleep(2000);
SpawnPlayers(xSpawn, ySpawn, zSpawn); SpawnPlayers(xSpawn, ySpawn, zSpawn);
Map.ChatLevel("-----&b5%S-----"); Map.ChatLevel("-----&b5%S-----");
if (Status != CountdownGameStatus.RoundCountdown) return;
Cuboid(midX - 1, midY, midZ - 1, midX, midY, midZ, Block.air, Map); Cuboid(midX - 1, midY, midZ - 1, midX, midY, midZ, Block.air, Map);
Thread.Sleep(1000); Thread.Sleep(1000);
if (Status != CountdownGameStatus.RoundCountdown) return;
Map.ChatLevel("-----&b4%S-----"); Thread.Sleep(1000); Map.ChatLevel("-----&b4%S-----"); Thread.Sleep(1000);
Map.ChatLevel("-----&b3%S-----"); Thread.Sleep(1000); Map.ChatLevel("-----&b3%S-----"); Thread.Sleep(1000);
Cuboid(midX, Map.Height - 5, midZ, midX + 1, Map.Height - 5, midZ + 1, Block.air, Map); Cuboid(midX, Map.Height - 5, midZ, midX + 1, Map.Height - 5, midZ + 1, Block.air, Map);
if (Status != CountdownGameStatus.RoundCountdown) return;
Map.ChatLevel("-----&b2%S-----"); Thread.Sleep(1000); Map.ChatLevel("-----&b2%S-----"); Thread.Sleep(1000);
Map.ChatLevel("-----&b1%S-----"); Thread.Sleep(1000); Map.ChatLevel("-----&b1%S-----"); Thread.Sleep(1000);
Map.ChatLevel("GO!!!!!!!"); Map.ChatLevel("GO!!!!!!!");
if (Status != CountdownGameStatus.RoundCountdown) return;
Player[] players = Players.Items; Player[] players = Players.Items;
Remaining.Clear(); Remaining.Clear();
@ -134,20 +141,30 @@ namespace MCGalaxy.Games {
Thread.Sleep(500); Thread.Sleep(500);
Map.ChatLevel("Welcome to Freeze Mode of countdown"); Map.ChatLevel("Welcome to Freeze Mode of countdown");
Map.ChatLevel("You have 15 seconds to stand on a square"); Map.ChatLevel("You have 15 seconds to stand on a square");
if (Status != CountdownGameStatus.RoundCountdown) return;
Thread.Sleep(500); Thread.Sleep(500);
Map.ChatLevel("-----&b15%S-----"); Thread.Sleep(500); Map.ChatLevel("-----&b15%S-----"); Thread.Sleep(500);
Map.ChatLevel("Once the countdown is up, you are stuck on your square"); Map.ChatLevel("Once the countdown is up, you are stuck on your square");
if (Status != CountdownGameStatus.RoundCountdown) return;
Thread.Sleep(500); Thread.Sleep(500);
Map.ChatLevel("-----&b14%S-----"); Thread.Sleep(500); Map.ChatLevel("-----&b14%S-----"); Thread.Sleep(500);
Map.ChatLevel("The squares then start to dissapear"); Map.ChatLevel("The squares then start to dissapear");
if (Status != CountdownGameStatus.RoundCountdown) return;
Thread.Sleep(500); Thread.Sleep(500);
Map.ChatLevel("-----&b13%S-----"); Thread.Sleep(500); Map.ChatLevel("-----&b13%S-----"); Thread.Sleep(500);
Map.ChatLevel("Whoever is last out wins!"); Map.ChatLevel("Whoever is last out wins!");
if (Status != CountdownGameStatus.RoundCountdown) return;
Thread.Sleep(500); Thread.Sleep(500);
Map.ChatLevel("-----&b12%S-----"); Thread.Sleep(1000); Map.ChatLevel("-----&b12%S-----"); Thread.Sleep(1000);
Map.ChatLevel("-----&b11%S-----"); Thread.Sleep(1000); Map.ChatLevel("-----&b11%S-----"); Thread.Sleep(1000);
Map.ChatLevel("-----&b10%S-----"); Map.ChatLevel("-----&b10%S-----");
Map.ChatLevel("Only 10 Seconds left to pick your places!"); Map.ChatLevel("Only 10 Seconds left to pick your places!");
if (Status != CountdownGameStatus.RoundCountdown) return;
Thread.Sleep(1000); Thread.Sleep(1000);
Map.ChatLevel("-----&b9%S-----"); Thread.Sleep(1000); Map.ChatLevel("-----&b9%S-----"); Thread.Sleep(1000);
Map.ChatLevel("-----&b8%S-----"); Thread.Sleep(1000); Map.ChatLevel("-----&b8%S-----"); Thread.Sleep(1000);
@ -155,6 +172,8 @@ namespace MCGalaxy.Games {
Map.ChatLevel("-----&b6%S-----"); Thread.Sleep(1000); Map.ChatLevel("-----&b6%S-----"); Thread.Sleep(1000);
Map.ChatLevel("-----&b5%S-----"); Map.ChatLevel("-----&b5%S-----");
Map.ChatLevel("5 Seconds left to pick your places!"); Map.ChatLevel("5 Seconds left to pick your places!");
if (Status != CountdownGameStatus.RoundCountdown) return;
Thread.Sleep(1000); Thread.Sleep(1000);
Map.ChatLevel("-----&b4%S-----"); Thread.Sleep(1000); Map.ChatLevel("-----&b4%S-----"); Thread.Sleep(1000);
Map.ChatLevel("-----&b3%S-----"); Thread.Sleep(1000); Map.ChatLevel("-----&b3%S-----"); Thread.Sleep(1000);