Fix various bugs with last few commits with countdown.

This commit is contained in:
UnknownShadow200 2017-06-29 15:55:31 +10:00
parent 67290a73a4
commit dbb2569efb

View File

@ -35,9 +35,6 @@ namespace MCGalaxy.Games {
/// <summary> Current status of the countdown game. </summary> /// <summary> Current status of the countdown game. </summary>
public CountdownGameStatus Status = CountdownGameStatus.Disabled; public CountdownGameStatus Status = CountdownGameStatus.Disabled;
/// <summary> Whether the current round is pending cancellation. </summary>
public bool PendingCancel = false;
/// <summary> Whether the game is running in freeze mode or not. </summary> /// <summary> Whether the game is running in freeze mode or not. </summary>
public bool FreezeMode = false; public bool FreezeMode = false;
@ -121,7 +118,7 @@ namespace MCGalaxy.Games {
void DoRound() { void DoRound() {
if (FreezeMode) { if (FreezeMode) {
MessageFreezeCountdown(); MessageFreezeCountdown();
MessageAll("&bPlayers Frozen"); Map.ChatLevel("&bPlayers Frozen");
Player[] players = Players.Items; Player[] players = Players.Items;
foreach (Player pl in players) { foreach (Player pl in players) {
@ -139,34 +136,34 @@ namespace MCGalaxy.Games {
void MessageFreezeCountdown() { void MessageFreezeCountdown() {
Thread.Sleep(500); Thread.Sleep(500);
MessageAll("Welcome to Freeze Mode of countdown"); Map.ChatLevel("Welcome to Freeze Mode of countdown");
MessageAll("You have 15 seconds to stand on a square"); Map.ChatLevel("You have 15 seconds to stand on a square");
Thread.Sleep(500); Thread.Sleep(500);
MessageAll("-----&b15%S-----"); Thread.Sleep(500); Map.ChatLevel("-----&b15%S-----"); Thread.Sleep(500);
MessageAll("Once the countdown is up, you are stuck on your square"); Map.ChatLevel("Once the countdown is up, you are stuck on your square");
Thread.Sleep(500); Thread.Sleep(500);
MessageAll("-----&b14%S-----"); Thread.Sleep(500); Map.ChatLevel("-----&b14%S-----"); Thread.Sleep(500);
MessageAll("The squares then start to dissapear"); Map.ChatLevel("The squares then start to dissapear");
Thread.Sleep(500); Thread.Sleep(500);
MessageAll("-----&b13%S-----"); Thread.Sleep(500); Map.ChatLevel("-----&b13%S-----"); Thread.Sleep(500);
MessageAll("Whoever is last out wins!!"); Map.ChatLevel("Whoever is last out wins!");
Thread.Sleep(500); Thread.Sleep(500);
MessageAll("-----&b12%S-----"); Thread.Sleep(1000); Map.ChatLevel("-----&b12%S-----"); Thread.Sleep(1000);
MessageAll("-----&b11%S-----"); Thread.Sleep(1000); Map.ChatLevel("-----&b11%S-----"); Thread.Sleep(1000);
MessageAll("-----&b10%S-----"); Map.ChatLevel("-----&b10%S-----");
MessageAll("Only 10 Seconds left to pick your places!!"); Map.ChatLevel("Only 10 Seconds left to pick your places!");
Thread.Sleep(1000); Thread.Sleep(1000);
MessageAll("-----&b9%S-----"); Thread.Sleep(1000); Map.ChatLevel("-----&b9%S-----"); Thread.Sleep(1000);
MessageAll("-----&b8%S-----"); Thread.Sleep(1000); Map.ChatLevel("-----&b8%S-----"); Thread.Sleep(1000);
MessageAll("-----&b7%S-----"); Thread.Sleep(1000); Map.ChatLevel("-----&b7%S-----"); Thread.Sleep(1000);
MessageAll("-----&b6%S-----"); Thread.Sleep(1000); Map.ChatLevel("-----&b6%S-----"); Thread.Sleep(1000);
MessageAll("-----&b5%S-----"); Map.ChatLevel("-----&b5%S-----");
MessageAll("5 Seconds left to pick your places!!"); Map.ChatLevel("5 Seconds left to pick your places!");
Thread.Sleep(1000); Thread.Sleep(1000);
MessageAll("-----&b4%S-----"); Thread.Sleep(1000); Map.ChatLevel("-----&b4%S-----"); Thread.Sleep(1000);
MessageAll("-----&b3%S-----"); Thread.Sleep(1000); Map.ChatLevel("-----&b3%S-----"); Thread.Sleep(1000);
MessageAll("-----&b2%S-----"); Thread.Sleep(1000); Map.ChatLevel("-----&b2%S-----"); Thread.Sleep(1000);
MessageAll("-----&b1%S-----"); Thread.Sleep(1000); Map.ChatLevel("-----&b1%S-----"); Thread.Sleep(1000);
} }
void CloseOffBoard() { void CloseOffBoard() {
@ -186,7 +183,7 @@ namespace MCGalaxy.Games {
for (int xx = 6; xx < maxX - 6; xx += 3) for (int xx = 6; xx < maxX - 6; xx += 3)
Cuboid(xx - 1, 4, 4, xx - 1, 4, maxZ - 4, Block.air, Map); Cuboid(xx - 1, 4, 4, xx - 1, 4, maxZ - 4, Block.air, Map);
for (int zz = 6; zz < maxZ - 6; zz += 3) for (int zz = 6; zz < maxZ - 6; zz += 3)
Cuboid(4, 4, zz - 1, maxX - 4, 4, zz - 2, Block.air, Map); Cuboid(4, 4, zz - 1, maxX - 4, 4, zz - 1, Block.air, Map);
} }
void RemoveSquares() { void RemoveSquares() {
@ -256,7 +253,7 @@ namespace MCGalaxy.Games {
public void Death(Player p) { public void Death(Player p) {
Map.ChatLevel(p.ColoredName + " %Sis out of countdown!!"); Map.ChatLevel(p.ColoredName + " %Sis out of countdown!");
Remaining.Remove(p); Remaining.Remove(p);
UpdatePlayersLeft(); UpdatePlayersLeft();
} }
@ -267,7 +264,7 @@ namespace MCGalaxy.Games {
switch (players.Length) { switch (players.Length) {
case 1: case 1:
Map.ChatLevel(players[0].ColoredName + " %Sis the winner!!"); Map.ChatLevel(players[0].ColoredName + " %Sis the winner!");
EndRound(players[0]); EndRound(players[0]);
break; break;
case 2: case 2:
@ -296,12 +293,9 @@ namespace MCGalaxy.Games {
} else { } else {
Player[] players = Players.Items; Player[] players = Players.Items;
foreach (Player pl in players) { foreach (Player pl in players) {
Player.Message(pl, "Current round was force ended!");
Command.all.Find("spawn").Use(pl, ""); Command.all.Find("spawn").Use(pl, "");
} }
Map.ChatLevel("Current round was force ended!");
Chat.MessageGlobal("Current round was force ended!");
PendingCancel = false;
} }
} }
@ -331,7 +325,7 @@ namespace MCGalaxy.Games {
if (Status == CountdownGameStatus.RoundInProgress) EndRound(null); if (Status == CountdownGameStatus.RoundInProgress) EndRound(null);
Status = CountdownGameStatus.Disabled; Status = CountdownGameStatus.Disabled;
MessageAll("Countdown was disabled."); Map.ChatLevel("Countdown was disabled.");
Players.Clear(); Players.Clear();
Remaining.Clear(); Remaining.Clear();
squaresLeft.Clear(); squaresLeft.Clear();
@ -363,15 +357,7 @@ namespace MCGalaxy.Games {
for (int xx = 6; xx < maxX - 6; xx += 3) for (int xx = 6; xx < maxX - 6; xx += 3)
Cuboid(xx, 4, zz, xx + 1, 4, zz + 1, Block.green, Map); Cuboid(xx, 4, zz, xx + 1, 4, zz + 1, Block.green, Map);
MessageAll("Countdown map has been reset"); Map.ChatLevel("Countdown map has been reset");
}
/// <summary> Sends a message to all players of countdown. </summary>
public void MessageAll(string message) {
Player[] players = Players.Items;
foreach (Player pl in players) {
Player.Message(pl, message);
}
} }