/// <summary> Moves all players to the level which has the highest number of votes. </summary> static void MoveToNextLevel(Random r, List <string> levels, ZombieGame game) { int v1 = game.Votes1, v2 = game.Votes2, v3 = game.Votes3; if (v1 >= v2) { if (v3 > v1 && v3 > v2) { game.ChangeLevel(game.Candidate3); } else { game.ChangeLevel(game.Candidate1); } } else { if (v3 > v1 && v3 > v2) { game.ChangeLevel(game.Candidate3); } else { game.ChangeLevel(game.Candidate2); } } Player[] online = PlayerInfo.Online.Items; foreach (Player pl in online) { pl.voted = false; } }
internal static void ChooseNextLevel(ZombieGame game) { if (game.QueuedLevel != null) { game.ChangeLevel(game.QueuedLevel); return; } if (!ZombieGameProps.ChangeLevels) { return; } try { List <string> maps = GetCandidateLevels(); if (maps == null) { return; } RemoveRecentLevels(maps, game); game.Votes1 = 0; game.Votes2 = 0; game.Votes3 = 0; Random r = new Random(); game.Candidate1 = GetRandomLevel(r, maps); game.Candidate2 = GetRandomLevel(r, maps); game.Candidate3 = GetRandomLevel(r, maps); if (!game.Running || game.Status == ZombieGameStatus.LastRound) { return; } DoLevelVote(game); if (!game.Running || game.Status == ZombieGameStatus.LastRound) { return; } MoveToNextLevel(r, maps, game); } catch (Exception ex) { Server.ErrorLog(ex); } }