mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-29 16:43:30 -04:00
Cleanup level choosing code, also fix block changes in zombie survival being permanently saved.
This commit is contained in:
parent
0e36b31505
commit
e68cf4edf6
@ -102,6 +102,7 @@ namespace MCGalaxy.Commands
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
Player.SendMessage(p, "/zg status - shows the current status of the Zombie Survival game.");
|
||||
Player.SendMessage(p, "/zg start 0 - Starts a Zombie Survival game for an unlimited amount of rounds.");
|
||||
Player.SendMessage(p, "/zg start [x] - Starts a Zombie Survival game for [x] amount of rounds.");
|
||||
Player.SendMessage(p, "/zg stop - Stops the Zombie Survival game after the round has finished.");
|
||||
|
@ -31,7 +31,7 @@ namespace MCGalaxy {
|
||||
void MainLoop() {
|
||||
if (Status == ZombieGameStatus.NotStarted) return;
|
||||
if (!initialChangeLevel) {
|
||||
ChangeLevel();
|
||||
ChooseNextLevel();
|
||||
initialChangeLevel = true;
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ namespace MCGalaxy {
|
||||
return;
|
||||
} else if (Status == ZombieGameStatus.InfiniteRounds) {
|
||||
DoRound();
|
||||
if (ChangeLevels) ChangeLevel();
|
||||
if (ChangeLevels) ChooseNextLevel();
|
||||
} else if (Status == ZombieGameStatus.SingleRound) {
|
||||
DoRound();
|
||||
ResetState(); return;
|
||||
@ -52,7 +52,7 @@ namespace MCGalaxy {
|
||||
ResetState(); return;
|
||||
} else {
|
||||
DoRound();
|
||||
if (ChangeLevels) ChangeLevel();
|
||||
if (ChangeLevels) ChooseNextLevel();
|
||||
}
|
||||
} else if (Status == ZombieGameStatus.LastRound) {
|
||||
ResetState(); return;
|
||||
@ -286,8 +286,8 @@ namespace MCGalaxy {
|
||||
playersString += p.group.color + p.DisplayName + Colors.white + ", ";
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeLevel()
|
||||
|
||||
void ChooseNextLevel()
|
||||
{
|
||||
if (queLevel)
|
||||
{
|
||||
@ -297,40 +297,19 @@ namespace MCGalaxy {
|
||||
{
|
||||
if (ChangeLevels)
|
||||
{
|
||||
ArrayList al = new ArrayList();
|
||||
DirectoryInfo di = new DirectoryInfo("levels/");
|
||||
FileInfo[] fi = di.GetFiles("*.lvl");
|
||||
foreach (FileInfo fil in fi)
|
||||
{
|
||||
al.Add(fil.Name.Split('.')[0]);
|
||||
}
|
||||
List<string> levels = GetCandidateLevels();
|
||||
if (levels.Count <= 2 && !UseLevelList) { Server.s.Log("You must have more than 2 levels to change levels in Zombie Survival"); return; }
|
||||
|
||||
if (al.Count <= 2 && !UseLevelList) { Server.s.Log("You must have more than 2 levels to change levels in Zombie Survival"); return; }
|
||||
if (levels.Count < 2 && UseLevelList) { Server.s.Log("You must have more than 2 levels in your level list to change levels in Zombie Survival"); return; }
|
||||
|
||||
if (LevelList.Count < 2 && UseLevelList) { Server.s.Log("You must have more than 2 levels in your level list to change levels in Zombie Survival"); return; }
|
||||
|
||||
string selectedLevel1 = "";
|
||||
string selectedLevel2 = "";
|
||||
string selectedLevel1 = "", selectedLevel2 = "";
|
||||
Random r = new Random();
|
||||
|
||||
LevelChoice:
|
||||
Random r = new Random();
|
||||
int x = 0;
|
||||
int x2 = 1;
|
||||
string level = ""; string level2 = "";
|
||||
if (!UseLevelList)
|
||||
{
|
||||
x = r.Next(0, al.Count);
|
||||
x2 = r.Next(0, al.Count);
|
||||
level = al[x].ToString();
|
||||
level2 = al[x2].ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
x = r.Next(0, LevelList.Count());
|
||||
x2 = r.Next(0, LevelList.Count());
|
||||
level = LevelList[x].ToString();
|
||||
level2 = LevelList[x2].ToString();
|
||||
}
|
||||
int x = 0, x2 = 1;
|
||||
string level = "", level2 = "";
|
||||
level = levels[r.Next(0, levels.Count)];
|
||||
level2 = levels[r.Next(0, levels.Count)];
|
||||
Level current = Server.mainLevel;
|
||||
|
||||
if (lastLevelVote1 == level || lastLevelVote2 == level2 || lastLevelVote1 == level2 || lastLevelVote2 == level || current == LevelInfo.Find(level) || currentZombieLevel == level || current == LevelInfo.Find(level2) || currentZombieLevel == level2)
|
||||
@ -358,33 +337,34 @@ namespace MCGalaxy {
|
||||
if (Status == ZombieGameStatus.NotStarted || Status == ZombieGameStatus.LastRound)
|
||||
return;
|
||||
|
||||
if (Level1Vote >= Level2Vote)
|
||||
{
|
||||
if (Level3Vote > Level1Vote && Level3Vote > Level2Vote)
|
||||
{
|
||||
r = new Random();
|
||||
int x3 = r.Next(0, al.Count);
|
||||
ChangeLevel(al[x3].ToString(), Server.ZombieOnlyServer);
|
||||
if (Level1Vote >= Level2Vote) {
|
||||
if (Level3Vote > Level1Vote && Level3Vote > Level2Vote) {
|
||||
ChangeLevel(levels[r.Next(0, levels.Count)], Server.ZombieOnlyServer);
|
||||
}
|
||||
ChangeLevel(selectedLevel1, Server.ZombieOnlyServer);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Level3Vote > Level1Vote && Level3Vote > Level2Vote)
|
||||
{
|
||||
r = new Random();
|
||||
int x4 = r.Next(0, al.Count);
|
||||
ChangeLevel(al[x4].ToString(), Server.ZombieOnlyServer);
|
||||
} else {
|
||||
if (Level3Vote > Level1Vote && Level3Vote > Level2Vote) {
|
||||
ChangeLevel(levels[r.Next(0, levels.Count)], Server.ZombieOnlyServer);
|
||||
}
|
||||
ChangeLevel(selectedLevel2, Server.ZombieOnlyServer);
|
||||
}
|
||||
Player[] online = PlayerInfo.Online.Items;
|
||||
foreach (Player winners in online) {
|
||||
winners.voted = false;
|
||||
}
|
||||
foreach (Player pl in online)
|
||||
pl.voted = false;
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
List<string> GetCandidateLevels() {
|
||||
if (UseLevelList) return LevelList;
|
||||
|
||||
List<string> maps = new List<string>();
|
||||
DirectoryInfo di = new DirectoryInfo("levels/");
|
||||
FileInfo[] fi = di.GetFiles("*.lvl");
|
||||
foreach (FileInfo fil in fi)
|
||||
maps.Add(fil.Name.Split('.')[0]);
|
||||
return maps;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,21 +25,21 @@ using System.Threading;
|
||||
using System.Timers;
|
||||
|
||||
namespace MCGalaxy {
|
||||
|
||||
public class BountyData {
|
||||
public Player Origin;
|
||||
public int Amount;
|
||||
|
||||
public BountyData(Player origin, int amount) {
|
||||
Origin = origin; Amount = amount;
|
||||
}
|
||||
}
|
||||
|
||||
public enum ZombieGameStatus { NotStarted, InfiniteRounds, SingleRound, VariableRounds, LastRound }
|
||||
|
||||
|
||||
public class BountyData {
|
||||
public Player Origin;
|
||||
public int Amount;
|
||||
|
||||
public BountyData(Player origin, int amount) {
|
||||
Origin = origin; Amount = amount;
|
||||
}
|
||||
}
|
||||
|
||||
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>
|
||||
|
||||
/// <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>
|
||||
@ -57,7 +57,7 @@ namespace MCGalaxy {
|
||||
public string currentZombieLevel = "";
|
||||
public static System.Timers.Timer timer;
|
||||
public bool initialChangeLevel = false;
|
||||
public string currentLevelName = "";
|
||||
public string lastLevelName = "", currentLevelName = "";
|
||||
public static List<Player> alive = new List<Player>();
|
||||
public static List<Player> infectd = new List<Player>();
|
||||
static string[] messages = new string[] { "{0} WIKIWOO'D {1}", "{0} stuck their teeth into {1}",
|
||||
@ -158,21 +158,19 @@ namespace MCGalaxy {
|
||||
Player.GlobalMessage("The next map has been chosen - " + Colors.red + next.ToLower());
|
||||
Player.GlobalMessage("Please wait while you are transfered.");
|
||||
string oldLevel = Server.mainLevel.name;
|
||||
if (changeMainLevel) {
|
||||
if (changeMainLevel)
|
||||
Server.mainLevel = LevelInfo.Find(next.ToLower());
|
||||
Player[] online = PlayerInfo.Online.Items;
|
||||
foreach (Player player in online) {
|
||||
if (player.level.name != next && player.level.name == currentLevelName)
|
||||
{
|
||||
player.SendMessage("Going to the next map!");
|
||||
Command.all.Find("goto").Use(player, next);
|
||||
}
|
||||
|
||||
Player[] online = PlayerInfo.Online.Items;
|
||||
foreach (Player pl in online) {
|
||||
if (pl.level.name != next && pl.level.name == lastLevelName) {
|
||||
pl.SendMessage("Going to the next map!");
|
||||
Command.all.Find("goto").Use(pl, next);
|
||||
}
|
||||
Command.all.Find("unload").Use(null, oldLevel);
|
||||
} else {
|
||||
Player.GlobalMessage("Type /goto " + next + " to play the next round of Zombie Survival");
|
||||
}
|
||||
return;
|
||||
if (lastLevelName != "")
|
||||
Command.all.Find("unload").Use(null, lastLevelName);
|
||||
lastLevelName = next;
|
||||
}
|
||||
|
||||
public bool IsInZombieGameLevel(Player p) {
|
||||
|
@ -278,7 +278,8 @@ namespace MCGalaxy
|
||||
public static event OnLevelLoaded LevelLoaded;
|
||||
|
||||
public bool ShouldSaveLevelFile() {
|
||||
if (Server.ZombieModeOn && name == Server.zombie.currentLevelName) return false;
|
||||
if (Server.ZombieModeOn && (name == Server.zombie.currentLevelName
|
||||
|| name == Server.zombie.lastLevelName)) return false;
|
||||
if (Server.lava.active && Server.lava.HasMap(name)) return false;
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user