mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-27 07:11:04 -04:00
More code cleanup for zombie survival.
This commit is contained in:
parent
6b04139c5b
commit
ab6c4288bc
@ -21,10 +21,12 @@ namespace MCGalaxy.Commands
|
||||
{
|
||||
public override string name { 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 LevelPermission defaultRank { get { return LevelPermission.Banned; } }
|
||||
public override bool Enabled { get { return Server.ZombieModeOn; } }
|
||||
public CmdAlive() { }
|
||||
|
||||
public override void Use(Player p, string message)
|
||||
{
|
||||
if (ZombieGame.alive.Count == 0)
|
||||
|
@ -31,7 +31,7 @@ namespace MCGalaxy.Commands {
|
||||
Player who = message == "" ? p : PlayerInfo.FindOrShowMatches(p, message);
|
||||
if (who == null) return;
|
||||
|
||||
if (!who.infected || !Server.zombie.GameInProgess()) {
|
||||
if (!who.infected || !Server.zombie.RoundInProgress) {
|
||||
Player.SendMessage(p, "Cannot disinfect player");
|
||||
} else if (!who.referee) {
|
||||
Server.zombie.DisinfectPlayer(who);
|
||||
|
@ -1,40 +1,39 @@
|
||||
/*
|
||||
Copyright 2011 MCForge
|
||||
|
||||
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||
the GNU General Public License, Version 3 (the "Licenses"); you may
|
||||
not use this file except in compliance with the Licenses. You may
|
||||
obtain a copy of the Licenses at
|
||||
|
||||
http://www.opensource.org/licenses/ecl2.php
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the Licenses are distributed on an "AS IS"
|
||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
or implied. See the Licenses for the specific language governing
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
namespace MCGalaxy.Commands
|
||||
{
|
||||
public sealed class CmdEndRound : Command
|
||||
{
|
||||
public override string name { get { return "endround"; } }
|
||||
public override string shortcut { get { return "er"; } }
|
||||
public override string type { get { return CommandTypes.Moderation; } }
|
||||
public override bool museumUsable { get { return true; } }
|
||||
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
|
||||
public CmdEndRound() { }
|
||||
public override void Use(Player p, string message)
|
||||
{
|
||||
if (Server.zombie.GameInProgess())
|
||||
{
|
||||
Server.zombie.HandOutRewards();
|
||||
}
|
||||
}
|
||||
public override void Help(Player p)
|
||||
{
|
||||
Player.SendMessage(p, "/endround - ends the round");
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
Copyright 2011 MCForge
|
||||
|
||||
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||
the GNU General Public License, Version 3 (the "Licenses"); you may
|
||||
not use this file except in compliance with the Licenses. You may
|
||||
obtain a copy of the Licenses at
|
||||
|
||||
http://www.opensource.org/licenses/ecl2.php
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the Licenses are distributed on an "AS IS"
|
||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
or implied. See the Licenses for the specific language governing
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
namespace MCGalaxy.Commands
|
||||
{
|
||||
public sealed class CmdEndRound : Command
|
||||
{
|
||||
public override string name { get { return "endround"; } }
|
||||
public override string shortcut { get { return "er"; } }
|
||||
public override string type { get { return CommandTypes.Moderation; } }
|
||||
public override bool museumUsable { get { return true; } }
|
||||
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
|
||||
public override bool Enabled { get { return Server.ZombieModeOn; } }
|
||||
public CmdEndRound() { }
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
if (Server.zombie.RoundInProgress)
|
||||
Server.zombie.HandOutRewards();
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
Player.SendMessage(p, "/endround - ends the round");
|
||||
}
|
||||
}
|
||||
}
|
@ -31,7 +31,7 @@ namespace MCGalaxy.Commands {
|
||||
Player who = message == "" ? p : PlayerInfo.FindOrShowMatches(p, message);
|
||||
if (who == null) return;
|
||||
|
||||
if (who.infected || !Server.zombie.GameInProgess()) {
|
||||
if (who.infected || !Server.zombie.RoundInProgress) {
|
||||
Player.SendMessage(p, "Cannot infect player");
|
||||
} else if (!who.referee) {
|
||||
Server.zombie.InfectPlayer(who);
|
||||
|
@ -1,79 +1,81 @@
|
||||
/*
|
||||
Copyright 2011 MCForge
|
||||
|
||||
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||
the GNU General Public License, Version 3 (the "Licenses"); you may
|
||||
not use this file except in compliance with the Licenses. You may
|
||||
obtain a copy of the Licenses at
|
||||
|
||||
http://www.opensource.org/licenses/ecl2.php
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the Licenses are distributed on an "AS IS"
|
||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
or implied. See the Licenses for the specific language governing
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
namespace MCGalaxy.Commands
|
||||
{
|
||||
public sealed class CmdReferee : Command
|
||||
{
|
||||
public override string name { get { return "ref"; } }
|
||||
public override string shortcut { get { return ""; } }
|
||||
public override string type { get { return CommandTypes.Moderation; } }
|
||||
public override bool museumUsable { get { return true; } }
|
||||
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
|
||||
public CmdReferee() { }
|
||||
public override void Use(Player p, string message)
|
||||
{
|
||||
if (p == null) { MessageInGameOnly(p); return; }
|
||||
if (p.referee)
|
||||
{
|
||||
p.referee = false;
|
||||
LevelPermission perm = Group.findPlayerGroup(name).Permission;
|
||||
Player.GlobalDespawn(p, false);
|
||||
Player.SendChatFrom(p, p.color + p.name + Server.DefaultColor + " is no longer a referee", false);
|
||||
if (Server.zombie.GameInProgess())
|
||||
{
|
||||
Server.zombie.InfectPlayer(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
Player.GlobalDespawn(p, false);
|
||||
Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], false);
|
||||
ZombieGame.infectd.Remove(p);
|
||||
ZombieGame.alive.Add(p);
|
||||
p.color = p.group.color;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
p.referee = true;
|
||||
Player.SendChatFrom(p, p.color + p.name + Server.DefaultColor + " is now a referee", false);
|
||||
Player.GlobalDespawn(p, false);
|
||||
if (Server.zombie.GameInProgess())
|
||||
{
|
||||
p.color = p.group.color;
|
||||
try
|
||||
{
|
||||
ZombieGame.infectd.Remove(p);
|
||||
ZombieGame.alive.Remove(p);
|
||||
}
|
||||
catch { }
|
||||
Server.zombie.InfectedPlayerDC();
|
||||
}
|
||||
else
|
||||
{
|
||||
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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
Copyright 2011 MCForge
|
||||
|
||||
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||
the GNU General Public License, Version 3 (the "Licenses"); you may
|
||||
not use this file except in compliance with the Licenses. You may
|
||||
obtain a copy of the Licenses at
|
||||
|
||||
http://www.opensource.org/licenses/ecl2.php
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the Licenses are distributed on an "AS IS"
|
||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
or implied. See the Licenses for the specific language governing
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
namespace MCGalaxy.Commands
|
||||
{
|
||||
public sealed class CmdReferee : Command
|
||||
{
|
||||
public override string name { get { return "ref"; } }
|
||||
public override string shortcut { get { return ""; } }
|
||||
public override string type { get { return CommandTypes.Moderation; } }
|
||||
public override bool museumUsable { get { return true; } }
|
||||
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
|
||||
public override bool Enabled { get { return Server.ZombieModeOn; } }
|
||||
public CmdReferee() { }
|
||||
|
||||
public override void Use(Player p, string message)
|
||||
{
|
||||
if (p == null) { MessageInGameOnly(p); return; }
|
||||
if (p.referee)
|
||||
{
|
||||
p.referee = false;
|
||||
LevelPermission perm = Group.findPlayerGroup(name).Permission;
|
||||
Player.GlobalDespawn(p, false);
|
||||
Player.SendChatFrom(p, p.FullName + " %Sis no longer a referee", false);
|
||||
if (Server.zombie.RoundInProgress)
|
||||
{
|
||||
Server.zombie.InfectPlayer(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
Player.GlobalDespawn(p, false);
|
||||
Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], false);
|
||||
ZombieGame.infectd.Remove(p);
|
||||
ZombieGame.alive.Add(p);
|
||||
p.color = p.group.color;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
p.referee = true;
|
||||
Player.SendChatFrom(p, p.FullName + " %Sis now a referee", false);
|
||||
Player.GlobalDespawn(p, false);
|
||||
if (Server.zombie.RoundInProgress)
|
||||
{
|
||||
p.color = p.group.color;
|
||||
try
|
||||
{
|
||||
ZombieGame.infectd.Remove(p);
|
||||
ZombieGame.alive.Remove(p);
|
||||
}
|
||||
catch { }
|
||||
Server.zombie.InfectedPlayerDC();
|
||||
}
|
||||
else
|
||||
{
|
||||
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.");
|
||||
}
|
||||
}
|
||||
}
|
@ -33,52 +33,50 @@ namespace MCGalaxy.Commands
|
||||
string[] s = message.ToLower().Split(' ');
|
||||
if (s[0] == "status")
|
||||
{
|
||||
switch (Server.zombie.ZombieStatus())
|
||||
{
|
||||
case 0:
|
||||
Player.GlobalMessage("There is no Zombie Survival game currently in progress.");
|
||||
return;
|
||||
case 1:
|
||||
Player.SendMessage(p, "There is a Zombie Survival game currently in progress with infinite rounds.");
|
||||
return;
|
||||
case 2:
|
||||
Player.SendMessage(p, "There is a one-time Zombie Survival game currently in progress.");
|
||||
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;
|
||||
switch (Server.zombie.Status) {
|
||||
case ZombieGameStatus.NotStarted:
|
||||
Player.SendMessage(p, "Zombie Survival is not ccurrently running."); return;
|
||||
case ZombieGameStatus.InfiniteRounds:
|
||||
Player.SendMessage(p, "Zombie Survival is currently in progress with infinite rounds."); return;
|
||||
case ZombieGameStatus.SingleRound:
|
||||
Player.SendMessage(p, "Zombie Survival game currently in progress."); return;
|
||||
case ZombieGameStatus.VariableRounds:
|
||||
Player.SendMessage(p, "Zombie Survival game currently in progress with " + Server.zombie.MaxRounds + " rounds."); return;
|
||||
case ZombieGameStatus.LastRound:
|
||||
Player.SendMessage(p, "Zombie Survival game currently in progress, with this round being the final round."); return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
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) {
|
||||
int rounds = 1;
|
||||
bool result = int.TryParse(s[1], out rounds);
|
||||
if (result == false) { Player.SendMessage(p, "You need to specify a valid option!"); return; }
|
||||
if (s[1] == "0")
|
||||
Server.zombie.StartGame(1, 0);
|
||||
else
|
||||
Server.zombie.StartGame(3, rounds);
|
||||
if (!int.TryParse(s[1], out rounds)) {
|
||||
Player.SendMessage(p, "You need to specify a valid option!"); return;
|
||||
}
|
||||
ZombieGameStatus status = rounds == 0 ?
|
||||
ZombieGameStatus.InfiniteRounds : ZombieGameStatus.VariableRounds;
|
||||
Server.zombie.Start(status, rounds);
|
||||
} else {
|
||||
Server.zombie.StartGame(2, 0);
|
||||
Server.zombie.Start(ZombieGameStatus.SingleRound, 0);
|
||||
}
|
||||
}
|
||||
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!");
|
||||
Server.zombie.gameStatus = 4;
|
||||
Server.zombie.Status = ZombieGameStatus.LastRound;
|
||||
}
|
||||
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.zombie.aliveCount = 0;
|
||||
Server.zombie.ResetState();
|
||||
|
@ -159,7 +159,7 @@ namespace MCGalaxy.Commands {
|
||||
}
|
||||
}
|
||||
|
||||
if (Server.zombie.GameInProgess()) {
|
||||
if (Server.zombie.RoundInProgress) {
|
||||
if (p.level.name == Server.zombie.currentLevelName)
|
||||
Server.zombie.InfectedPlayerLogin(p);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ namespace MCGalaxy.Commands {
|
||||
ushort x = (ushort)(16 + (cpSpawn ? p.checkpointX : p.level.spawnx) * 32);
|
||||
ushort y = (ushort)(32 + (cpSpawn ? p.checkpointY : p.level.spawny) * 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);
|
||||
|
||||
if (p.PlayingTntWars) {
|
||||
|
@ -29,31 +29,39 @@ namespace MCGalaxy {
|
||||
public sealed partial class ZombieGame {
|
||||
|
||||
void MainLoop() {
|
||||
if (gameStatus == 0) return;
|
||||
if (Status == ZombieGameStatus.NotStarted) return;
|
||||
if (!initialChangeLevel) {
|
||||
ChangeLevel();
|
||||
initialChangeLevel = true;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
zombieRound = false;
|
||||
RoundInProgress = false;
|
||||
RoundsDone++;
|
||||
|
||||
if (gameStatus == 0) { return; }
|
||||
else if (gameStatus == 1) { DoRound(); if (ChangeLevels) ChangeLevel();}
|
||||
else if (gameStatus == 2) { DoRound(); if (ChangeLevels) ChangeLevel(); gameStatus = 0; return; }
|
||||
else if (gameStatus == 3)
|
||||
{
|
||||
if (RoundsDone == MaxRounds) { ResetState(); return; }
|
||||
else { DoRound(); if (ChangeLevels) ChangeLevel(); }
|
||||
if (Status == ZombieGameStatus.NotStarted) {
|
||||
return;
|
||||
} else if (Status == ZombieGameStatus.InfiniteRounds) {
|
||||
DoRound();
|
||||
if (ChangeLevels) ChangeLevel();
|
||||
} else if (Status == ZombieGameStatus.SingleRound) {
|
||||
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()
|
||||
{
|
||||
if (gameStatus == 0) return;
|
||||
void DoRound() {
|
||||
if (Status == ZombieGameStatus.NotStarted) return;
|
||||
List<Player> players = DoRoundCountdown();
|
||||
|
||||
theEnd:
|
||||
@ -71,7 +79,7 @@ namespace MCGalaxy {
|
||||
Player.GlobalDespawn(player, 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);
|
||||
Player.GlobalMessage("The round will last for " + roundMins + " minutes!");
|
||||
timer = new System.Timers.Timer(roundMins * 60 * 1000);
|
||||
@ -90,8 +98,8 @@ namespace MCGalaxy {
|
||||
aliveCount = alive.Count;
|
||||
DoCoreGame(players, random);
|
||||
|
||||
if (gameStatus == 0) {
|
||||
gameStatus = 4; return;
|
||||
if (Status == ZombieGameStatus.NotStarted) {
|
||||
Status = ZombieGameStatus.LastRound; return;
|
||||
} else {
|
||||
HandOutRewards();
|
||||
}
|
||||
@ -117,7 +125,7 @@ namespace MCGalaxy {
|
||||
Thread.Sleep(1000); if (!Server.ZombieModeOn) return null;
|
||||
Player.GlobalMessage("%4Round Start:%f 1...");
|
||||
Thread.Sleep(1000); if (!Server.ZombieModeOn) return null;
|
||||
zombieRound = true;
|
||||
RoundInProgress = true;
|
||||
int nonRefPlayers = 0;
|
||||
List<Player> players = new List<Player>();
|
||||
|
||||
@ -156,8 +164,9 @@ namespace MCGalaxy {
|
||||
Player.GlobalDespawn(pAlive, 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
|
||||
&& Math.Abs(pAlive.pos[2] / 32 - pKiller.pos[2] / 32) <= 1) {
|
||||
if (Math.Abs(pAlive.pos[0] - pKiller.pos[0]) <= HitboxPrecision
|
||||
&& 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)
|
||||
{
|
||||
pAlive.infected = true;
|
||||
@ -208,7 +217,7 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
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 4"); Thread.Sleep(1000);
|
||||
Player.GlobalMessage("%4Round End:%f 3"); Thread.Sleep(1000);
|
||||
@ -218,8 +227,8 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
public void HandOutRewards() {
|
||||
zombieRound = false;
|
||||
if (gameStatus == 0) return;
|
||||
RoundInProgress = false;
|
||||
if (Status == ZombieGameStatus.NotStarted) return;
|
||||
Player.GlobalMessage(Colors.lime + "The game has ended!");
|
||||
if(aliveCount == 0)
|
||||
Player.GlobalMessage(Colors.maroon + "Zombies have won this round.");
|
||||
@ -375,7 +384,8 @@ namespace MCGalaxy {
|
||||
Level1Vote = 0; Level2Vote = 0; Level3Vote = 0;
|
||||
lastLevelVote1 = selectedLevel1; lastLevelVote2 = selectedLevel2;
|
||||
|
||||
if (gameStatus == 4 || gameStatus == 0) { return; }
|
||||
if (Status == ZombieGameStatus.NotStarted || Status == ZombieGameStatus.LastRound)
|
||||
return;
|
||||
|
||||
if (initialChangeLevel)
|
||||
{
|
||||
@ -387,7 +397,8 @@ namespace MCGalaxy {
|
||||
}
|
||||
else { Level1Vote = 1; Level2Vote = 0; Level3Vote = 0; }
|
||||
|
||||
if (gameStatus == 4 || gameStatus == 0) { return; }
|
||||
if (Status == ZombieGameStatus.NotStarted || Status == ZombieGameStatus.LastRound)
|
||||
return;
|
||||
|
||||
if (Level1Vote >= Level2Vote)
|
||||
{
|
||||
|
@ -90,7 +90,7 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
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! " +
|
||||
"Join it by typing /g " + Server.zombie.currentLevelName);
|
||||
}
|
||||
|
@ -35,13 +35,24 @@ namespace MCGalaxy {
|
||||
}
|
||||
}
|
||||
|
||||
public enum ZombieGameStatus { NotStarted, InfiniteRounds, SingleRound, VariableRounds, LastRound }
|
||||
|
||||
public sealed partial class ZombieGame {
|
||||
|
||||
/// <summary> The number of rounds that have been played in this game so far. </summary>
|
||||
public int RoundsDone = 0;
|
||||
|
||||
/// <summary> The maximum number of rounds that can be played before the game ends. </summary>
|
||||
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 string currentZombieLevel = "";
|
||||
public static System.Timers.Timer timer;
|
||||
@ -54,10 +65,8 @@ namespace MCGalaxy {
|
||||
|
||||
internal bool noRespawn = true, noLevelSaving = true, noPillaring = true;
|
||||
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 string nextZombie = "", nextLevel = "";
|
||||
internal bool zombieRound = false;
|
||||
internal bool ChangeLevels = true, UseLevelList = false;
|
||||
|
||||
internal List<string> LevelList = new List<string>();
|
||||
@ -69,63 +78,42 @@ namespace MCGalaxy {
|
||||
int infectCombo = 0;
|
||||
public Dictionary<string, BountyData> Bounties = new Dictionary<string, BountyData>();
|
||||
|
||||
public void StartGame(int 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!
|
||||
public void Start(ZombieGameStatus status, int amount) {
|
||||
if (UseLevelList && LevelList == null)
|
||||
ChangeLevels = false;
|
||||
Server.ZombieModeOn = true;
|
||||
gameStatus = status;
|
||||
zombieRound = false;
|
||||
Status = status;
|
||||
RoundInProgress = false;
|
||||
initialChangeLevel = false;
|
||||
MaxRounds = amount + 1;
|
||||
RoundsDone = 0;
|
||||
//SET ALL THE VARIABLES?!?
|
||||
|
||||
//Start the main Zombie thread
|
||||
Thread t = new Thread(MainLoop);
|
||||
t.Name = "MCG_ZombieGame";
|
||||
t.Start();
|
||||
Thread t = new Thread(MainLoop);
|
||||
t.Name = "MCG_ZombieGame";
|
||||
t.Start();
|
||||
}
|
||||
|
||||
public void InfectedPlayerDC()
|
||||
{
|
||||
if (gameStatus == 0) return;
|
||||
public void InfectedPlayerDC() {
|
||||
if (Status == ZombieGameStatus.NotStarted) return;
|
||||
//This is for when the first zombie disconnects
|
||||
Random random = new Random();
|
||||
if ((gameStatus != 0 && zombieRound) && infectd.Count <= 0)
|
||||
{
|
||||
int firstinfect = random.Next(alive.Count);
|
||||
firstinfect = firstinfect - 1;
|
||||
while (alive[firstinfect].referee || alive[firstinfect].level.name == Server.zombie.currentLevelName)
|
||||
{
|
||||
if (firstinfect == alive.Count)
|
||||
{
|
||||
firstinfect = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
firstinfect++;
|
||||
}
|
||||
if ((Status != ZombieGameStatus.NotStarted && RoundInProgress) && infectd.Count <= 0) {
|
||||
if (alive.Count == 0) return;
|
||||
int index = random.Next(alive.Count);
|
||||
|
||||
while (alive[index].referee || alive[index].level.name == Server.zombie.currentLevelName) {
|
||||
if (index >= alive.Count - 1) index = 0;
|
||||
else index++;
|
||||
}
|
||||
Player.GlobalMessage(alive[firstinfect].color + alive[firstinfect].name + Server.DefaultColor + " continued the infection!");
|
||||
alive[firstinfect].color = Colors.red;
|
||||
Player.GlobalDespawn(alive[firstinfect], false);
|
||||
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);
|
||||
infectd.Add(alive[firstinfect]);
|
||||
alive.Remove(alive[firstinfect]);
|
||||
|
||||
Player zombie = alive[index];
|
||||
Player.GlobalMessage(zombie.FullName + " %Scontinued the infection!");
|
||||
InfectPlayer(zombie);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
public bool InfectedPlayerLogin(Player p)
|
||||
{
|
||||
if (gameStatus == 0) return false;
|
||||
if (p == null) return false;
|
||||
public bool InfectedPlayerLogin(Player p) {
|
||||
if (Status == ZombieGameStatus.NotStarted || p == null) 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.blockCount = 50;
|
||||
@ -137,19 +125,9 @@ namespace MCGalaxy {
|
||||
return true;
|
||||
}
|
||||
|
||||
public int ZombieStatus()
|
||||
{
|
||||
return gameStatus;
|
||||
}
|
||||
|
||||
public bool GameInProgess()
|
||||
{
|
||||
return zombieRound;
|
||||
}
|
||||
|
||||
public void InfectPlayer(Player p)
|
||||
{
|
||||
if (!zombieRound || p == null) return;
|
||||
if (!RoundInProgress || p == null) return;
|
||||
infectd.Add(p);
|
||||
alive.Remove(p);
|
||||
p.infected = true;
|
||||
@ -161,7 +139,7 @@ namespace MCGalaxy {
|
||||
|
||||
public void DisinfectPlayer(Player p)
|
||||
{
|
||||
if (!zombieRound || p == null) return;
|
||||
if (!RoundInProgress || p == null) return;
|
||||
infectd.Remove(p);
|
||||
alive.Add(p);
|
||||
p.infected = false;
|
||||
@ -206,11 +184,11 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
public void ResetState() {
|
||||
gameStatus = 0;
|
||||
Status = ZombieGameStatus.NotStarted;
|
||||
MaxRounds = 0;
|
||||
initialChangeLevel = false;
|
||||
Server.ZombieModeOn = false;
|
||||
zombieRound = false;
|
||||
RoundInProgress = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -180,12 +180,14 @@
|
||||
<Compile Include="Commands\Fun\CmdCountdown.cs" />
|
||||
<Compile Include="Commands\Fun\CmdCtf.cs" />
|
||||
<Compile Include="Commands\Fun\CmdDisinfect.cs" />
|
||||
<Compile Include="Commands\Fun\CmdEndRound.cs" />
|
||||
<Compile Include="Commands\Fun\CmdFliphead.cs" />
|
||||
<Compile Include="Commands\Fun\CmdFlipHeads.cs" />
|
||||
<Compile Include="Commands\Fun\CmdInfect.cs" />
|
||||
<Compile Include="Commands\Fun\CmdInfected.cs" />
|
||||
<Compile Include="Commands\Fun\CmdLavaSurvival.cs" />
|
||||
<Compile Include="Commands\Fun\CmdQueue.cs" />
|
||||
<Compile Include="Commands\Fun\CmdReferee.cs" />
|
||||
<Compile Include="Commands\Fun\CmdSlap.cs" />
|
||||
<Compile Include="Commands\Fun\CmdTntWars.cs" />
|
||||
<Compile Include="Commands\Fun\CmdZombieGame.cs" />
|
||||
@ -242,7 +244,6 @@
|
||||
<Compile Include="Commands\Moderation\CmdCrashServer.cs" />
|
||||
<Compile Include="Commands\Moderation\CmdDelTempRank.cs" />
|
||||
<Compile Include="Commands\Moderation\CmdDemote.cs" />
|
||||
<Compile Include="Commands\Moderation\CmdEndRound.cs" />
|
||||
<Compile Include="Commands\Moderation\CmdExplode.cs" />
|
||||
<Compile Include="Commands\Moderation\CmdFollow.cs" />
|
||||
<Compile Include="Commands\Moderation\CmdFreeze.cs" />
|
||||
@ -273,7 +274,6 @@
|
||||
<Compile Include="Commands\Moderation\CmdPromote.cs" />
|
||||
<Compile Include="Commands\Moderation\CmdPUnload.cs" />
|
||||
<Compile Include="Commands\Moderation\CmdRankInfo.cs" />
|
||||
<Compile Include="Commands\Moderation\CmdReferee.cs" />
|
||||
<Compile Include="Commands\Moderation\CmdRenameLvl.cs" />
|
||||
<Compile Include="Commands\Moderation\CmdResetBot.cs" />
|
||||
<Compile Include="Commands\Moderation\CmdRestart.cs" />
|
||||
|
@ -186,7 +186,7 @@ namespace MCGalaxy {
|
||||
if (Server.lava.startOnStartup)
|
||||
Server.lava.Start();
|
||||
if (Server.startZombieModeOnStartup)
|
||||
Server.zombie.StartGame(1, 0);
|
||||
Server.zombie.Start(ZombieGameStatus.InfiniteRounds, 0);
|
||||
//This doesnt use the main map
|
||||
if (Server.UseCTF)
|
||||
ctf = new Auto_CTF();
|
||||
|
Loading…
x
Reference in New Issue
Block a user