More code cleanup for zombie survival.

This commit is contained in:
UnknownShadow200 2016-03-13 12:31:59 +11:00
parent 6b04139c5b
commit ab6c4288bc
13 changed files with 231 additions and 241 deletions

View File

@ -21,10 +21,12 @@ namespace MCGalaxy.Commands
{ {
public override string name { get { return "alive"; } } public override string name { get { return "alive"; } }
public override string shortcut { get { return "alive"; } } public override string shortcut { get { return "alive"; } }
public override string type { get { return CommandTypes.Games; } } public override string type { get { return CommandTypes.Games; } }
public override bool museumUsable { get { return true; } } public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } } public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
public override bool Enabled { get { return Server.ZombieModeOn; } }
public CmdAlive() { } public CmdAlive() { }
public override void Use(Player p, string message) public override void Use(Player p, string message)
{ {
if (ZombieGame.alive.Count == 0) if (ZombieGame.alive.Count == 0)

View File

@ -31,7 +31,7 @@ namespace MCGalaxy.Commands {
Player who = message == "" ? p : PlayerInfo.FindOrShowMatches(p, message); Player who = message == "" ? p : PlayerInfo.FindOrShowMatches(p, message);
if (who == null) return; if (who == null) return;
if (!who.infected || !Server.zombie.GameInProgess()) { if (!who.infected || !Server.zombie.RoundInProgress) {
Player.SendMessage(p, "Cannot disinfect player"); Player.SendMessage(p, "Cannot disinfect player");
} else if (!who.referee) { } else if (!who.referee) {
Server.zombie.DisinfectPlayer(who); Server.zombie.DisinfectPlayer(who);

View File

@ -1,40 +1,39 @@
/* /*
Copyright 2011 MCForge Copyright 2011 MCForge
Dual-licensed under the Educational Community License, Version 2.0 and Dual-licensed under the Educational Community License, Version 2.0 and
the GNU General Public License, Version 3 (the "Licenses"); you may the GNU General Public License, Version 3 (the "Licenses"); you may
not use this file except in compliance with the Licenses. You may not use this file except in compliance with the Licenses. You may
obtain a copy of the Licenses at obtain a copy of the Licenses at
http://www.opensource.org/licenses/ecl2.php http://www.opensource.org/licenses/ecl2.php
http://www.gnu.org/licenses/gpl-3.0.html http://www.gnu.org/licenses/gpl-3.0.html
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the Licenses are distributed on an "AS IS" software distributed under the Licenses are distributed on an "AS IS"
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied. See the Licenses for the specific language governing or implied. See the Licenses for the specific language governing
permissions and limitations under the Licenses. permissions and limitations under the Licenses.
*/ */
namespace MCGalaxy.Commands namespace MCGalaxy.Commands
{ {
public sealed class CmdEndRound : Command public sealed class CmdEndRound : Command
{ {
public override string name { get { return "endround"; } } public override string name { get { return "endround"; } }
public override string shortcut { get { return "er"; } } public override string shortcut { get { return "er"; } }
public override string type { get { return CommandTypes.Moderation; } } public override string type { get { return CommandTypes.Moderation; } }
public override bool museumUsable { get { return true; } } public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } } public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
public CmdEndRound() { } public override bool Enabled { get { return Server.ZombieModeOn; } }
public override void Use(Player p, string message) public CmdEndRound() { }
{
if (Server.zombie.GameInProgess()) public override void Use(Player p, string message) {
{ if (Server.zombie.RoundInProgress)
Server.zombie.HandOutRewards(); Server.zombie.HandOutRewards();
} }
}
public override void Help(Player p) public override void Help(Player p) {
{ Player.SendMessage(p, "/endround - ends the round");
Player.SendMessage(p, "/endround - ends the round"); }
} }
} }
}

View File

@ -31,7 +31,7 @@ namespace MCGalaxy.Commands {
Player who = message == "" ? p : PlayerInfo.FindOrShowMatches(p, message); Player who = message == "" ? p : PlayerInfo.FindOrShowMatches(p, message);
if (who == null) return; if (who == null) return;
if (who.infected || !Server.zombie.GameInProgess()) { if (who.infected || !Server.zombie.RoundInProgress) {
Player.SendMessage(p, "Cannot infect player"); Player.SendMessage(p, "Cannot infect player");
} else if (!who.referee) { } else if (!who.referee) {
Server.zombie.InfectPlayer(who); Server.zombie.InfectPlayer(who);

View File

@ -1,79 +1,81 @@
/* /*
Copyright 2011 MCForge Copyright 2011 MCForge
Dual-licensed under the Educational Community License, Version 2.0 and Dual-licensed under the Educational Community License, Version 2.0 and
the GNU General Public License, Version 3 (the "Licenses"); you may the GNU General Public License, Version 3 (the "Licenses"); you may
not use this file except in compliance with the Licenses. You may not use this file except in compliance with the Licenses. You may
obtain a copy of the Licenses at obtain a copy of the Licenses at
http://www.opensource.org/licenses/ecl2.php http://www.opensource.org/licenses/ecl2.php
http://www.gnu.org/licenses/gpl-3.0.html http://www.gnu.org/licenses/gpl-3.0.html
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the Licenses are distributed on an "AS IS" software distributed under the Licenses are distributed on an "AS IS"
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied. See the Licenses for the specific language governing or implied. See the Licenses for the specific language governing
permissions and limitations under the Licenses. permissions and limitations under the Licenses.
*/ */
namespace MCGalaxy.Commands namespace MCGalaxy.Commands
{ {
public sealed class CmdReferee : Command public sealed class CmdReferee : Command
{ {
public override string name { get { return "ref"; } } public override string name { get { return "ref"; } }
public override string shortcut { get { return ""; } } public override string shortcut { get { return ""; } }
public override string type { get { return CommandTypes.Moderation; } } public override string type { get { return CommandTypes.Moderation; } }
public override bool museumUsable { get { return true; } } public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
public CmdReferee() { } public override bool Enabled { get { return Server.ZombieModeOn; } }
public override void Use(Player p, string message) public CmdReferee() { }
{
if (p == null) { MessageInGameOnly(p); return; } public override void Use(Player p, string message)
if (p.referee) {
{ if (p == null) { MessageInGameOnly(p); return; }
p.referee = false; if (p.referee)
LevelPermission perm = Group.findPlayerGroup(name).Permission; {
Player.GlobalDespawn(p, false); p.referee = false;
Player.SendChatFrom(p, p.color + p.name + Server.DefaultColor + " is no longer a referee", false); LevelPermission perm = Group.findPlayerGroup(name).Permission;
if (Server.zombie.GameInProgess()) Player.GlobalDespawn(p, false);
{ Player.SendChatFrom(p, p.FullName + " %Sis no longer a referee", false);
Server.zombie.InfectPlayer(p); if (Server.zombie.RoundInProgress)
} {
else Server.zombie.InfectPlayer(p);
{ }
Player.GlobalDespawn(p, false); else
Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], false); {
ZombieGame.infectd.Remove(p); Player.GlobalDespawn(p, false);
ZombieGame.alive.Add(p); Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], false);
p.color = p.group.color; ZombieGame.infectd.Remove(p);
} ZombieGame.alive.Add(p);
} p.color = p.group.color;
else }
{ }
p.referee = true; else
Player.SendChatFrom(p, p.color + p.name + Server.DefaultColor + " is now a referee", false); {
Player.GlobalDespawn(p, false); p.referee = true;
if (Server.zombie.GameInProgess()) Player.SendChatFrom(p, p.FullName + " %Sis now a referee", false);
{ Player.GlobalDespawn(p, false);
p.color = p.group.color; if (Server.zombie.RoundInProgress)
try {
{ p.color = p.group.color;
ZombieGame.infectd.Remove(p); try
ZombieGame.alive.Remove(p); {
} ZombieGame.infectd.Remove(p);
catch { } ZombieGame.alive.Remove(p);
Server.zombie.InfectedPlayerDC(); }
} catch { }
else Server.zombie.InfectedPlayerDC();
{ }
ZombieGame.infectd.Remove(p); else
ZombieGame.alive.Remove(p); {
p.color = p.group.color; ZombieGame.infectd.Remove(p);
} ZombieGame.alive.Remove(p);
} p.color = p.group.color;
} }
public override void Help(Player p) }
{ }
Player.SendMessage(p, "/referee - Turns referee mode on/off."); public override void Help(Player p)
} {
} Player.SendMessage(p, "/referee - Turns referee mode on/off.");
} }
}
}

View File

@ -33,52 +33,50 @@ namespace MCGalaxy.Commands
string[] s = message.ToLower().Split(' '); string[] s = message.ToLower().Split(' ');
if (s[0] == "status") if (s[0] == "status")
{ {
switch (Server.zombie.ZombieStatus()) switch (Server.zombie.Status) {
{ case ZombieGameStatus.NotStarted:
case 0: Player.SendMessage(p, "Zombie Survival is not ccurrently running."); return;
Player.GlobalMessage("There is no Zombie Survival game currently in progress."); case ZombieGameStatus.InfiniteRounds:
return; Player.SendMessage(p, "Zombie Survival is currently in progress with infinite rounds."); return;
case 1: case ZombieGameStatus.SingleRound:
Player.SendMessage(p, "There is a Zombie Survival game currently in progress with infinite rounds."); Player.SendMessage(p, "Zombie Survival game currently in progress."); return;
return; case ZombieGameStatus.VariableRounds:
case 2: Player.SendMessage(p, "Zombie Survival game currently in progress with " + Server.zombie.MaxRounds + " rounds."); return;
Player.SendMessage(p, "There is a one-time Zombie Survival game currently in progress."); case ZombieGameStatus.LastRound:
return; Player.SendMessage(p, "Zombie Survival game currently in progress, with this round being the final round."); return;
case 3:
Player.SendMessage(p, "There is a Zombie Survival game currently in progress with a " + Server.zombie.MaxRounds + " amount of rounds.");
return;
case 4:
Player.SendMessage(p, "There is a Zombie Survival game currently in progress, scheduled to stop after this round.");
return;
default:
Player.SendMessage(p, "An unknown error occurred.");
return;
} }
return;
} }
else if (s[0] == "start") else if (s[0] == "start")
{ {
if (Server.zombie.ZombieStatus() != 0) { Player.SendMessage(p, "There is already a Zombie Survival game currently in progress."); return; } if (Server.zombie.Status != ZombieGameStatus.NotStarted) {
Player.SendMessage(p, "There is already a Zombie Survival game currently in progress."); return;
}
if (s.Length == 2) { if (s.Length == 2) {
int rounds = 1; int rounds = 1;
bool result = int.TryParse(s[1], out rounds); if (!int.TryParse(s[1], out rounds)) {
if (result == false) { Player.SendMessage(p, "You need to specify a valid option!"); return; } Player.SendMessage(p, "You need to specify a valid option!"); return;
if (s[1] == "0") }
Server.zombie.StartGame(1, 0); ZombieGameStatus status = rounds == 0 ?
else ZombieGameStatus.InfiniteRounds : ZombieGameStatus.VariableRounds;
Server.zombie.StartGame(3, rounds); Server.zombie.Start(status, rounds);
} else { } else {
Server.zombie.StartGame(2, 0); Server.zombie.Start(ZombieGameStatus.SingleRound, 0);
} }
} }
else if (s[0] == "stop") else if (s[0] == "stop")
{ {
if (Server.zombie.ZombieStatus() == 0) { Player.SendMessage(p, "There is no Zombie Survival game currently in progress."); return; } if (Server.zombie.Status == ZombieGameStatus.NotStarted) {
Player.SendMessage(p, "There is no Zombie Survival game currently in progress."); return;
}
Player.GlobalMessage("The current game of Zombie Survival will end this round!"); Player.GlobalMessage("The current game of Zombie Survival will end this round!");
Server.zombie.gameStatus = 4; Server.zombie.Status = ZombieGameStatus.LastRound;
} }
else if (s[0] == "force") else if (s[0] == "force")
{ {
if (Server.zombie.ZombieStatus() == 0) { Player.SendMessage(p, "There is no Zombie Survival game currently in progress."); return; } if (Server.zombie.Status == ZombieGameStatus.NotStarted) {
Player.SendMessage(p, "There is no Zombie Survival game currently in progress."); return;
}
Server.s.Log("Zombie Survival ended forcefully by " + p.name); Server.s.Log("Zombie Survival ended forcefully by " + p.name);
Server.zombie.aliveCount = 0; Server.zombie.aliveCount = 0;
Server.zombie.ResetState(); Server.zombie.ResetState();

View File

@ -159,7 +159,7 @@ namespace MCGalaxy.Commands {
} }
} }
if (Server.zombie.GameInProgess()) { if (Server.zombie.RoundInProgress) {
if (p.level.name == Server.zombie.currentLevelName) if (p.level.name == Server.zombie.currentLevelName)
Server.zombie.InfectedPlayerLogin(p); Server.zombie.InfectedPlayerLogin(p);
} }

View File

@ -32,7 +32,7 @@ namespace MCGalaxy.Commands {
ushort x = (ushort)(16 + (cpSpawn ? p.checkpointX : p.level.spawnx) * 32); ushort x = (ushort)(16 + (cpSpawn ? p.checkpointX : p.level.spawnx) * 32);
ushort y = (ushort)(32 + (cpSpawn ? p.checkpointY : p.level.spawny) * 32); ushort y = (ushort)(32 + (cpSpawn ? p.checkpointY : p.level.spawny) * 32);
ushort z = (ushort)(16 + (cpSpawn ? p.checkpointZ : p.level.spawnz) * 32); ushort z = (ushort)(16 + (cpSpawn ? p.checkpointZ : p.level.spawnz) * 32);
if (!p.referee && !p.infected && Server.zombie.GameInProgess()) if (!p.referee && !p.infected && Server.zombie.RoundInProgress)
Server.zombie.InfectPlayer(p); Server.zombie.InfectPlayer(p);
if (p.PlayingTntWars) { if (p.PlayingTntWars) {

View File

@ -29,31 +29,39 @@ namespace MCGalaxy {
public sealed partial class ZombieGame { public sealed partial class ZombieGame {
void MainLoop() { void MainLoop() {
if (gameStatus == 0) return; if (Status == ZombieGameStatus.NotStarted) return;
if (!initialChangeLevel) { if (!initialChangeLevel) {
ChangeLevel(); ChangeLevel();
initialChangeLevel = true; initialChangeLevel = true;
} }
while (true) { while (true) {
zombieRound = false; RoundInProgress = false;
RoundsDone++; RoundsDone++;
if (gameStatus == 0) { return; } if (Status == ZombieGameStatus.NotStarted) {
else if (gameStatus == 1) { DoRound(); if (ChangeLevels) ChangeLevel();} return;
else if (gameStatus == 2) { DoRound(); if (ChangeLevels) ChangeLevel(); gameStatus = 0; return; } } else if (Status == ZombieGameStatus.InfiniteRounds) {
else if (gameStatus == 3) DoRound();
{ if (ChangeLevels) ChangeLevel();
if (RoundsDone == MaxRounds) { ResetState(); return; } } else if (Status == ZombieGameStatus.SingleRound) {
else { DoRound(); if (ChangeLevels) ChangeLevel(); } DoRound();
ResetState(); return;
} else if (Status == ZombieGameStatus.VariableRounds) {
if (RoundsDone == MaxRounds) {
ResetState(); return;
} else {
DoRound();
if (ChangeLevels) ChangeLevel();
}
} else if (Status == ZombieGameStatus.LastRound) {
ResetState(); return;
} }
else if (gameStatus == 4) { ResetState(); return; }
} }
} }
void DoRound() void DoRound() {
{ if (Status == ZombieGameStatus.NotStarted) return;
if (gameStatus == 0) return;
List<Player> players = DoRoundCountdown(); List<Player> players = DoRoundCountdown();
theEnd: theEnd:
@ -71,7 +79,7 @@ namespace MCGalaxy {
Player.GlobalDespawn(player, false); Player.GlobalDespawn(player, false);
Player.GlobalSpawn(player, player.pos[0], player.pos[1], player.pos[2], player.rot[0], player.rot[1], false); Player.GlobalSpawn(player, player.pos[0], player.pos[1], player.pos[2], player.rot[0], player.rot[1], false);
zombieRound = true; RoundInProgress = true;
int roundMins = random.Next(5, 8); int roundMins = random.Next(5, 8);
Player.GlobalMessage("The round will last for " + roundMins + " minutes!"); Player.GlobalMessage("The round will last for " + roundMins + " minutes!");
timer = new System.Timers.Timer(roundMins * 60 * 1000); timer = new System.Timers.Timer(roundMins * 60 * 1000);
@ -90,8 +98,8 @@ namespace MCGalaxy {
aliveCount = alive.Count; aliveCount = alive.Count;
DoCoreGame(players, random); DoCoreGame(players, random);
if (gameStatus == 0) { if (Status == ZombieGameStatus.NotStarted) {
gameStatus = 4; return; Status = ZombieGameStatus.LastRound; return;
} else { } else {
HandOutRewards(); HandOutRewards();
} }
@ -117,7 +125,7 @@ namespace MCGalaxy {
Thread.Sleep(1000); if (!Server.ZombieModeOn) return null; Thread.Sleep(1000); if (!Server.ZombieModeOn) return null;
Player.GlobalMessage("%4Round Start:%f 1..."); Player.GlobalMessage("%4Round Start:%f 1...");
Thread.Sleep(1000); if (!Server.ZombieModeOn) return null; Thread.Sleep(1000); if (!Server.ZombieModeOn) return null;
zombieRound = true; RoundInProgress = true;
int nonRefPlayers = 0; int nonRefPlayers = 0;
List<Player> players = new List<Player>(); List<Player> players = new List<Player>();
@ -156,8 +164,9 @@ namespace MCGalaxy {
Player.GlobalDespawn(pAlive, false); Player.GlobalDespawn(pAlive, false);
Player.GlobalSpawn(pAlive, pAlive.pos[0], pAlive.pos[1], pAlive.pos[2], pAlive.rot[0], pAlive.rot[1], false); Player.GlobalSpawn(pAlive, pAlive.pos[0], pAlive.pos[1], pAlive.pos[2], pAlive.rot[0], pAlive.rot[1], false);
} }
if (Math.Abs(pAlive.pos[0] / 32 - pKiller.pos[0] / 32) <= 1 && Math.Abs(pAlive.pos[1] / 32 - pKiller.pos[1] / 32) <= 1 if (Math.Abs(pAlive.pos[0] - pKiller.pos[0]) <= HitboxPrecision
&& Math.Abs(pAlive.pos[2] / 32 - pKiller.pos[2] / 32) <= 1) { && Math.Abs(pAlive.pos[1] - pKiller.pos[1]) <= HitboxPrecision
&& Math.Abs(pAlive.pos[2] - pKiller.pos[2]) <= HitboxPrecision) {
if (!pAlive.infected && pKiller.infected && !pAlive.referee && !pKiller.referee && pKiller != pAlive && pKiller.level.name == currentLevelName && pAlive.level.name == currentLevelName) if (!pAlive.infected && pKiller.infected && !pAlive.referee && !pKiller.referee && pKiller != pAlive && pKiller.level.name == currentLevelName && pAlive.level.name == currentLevelName)
{ {
pAlive.infected = true; pAlive.infected = true;
@ -208,7 +217,7 @@ namespace MCGalaxy {
} }
public void EndRound(object sender, ElapsedEventArgs e) { public void EndRound(object sender, ElapsedEventArgs e) {
if (gameStatus == 0) return; if (Status == ZombieGameStatus.NotStarted) return;
Player.GlobalMessage("%4Round End:%f 5"); Thread.Sleep(1000); Player.GlobalMessage("%4Round End:%f 5"); Thread.Sleep(1000);
Player.GlobalMessage("%4Round End:%f 4"); Thread.Sleep(1000); Player.GlobalMessage("%4Round End:%f 4"); Thread.Sleep(1000);
Player.GlobalMessage("%4Round End:%f 3"); Thread.Sleep(1000); Player.GlobalMessage("%4Round End:%f 3"); Thread.Sleep(1000);
@ -218,8 +227,8 @@ namespace MCGalaxy {
} }
public void HandOutRewards() { public void HandOutRewards() {
zombieRound = false; RoundInProgress = false;
if (gameStatus == 0) return; if (Status == ZombieGameStatus.NotStarted) return;
Player.GlobalMessage(Colors.lime + "The game has ended!"); Player.GlobalMessage(Colors.lime + "The game has ended!");
if(aliveCount == 0) if(aliveCount == 0)
Player.GlobalMessage(Colors.maroon + "Zombies have won this round."); Player.GlobalMessage(Colors.maroon + "Zombies have won this round.");
@ -375,7 +384,8 @@ namespace MCGalaxy {
Level1Vote = 0; Level2Vote = 0; Level3Vote = 0; Level1Vote = 0; Level2Vote = 0; Level3Vote = 0;
lastLevelVote1 = selectedLevel1; lastLevelVote2 = selectedLevel2; lastLevelVote1 = selectedLevel1; lastLevelVote2 = selectedLevel2;
if (gameStatus == 4 || gameStatus == 0) { return; } if (Status == ZombieGameStatus.NotStarted || Status == ZombieGameStatus.LastRound)
return;
if (initialChangeLevel) if (initialChangeLevel)
{ {
@ -387,7 +397,8 @@ namespace MCGalaxy {
} }
else { Level1Vote = 1; Level2Vote = 0; Level3Vote = 0; } else { Level1Vote = 1; Level2Vote = 0; Level3Vote = 0; }
if (gameStatus == 4 || gameStatus == 0) { return; } if (Status == ZombieGameStatus.NotStarted || Status == ZombieGameStatus.LastRound)
return;
if (Level1Vote >= Level2Vote) if (Level1Vote >= Level2Vote)
{ {

View File

@ -90,7 +90,7 @@ namespace MCGalaxy {
} }
public override void PlayerJoinedServer(Player p) { public override void PlayerJoinedServer(Player p) {
if (ZombieStatus() != 0) if (Status != ZombieGameStatus.NotStarted)
Player.SendMessage(p, "There is a Zombie Survival game currently in-progress! " + Player.SendMessage(p, "There is a Zombie Survival game currently in-progress! " +
"Join it by typing /g " + Server.zombie.currentLevelName); "Join it by typing /g " + Server.zombie.currentLevelName);
} }

View File

@ -35,13 +35,24 @@ namespace MCGalaxy {
} }
} }
public enum ZombieGameStatus { NotStarted, InfiniteRounds, SingleRound, VariableRounds, LastRound }
public sealed partial class ZombieGame { public sealed partial class ZombieGame {
/// <summary> The number of rounds that have been played in this game so far. </summary> /// <summary> The number of rounds that have been played in this game so far. </summary>
public int RoundsDone = 0; public int RoundsDone = 0;
/// <summary> The maximum number of rounds that can be played before the game ends. </summary> /// <summary> The maximum number of rounds that can be played before the game ends. </summary>
public int MaxRounds = 0; public int MaxRounds = 0;
/// <summary> How precise collision detection is between alive and dead players. (Where 1 block = 32 units) </summary>
public int HitboxPrecision = 24;
/// <summary> Current round status of the game. </summary>
public ZombieGameStatus Status = ZombieGameStatus.NotStarted;
public bool RoundInProgress = false;
public int aliveCount = 0; public int aliveCount = 0;
public string currentZombieLevel = ""; public string currentZombieLevel = "";
public static System.Timers.Timer timer; public static System.Timers.Timer timer;
@ -54,10 +65,8 @@ namespace MCGalaxy {
internal bool noRespawn = true, noLevelSaving = true, noPillaring = true; internal bool noRespawn = true, noLevelSaving = true, noPillaring = true;
internal string ZombieName = ""; internal string ZombieName = "";
internal int gameStatus = 0; //0 = not started, 1 = always on, 2 = one time, 3 = certain amount of rounds, 4 = stop game next round
internal bool queLevel = false, queZombie = false; internal bool queLevel = false, queZombie = false;
internal string nextZombie = "", nextLevel = ""; internal string nextZombie = "", nextLevel = "";
internal bool zombieRound = false;
internal bool ChangeLevels = true, UseLevelList = false; internal bool ChangeLevels = true, UseLevelList = false;
internal List<string> LevelList = new List<string>(); internal List<string> LevelList = new List<string>();
@ -69,63 +78,42 @@ namespace MCGalaxy {
int infectCombo = 0; int infectCombo = 0;
public Dictionary<string, BountyData> Bounties = new Dictionary<string, BountyData>(); public Dictionary<string, BountyData> Bounties = new Dictionary<string, BountyData>();
public void StartGame(int status, int amount) public void Start(ZombieGameStatus status, int amount) {
{
//status: 0 = not started, 1 = always on, 2 = one time, 3 = certain amount of rounds, 4 = stop round next round
if (status == 0) return;
//SET ALL THE VARIABLES!
if (UseLevelList && LevelList == null) if (UseLevelList && LevelList == null)
ChangeLevels = false; ChangeLevels = false;
Server.ZombieModeOn = true; Server.ZombieModeOn = true;
gameStatus = status; Status = status;
zombieRound = false; RoundInProgress = false;
initialChangeLevel = false; initialChangeLevel = false;
MaxRounds = amount + 1; MaxRounds = amount + 1;
RoundsDone = 0; RoundsDone = 0;
//SET ALL THE VARIABLES?!?
//Start the main Zombie thread Thread t = new Thread(MainLoop);
Thread t = new Thread(MainLoop); t.Name = "MCG_ZombieGame";
t.Name = "MCG_ZombieGame"; t.Start();
t.Start();
} }
public void InfectedPlayerDC() public void InfectedPlayerDC() {
{ if (Status == ZombieGameStatus.NotStarted) return;
if (gameStatus == 0) return;
//This is for when the first zombie disconnects //This is for when the first zombie disconnects
Random random = new Random(); Random random = new Random();
if ((gameStatus != 0 && zombieRound) && infectd.Count <= 0) if ((Status != ZombieGameStatus.NotStarted && RoundInProgress) && infectd.Count <= 0) {
{ if (alive.Count == 0) return;
int firstinfect = random.Next(alive.Count); int index = random.Next(alive.Count);
firstinfect = firstinfect - 1;
while (alive[firstinfect].referee || alive[firstinfect].level.name == Server.zombie.currentLevelName) while (alive[index].referee || alive[index].level.name == Server.zombie.currentLevelName) {
{ if (index >= alive.Count - 1) index = 0;
if (firstinfect == alive.Count) else index++;
{
firstinfect = 0;
}
else
{
firstinfect++;
}
} }
Player.GlobalMessage(alive[firstinfect].color + alive[firstinfect].name + Server.DefaultColor + " continued the infection!");
alive[firstinfect].color = Colors.red; Player zombie = alive[index];
Player.GlobalDespawn(alive[firstinfect], false); Player.GlobalMessage(zombie.FullName + " %Scontinued the infection!");
Player.GlobalSpawn(alive[firstinfect], alive[firstinfect].pos[0], alive[firstinfect].pos[1], alive[firstinfect].pos[2], alive[firstinfect].rot[0], alive[firstinfect].rot[1], false); InfectPlayer(zombie);
infectd.Add(alive[firstinfect]);
alive.Remove(alive[firstinfect]);
} }
return;
} }
public bool InfectedPlayerLogin(Player p) public bool InfectedPlayerLogin(Player p) {
{ if (Status == ZombieGameStatus.NotStarted || p == null) return false;
if (gameStatus == 0) return false;
if (p == null) return false;
if (p.level.name != Server.zombie.currentLevelName) return false; if (p.level.name != Server.zombie.currentLevelName) return false;
p.SendMessage("You have joined in the middle of a round. You are now infected!"); p.SendMessage("You have joined in the middle of a round. You are now infected!");
p.blockCount = 50; p.blockCount = 50;
@ -137,19 +125,9 @@ namespace MCGalaxy {
return true; return true;
} }
public int ZombieStatus()
{
return gameStatus;
}
public bool GameInProgess()
{
return zombieRound;
}
public void InfectPlayer(Player p) public void InfectPlayer(Player p)
{ {
if (!zombieRound || p == null) return; if (!RoundInProgress || p == null) return;
infectd.Add(p); infectd.Add(p);
alive.Remove(p); alive.Remove(p);
p.infected = true; p.infected = true;
@ -161,7 +139,7 @@ namespace MCGalaxy {
public void DisinfectPlayer(Player p) public void DisinfectPlayer(Player p)
{ {
if (!zombieRound || p == null) return; if (!RoundInProgress || p == null) return;
infectd.Remove(p); infectd.Remove(p);
alive.Add(p); alive.Add(p);
p.infected = false; p.infected = false;
@ -206,11 +184,11 @@ namespace MCGalaxy {
} }
public void ResetState() { public void ResetState() {
gameStatus = 0; Status = ZombieGameStatus.NotStarted;
MaxRounds = 0; MaxRounds = 0;
initialChangeLevel = false; initialChangeLevel = false;
Server.ZombieModeOn = false; Server.ZombieModeOn = false;
zombieRound = false; RoundInProgress = false;
} }
} }
} }

View File

@ -180,12 +180,14 @@
<Compile Include="Commands\Fun\CmdCountdown.cs" /> <Compile Include="Commands\Fun\CmdCountdown.cs" />
<Compile Include="Commands\Fun\CmdCtf.cs" /> <Compile Include="Commands\Fun\CmdCtf.cs" />
<Compile Include="Commands\Fun\CmdDisinfect.cs" /> <Compile Include="Commands\Fun\CmdDisinfect.cs" />
<Compile Include="Commands\Fun\CmdEndRound.cs" />
<Compile Include="Commands\Fun\CmdFliphead.cs" /> <Compile Include="Commands\Fun\CmdFliphead.cs" />
<Compile Include="Commands\Fun\CmdFlipHeads.cs" /> <Compile Include="Commands\Fun\CmdFlipHeads.cs" />
<Compile Include="Commands\Fun\CmdInfect.cs" /> <Compile Include="Commands\Fun\CmdInfect.cs" />
<Compile Include="Commands\Fun\CmdInfected.cs" /> <Compile Include="Commands\Fun\CmdInfected.cs" />
<Compile Include="Commands\Fun\CmdLavaSurvival.cs" /> <Compile Include="Commands\Fun\CmdLavaSurvival.cs" />
<Compile Include="Commands\Fun\CmdQueue.cs" /> <Compile Include="Commands\Fun\CmdQueue.cs" />
<Compile Include="Commands\Fun\CmdReferee.cs" />
<Compile Include="Commands\Fun\CmdSlap.cs" /> <Compile Include="Commands\Fun\CmdSlap.cs" />
<Compile Include="Commands\Fun\CmdTntWars.cs" /> <Compile Include="Commands\Fun\CmdTntWars.cs" />
<Compile Include="Commands\Fun\CmdZombieGame.cs" /> <Compile Include="Commands\Fun\CmdZombieGame.cs" />
@ -242,7 +244,6 @@
<Compile Include="Commands\Moderation\CmdCrashServer.cs" /> <Compile Include="Commands\Moderation\CmdCrashServer.cs" />
<Compile Include="Commands\Moderation\CmdDelTempRank.cs" /> <Compile Include="Commands\Moderation\CmdDelTempRank.cs" />
<Compile Include="Commands\Moderation\CmdDemote.cs" /> <Compile Include="Commands\Moderation\CmdDemote.cs" />
<Compile Include="Commands\Moderation\CmdEndRound.cs" />
<Compile Include="Commands\Moderation\CmdExplode.cs" /> <Compile Include="Commands\Moderation\CmdExplode.cs" />
<Compile Include="Commands\Moderation\CmdFollow.cs" /> <Compile Include="Commands\Moderation\CmdFollow.cs" />
<Compile Include="Commands\Moderation\CmdFreeze.cs" /> <Compile Include="Commands\Moderation\CmdFreeze.cs" />
@ -273,7 +274,6 @@
<Compile Include="Commands\Moderation\CmdPromote.cs" /> <Compile Include="Commands\Moderation\CmdPromote.cs" />
<Compile Include="Commands\Moderation\CmdPUnload.cs" /> <Compile Include="Commands\Moderation\CmdPUnload.cs" />
<Compile Include="Commands\Moderation\CmdRankInfo.cs" /> <Compile Include="Commands\Moderation\CmdRankInfo.cs" />
<Compile Include="Commands\Moderation\CmdReferee.cs" />
<Compile Include="Commands\Moderation\CmdRenameLvl.cs" /> <Compile Include="Commands\Moderation\CmdRenameLvl.cs" />
<Compile Include="Commands\Moderation\CmdResetBot.cs" /> <Compile Include="Commands\Moderation\CmdResetBot.cs" />
<Compile Include="Commands\Moderation\CmdRestart.cs" /> <Compile Include="Commands\Moderation\CmdRestart.cs" />

View File

@ -186,7 +186,7 @@ namespace MCGalaxy {
if (Server.lava.startOnStartup) if (Server.lava.startOnStartup)
Server.lava.Start(); Server.lava.Start();
if (Server.startZombieModeOnStartup) if (Server.startZombieModeOnStartup)
Server.zombie.StartGame(1, 0); Server.zombie.Start(ZombieGameStatus.InfiniteRounds, 0);
//This doesnt use the main map //This doesnt use the main map
if (Server.UseCTF) if (Server.UseCTF)
ctf = new Auto_CTF(); ctf = new Auto_CTF();