LevelPlaylist CreateLevelPlaylistObject() { LevelPlaylist levels = new LevelPlaylist(); levels.freeForAllScenes = new List <string>(); levels.eliminationScenes = new List <string>(); levels.extractionScenes = new List <string>(); levels.climbScenes = new List <string>(); List <EditorBuildSettingsScene> editorBuildSettingsScenes = new List <EditorBuildSettingsScene>(); foreach (var scene in EditorBuildSettings.scenes) { editorBuildSettingsScenes.Add(new EditorBuildSettingsScene(scene.path, true)); } List <string> scenePaths = new List <string>(); for (int i = 0; i < freeForAllScenes.Count; i++) { levels.freeForAllScenes.Add(freeForAllScenes[i].name); scenePaths.Add(AssetDatabase.GetAssetPath(freeForAllScenes[i])); } for (int i = 0; i < eliminationScenes.Count; i++) { levels.eliminationScenes.Add(eliminationScenes[i].name); scenePaths.Add(AssetDatabase.GetAssetPath(freeForAllScenes[i])); } for (int i = 0; i < extractionScenes.Count; i++) { levels.extractionScenes.Add(extractionScenes[i].name); scenePaths.Add(AssetDatabase.GetAssetPath(freeForAllScenes[i])); } for (int i = 0; i < climbScenes.Count; i++) { levels.climbScenes.Add(climbScenes[i].name); scenePaths.Add(AssetDatabase.GetAssetPath(freeForAllScenes[i])); } foreach (var path in scenePaths) { bool inBuildSettings = false; foreach (var scene in editorBuildSettingsScenes) { if (scene.path == path) { inBuildSettings = true; } } if (inBuildSettings == false) { editorBuildSettingsScenes.Add(new EditorBuildSettingsScene(path, true)); } } // Set the Build Settings window Scene list EditorBuildSettings.scenes = editorBuildSettingsScenes.ToArray(); return(levels); }
// Use this for initialization void Start() { var mus = GameObject.FindGameObjectWithTag("MusicSys"); if (mus) { music_sys = mus.GetComponent <MusicSys>(); } level_stats = GameObject.FindGameObjectWithTag("LevelPlaylist").GetComponent <LevelPlaylist>(); gameoverPanel.gameObject.SetActive(false); score_list = new List <PlayerScoreData>(); State = GameState.Setup; var entDB = GameObject.FindGameObjectWithTag("EntityDatabase"); stats = entDB.GetComponent <GameplayDatabase>().Stats[0]; scores = new List <int>(); scores.Add(stats.Score_first); scores.Add(stats.Score_second); scores.Add(stats.Score_third); scores.Add(stats.Score_fourth); if (music_sys) { music_sys.StopCurrent(); } }
public static void Postfix(LevelGridMenu __instance) { if (__instance.DisplayType_ == LevelSelectMenuAbstract.DisplayType.GameLobby) { return; } LockingSystem.CreateProfile(); if (__instance.isCampaignMode_) { foreach (var campaign in Campaigns.Items) { if (campaign.Value.Enabled) { __instance.CreateAndAddCampaignLevelSet(campaign.Value.GetLevelSet(campaign.Value.GameMode, false), campaign.Value.Name, true, unlock_mode, campaign.Value.GameMode); } } } else if (__instance.modeID_ == GameModeID.Sprint) { foreach (var campaign in Campaigns.Items) { if (campaign.Value.Enabled && campaign.Value.ShowInArcade) { LevelSet set = campaign.Value.GetLevelSet(GameModeID.Sprint, true); LevelPlaylist playlist = LevelPlaylist.Create(set, $"{Constants.Strings.CampaignEntry_Color}{campaign.Value.Name}[-]"); bool unlocked = LockingSystem.IsCampaignComplete(campaign.Value.Id); __instance.CreateAndAddEntry(playlist, LevelGridMenu.PlaylistEntry.Type.Campaign, unlocked, sprint_unlock_mode); } } } __instance.buttonList_.SortAndUpdateVisibleButtons(); }
public override void use(ClientPlayerInfo p, string message) { if (message == "") { MessageUtilities.pushMessageOption(new MessageStateOptionPlayer(p)); printPlaylists(); MessageUtilities.popMessageOptions(); return; } var name = Resource.PersonalLevelPlaylistsDirPath_ + message + ".xml"; if (!Resource.FileExist(name)) { MessageUtilities.sendMessage(p, "The playlist " + message + " don't exist !"); return; } var item = G.Sys.GameManager_.LevelPlaylist_.Count_ == 0 ? null : G.Sys.GameManager_.LevelPlaylist_.Playlist_[G.Sys.GameManager_.LevelPlaylist_.Index_]; var gameObject = LevelPlaylist.Load(name); var playlistComp = gameObject.GetComponent <LevelPlaylist>(); G.Sys.GameManager_.LevelPlaylist_.CopyFrom(playlistComp); MessageUtilities.sendMessage(p, "Playlist Loaded : " + G.Sys.GameManager_.LevelPlaylist_.Count_ + " levels."); if (GeneralUtilities.isOnGamemode() && item != null) { G.Sys.GameManager_.LevelPlaylist_.Playlist_.Insert(0, item); } }
public override void use(ClientPlayerInfo p, string message) { LevelPlaylist playlist = new LevelPlaylist(); playlist.CopyFrom(G.Sys.GameManager_.LevelPlaylist_); if (G.Sys.GameManager_.ModeID_ == GameModeID.Trackmogrify) { MessageUtilities.sendMessage(p, "You can't manage the playlist in trackmogrify"); return; } if (playlist.Count_ == 0) { MessageUtilities.sendMessage(p, "The playlist is empty !"); return; } var item = playlist.Playlist_[G.Sys.GameManager_.LevelPlaylist_.Index_]; playlist.Playlist_.Clear(); G.Sys.GameManager_.LevelPlaylist_.Clear(); G.Sys.GameManager_.LevelPlaylist_.Add(item); G.Sys.GameManager_.NextLevelName_ = item.levelNameAndPath_.levelName_; G.Sys.GameManager_.NextLevelPath_ = item.levelNameAndPath_.levelPath_; G.Sys.GameManager_.LevelPlaylist_.SetIndex(0); MessageUtilities.sendMessage(p, "Playlist cleared !"); }
public override void use(ClientPlayerInfo p, string message) { LevelPlaylist currentList = G.Sys.GameManager_.LevelPlaylist_; if (currentList.Index_ >= currentList.Count_) { MessageUtilities.sendMessage(p, "There are no levels in the playlist!"); return; } else if (currentList.Index_ == currentList.Count_ - 1) { MessageUtilities.sendMessage(p, "You are on the last level of the playlist!"); return; } LevelCmd levelCmd = Cmd.all.getCommand <LevelCmd>("level"); var levelsUpcoming = currentList.Playlist_.GetRange(currentList.Index_ + 1, currentList.Count_ - currentList.Index_ - 1); FilteredPlaylist filterer = new FilteredPlaylist(levelsUpcoming); GeneralUtilities.addFiltersToPlaylist(filterer, p, message, false); MessageUtilities.sendMessage(p, "[FFFFFF]Upcoming:[-]"); MessageUtilities.sendMessage(p, GeneralUtilities.getPlaylistText(filterer, GeneralUtilities.IndexMode.Initial, levelCmd.levelFormat)); }
public override void use(ClientPlayerInfo p, string message) { LevelPlaylist playlist = new LevelPlaylist(); playlist.Copy(G.Sys.GameManager_.LevelPlaylist_); if (G.Sys.GameManager_.ModeID_ == GameModeID.Trackmogrify) { Utilities.sendMessage("You can't manage the playlist in trackmogrify"); return; } if (playlist.Count_ == 0) { Utilities.sendMessage("The playlist is empty !"); return; } if (Utilities.isOnGamemode()) { shuffleOnGame(playlist); } else { shuffleOnLobby(playlist); } G.Sys.GameManager_.LevelPlaylist_.SetIndex(0); G.Sys.GameManager_.NextLevelName_ = G.Sys.GameManager_.LevelPlaylist_.Playlist_[0].levelNameAndPath_.levelName_; G.Sys.GameManager_.NextLevelPath_ = G.Sys.GameManager_.LevelPlaylist_.Playlist_[0].levelNameAndPath_.levelPath_; Utilities.sendMessage("Playlist shuffled !"); }
void shuffleOnLobby(LevelPlaylist playlist) { var shuffledList = playlist.Playlist_; Utilities.Shuffle(playlist.Playlist_, new Random()); G.Sys.GameManager_.LevelPlaylist_.Clear(); foreach (var lvl in shuffledList) { G.Sys.GameManager_.LevelPlaylist_.Add(lvl); } }
static void CompareAndLoadScenesFromBuildSettings(LevelPlaylist levelPlaylist) { foreach (var scene in EditorBuildSettings.scenes) { string sceneName = Path.GetFileNameWithoutExtension(scene.path); foreach (string name in levelPlaylist.freeForAllScenes) { if (sceneName == name) { SceneAsset s = AssetDatabase.LoadAssetAtPath <SceneAsset>(scene.path); if (!freeForAllScenes.Contains(s)) { freeForAllScenes.Add(s); } } } foreach (string name in levelPlaylist.eliminationScenes) { if (sceneName == name) { SceneAsset s = AssetDatabase.LoadAssetAtPath <SceneAsset>(scene.path); if (!eliminationScenes.Contains(s)) { eliminationScenes.Add(s); } } } foreach (string name in levelPlaylist.extractionScenes) { if (sceneName == name) { SceneAsset s = AssetDatabase.LoadAssetAtPath <SceneAsset>(scene.path); if (!extractionScenes.Contains(s)) { extractionScenes.Add(s); } } } foreach (string name in levelPlaylist.climbScenes) { if (sceneName == name) { SceneAsset s = AssetDatabase.LoadAssetAtPath <SceneAsset>(scene.path); if (!climbScenes.Contains(s)) { climbScenes.Add(s); } } } } }
public override void use(ClientPlayerInfo p, string message) { if (message == "") { help(p); return; } if (G.Sys.GameManager_.ModeID_ == GameModeID.Trackmogrify) { MessageUtilities.sendMessage(p, "You can't manage the playlist in trackmogrify"); return; } int id = 0; int.TryParse(message, out id); if (id < 0) { MessageUtilities.sendMessage(p, "The id must be >= 0"); return; } int index = G.Sys.GameManager_.LevelPlaylist_.Index_; int playListSize = G.Sys.GameManager_.LevelPlaylist_.Playlist_.Count - index - 1; if (id >= playListSize) { MessageUtilities.sendMessage(p, "The playlist has only " + playListSize + " maps."); return; } LevelPlaylist playlist = new LevelPlaylist(); playlist.CopyFrom(G.Sys.GameManager_.LevelPlaylist_); var currentPlaylist = playlist.Playlist_; currentPlaylist.RemoveAt(index + id + 1); G.Sys.GameManager_.LevelPlaylist_.Clear(); foreach (var lvl in currentPlaylist) { G.Sys.GameManager_.LevelPlaylist_.Add(lvl); } G.Sys.GameManager_.LevelPlaylist_.SetIndex(index); MessageUtilities.sendMessage(p, "Map removed !"); }
public static bool IsResourcesPlaylist(this LevelPlaylist playlist) { LevelPlaylistCompoundData data = playlist.gameObject.GetComponent <LevelPlaylistCompoundData>(); if (!data) { return(true); } string path = new FileInfo(data.FilePath).FullName.UniformPathName(); string resourcesPath = new DirectoryInfo(Path.Combine(Application.dataPath, "Resources")).FullName.UniformPathName(); return(path.StartsWith(resourcesPath, StringComparison.InvariantCultureIgnoreCase)); }
public override LevelFilterResult FromChatString(string chatString, string option) { PlaylistCmd playlistCmd = Cmd.all.getCommand <PlaylistCmd>("playlist"); int count; LevelPlaylist list = playlistCmd.getPlaylistLevels(chatString, out count, playlistCmd.getActivePlaylist(LevelFilterLast.activePlayerString)); if (count == 0) { return(new LevelFilterResult($"Could not find any matching playlist for `{chatString}`")); } else // TODO: allow messages and results at the same time, for case count > 1 { return(new LevelFilterResult(new LevelFilterPlaylist(list.Playlist_))); } }
internal static void Postfix(LevelGridGrid __instance) { if (!Mod.Instance.Config.EnableDeletePlaylistButton) { return; } LevelPlaylist playlist = __instance.playlist_; LevelPlaylistCompoundData data = playlist.GetComponent <LevelPlaylistCompoundData>(); if (data && !playlist.IsResourcesPlaylist()) { G.Sys.MenuPanelManager_.SetBottomLeftActionButton(InternalResources.Constants.INPUT_DELETE_PLAYLIST, "DELETE PLAYLIST"); } }
void shuffleOnGame(LevelPlaylist playlist) { int index = G.Sys.GameManager_.LevelPlaylist_.Index_; var item = playlist.Playlist_[index]; playlist.Playlist_.RemoveAt(index); var shuffledList = playlist.Playlist_; Utilities.Shuffle(playlist.Playlist_, new Random()); G.Sys.GameManager_.LevelPlaylist_.Clear(); G.Sys.GameManager_.LevelPlaylist_.Add(item); foreach (var lvl in shuffledList) { G.Sys.GameManager_.LevelPlaylist_.Add(lvl); } }
public static bool Prefix(LevelGridMenu __instance, ref int index) { LevelPlaylist playlist = __instance.DisplayedEntry_.Playlist_; string level = playlist.Playlist_[index].levelNameAndPath_.levelPath_; if (Utils.Campaign.GetCampaignUnlockMode(level) == Models.Campaign.UnlockStyle.LevelSet) { return(true); } else { bool flag = Utils.Campaign.IsCustomCampaignLevel(level) && LockingSystem.IsLevelLocked(level); if (flag) { G.Sys.MenuPanelManager_.ShowTimedOk(10, Constants.Strings.LevelLocked_Message, Constants.Strings.LevelLocked_Title); } return(!flag); } }
public static void Postfix(LevelGridMenu __instance) { bool flag_campaignmode = __instance.isCampaignMode_; if (flag_campaignmode && __instance.isActiveAndEnabled) { try { LevelPlaylist playlist = __instance.DisplayedEntry_.Playlist_; string level = playlist.GetLevelSet()[0].levelPath_.NormPath(true); if (Utils.Campaign.IsCustomCampaignLevel(level)) { __instance.modeDescription_.text = __instance.gridDescription_.text = Utils.Campaign.GetCampaignDescription(level); __instance.campaignLogo_.mainTexture = Utils.Campaign.GetCampaignLogo(level); } } catch (NullReferenceException nre) { Plugin.Log.Exception(nre); } } }
void SaveToJSON(bool isDebug) { SetGuids(); LevelPlaylist levels = CreateLevelPlaylistObject(); SaveObject saveObject = new SaveObject() { savedWeapons = weaponTypes, playerParams = player, levelPlaylist = levels }; string json = JsonUtility.ToJson(saveObject); Debug.Log(json); string file = Application.dataPath + "/Resources/DesignMaster.txt"; if (isDebug) { file = Application.dataPath + "/Resources/DebugDesignMaster.txt"; } File.WriteAllText(file, json); }
public override void use(ClientPlayerInfo p, string message) { LevelPlaylist playlist = new LevelPlaylist(); playlist.Copy(G.Sys.GameManager_.LevelPlaylist_); if (G.Sys.GameManager_.ModeID_ == GameModeID.Trackmogrify) { Utilities.sendMessage("You can't manage the playlist in trackmogrify"); return; } if (playlist.Count_ == 0) { Utilities.sendMessage("The playlist is empty !"); return; } int index = G.Sys.GameManager_.LevelPlaylist_.Index_; var item = playlist.Playlist_[index]; playlist.Playlist_.RemoveAt(index); var shuffledList = playlist.Playlist_; Utilities.Shuffle(playlist.Playlist_, new Random()); G.Sys.GameManager_.LevelPlaylist_.Clear(); G.Sys.GameManager_.LevelPlaylist_.Add(item); foreach (var lvl in shuffledList) { G.Sys.GameManager_.LevelPlaylist_.Add(lvl); } G.Sys.GameManager_.NextLevelName_ = item.levelNameAndPath_.levelName_; G.Sys.GameManager_.NextLevelPath_ = item.levelNameAndPath_.levelPath_; G.Sys.GameManager_.LevelPlaylist_.SetIndex(0); Utilities.sendMessage("Playlist shuffled !"); }
internal static void Postfix(LevelGridGrid __instance) { if (!Mod.Instance.Config.EnableDeletePlaylistButton) { return; } LevelPlaylist playlist = __instance.playlist_; LevelPlaylistCompoundData data = playlist.GetComponent <LevelPlaylistCompoundData>(); if (data && !playlist.IsResourcesPlaylist() && G.Sys.InputManager_.GetKeyUp(InternalResources.Constants.INPUT_DELETE_PLAYLIST)) { MessageBox.Create($"Are you sure you want to remove [u]{playlist.Name_}[/u]?", "DELETE PLAYLIST") .SetButtons(MessageButtons.YesNo) .OnConfirm(() => { try { FileEx.Delete(data.FilePath); playlist.Destroy(); Object.DestroyImmediate(data.gameObject); } catch (System.Exception e) { Mod.Instance.Logger.Exception(e); } finally { G.Sys.MenuPanelManager_.Pop(); __instance.levelGridMenu_.CreateEntries(); } }) .Show(); } }
public override void use(ClientPlayerInfo p, string message) { if (!doForceNextUse) { if (!votesAllowed) { MessageUtilities.sendMessage(p, "Votes are disabled."); return; } } else { doForceNextUse = false; } bool voteValue; bool isInfo; string voteType; string parameter; var matchShortcut = Regex.Match(message, parent.voteCmdShortcutPattern); var shortcutVoteType = matchShortcut.Groups[1].Value.ToLower(); if (matchShortcut.Success && voteThresholds.ContainsKey(shortcutVoteType)) { voteValue = true; isInfo = false; voteType = shortcutVoteType; parameter = matchShortcut.Groups[2].Value; } else { var match = Regex.Match(message, parent.voteCmdPattern); if (!match.Success) { help(p); return; } string voteValueS = match.Groups[1].Value.ToLower(); voteValue = false; isInfo = false; if (voteValueS == "yes" || voteValueS == "y" || voteValueS == "1" || voteValueS == "true" || voteValueS == "t") { voteValue = true; } else if (voteValueS == "no" || voteValueS == "n" || voteValueS == "0" || voteValueS == "false" || voteValueS == "f") { voteValue = false; } else if (voteValueS == "info" || voteValueS == "i") { isInfo = true; } else { MessageUtilities.sendMessage(p, "Invalid <voteType>, or invalid [yes/no] You can use yes/no, y/n, 1/0, true/false, and t/f."); MessageUtilities.sendMessage(p, "You can use [info/i] to get info."); MessageUtilities.sendMessage(p, "<voteType>s: skip, stop, play"); return; } voteType = match.Groups[2].Value.ToLower(); parameter = match.Groups[3].Value; } if (!voteThresholds.ContainsKey(voteType)) { MessageUtilities.sendMessage(p, $"Invalid <voteType>. ({voteType})"); help(p); return; } AutoCmd autoCommand = parent.list.getCommand <AutoCmd>("auto"); AutoSpecCmd autoSpecCommand = parent.list.getCommand <AutoSpecCmd>("autospec"); int playerOffset = (autoCommand.autoMode && autoSpecCommand.autoSpecMode) ? -1 : 0; int numPlayers = G.Sys.PlayerManager_.PlayerList_.Count + playerOffset; if (isInfo) { MessageUtilities.sendMessage(p, $"Info for {voteType}:"); MessageUtilities.sendMessage(p, $"Pass threshold: {Convert.ToInt32(Math.Floor(voteThresholds[voteType]*100))}%"); int value = parent.votes[voteType].Count; MessageUtilities.sendMessage(p, $"Votes: {value}/{Convert.ToInt32(Math.Ceiling(voteThresholds[voteType] * Convert.ToDouble(numPlayers)))}"); return; } if (voteType == "skip") { if (GeneralUtilities.isOnLobby()) { MessageUtilities.sendMessage(p, "You can't vote to skip in the lobby!"); return; } if (votedSkip) { MessageUtilities.sendMessage(p, "Vote skip already succeeded."); return; } List <string> votes = parent.votes[voteType]; int value = votes.Count; string playerVoteId = GeneralUtilities.getUniquePlayerString(p); if (voteValue) { if (votes.Contains(playerVoteId)) { MessageUtilities.sendMessage($"{p.Username_} has already voted to skip {G.Sys.GameManager_.LevelName_}."); return; } votes.Add(playerVoteId); value = votes.Count; MessageUtilities.sendMessage($"{p.Username_} voted to skip {G.Sys.GameManager_.LevelName_}."); if (Convert.ToDouble(value) / Convert.ToDouble(numPlayers) < voteThresholds[voteType]) { MessageUtilities.sendMessage($"Votes: {value}/{Convert.ToInt32(Math.Ceiling(voteThresholds[voteType] * Convert.ToDouble(numPlayers)))}"); } else { votedSkip = true; MessageUtilities.sendMessage("Vote skip succeeded! Skipping map..."); parent.advanceLevel(); } } else { votes.Remove(playerVoteId); value = votes.Count; MessageUtilities.sendMessage($"{p.Username_} unvoted to skip {G.Sys.GameManager_.LevelName_}."); MessageUtilities.sendMessage($"Votes: {value}/{Convert.ToInt32(Math.Ceiling(voteThresholds[voteType] * Convert.ToDouble(numPlayers)))}"); return; } } else if (voteType == "stop") { if (GeneralUtilities.isOnLobby()) { MessageUtilities.sendMessage(p, "You can't vote to stop the countdown in the lobby!"); return; } List <string> votes = parent.votes[voteType]; int value = votes.Count; string playerVoteId = GeneralUtilities.getUniquePlayerString(p); if (voteValue) { if (votes.Contains(playerVoteId)) { MessageUtilities.sendMessage($"{p.Username_} has already voted to stop the countdown."); return; } votes.Add(playerVoteId); value = votes.Count; MessageUtilities.sendMessage($"{p.Username_} voted to stop the countdown."); if (Convert.ToDouble(value) / Convert.ToDouble(numPlayers) < voteThresholds[voteType]) { MessageUtilities.sendMessage($"Votes: {value}/{Convert.ToInt32(Math.Ceiling(voteThresholds[voteType] * Convert.ToDouble(numPlayers)))}"); } else { parent.votes[voteType].Clear(); CountdownCmd command = parent.list.getCommand <CountdownCmd>("countdown"); command.stopCountdown(); MessageUtilities.sendMessage("Vote stop succeeded! Stopping countdown..."); } } else { votes.Remove(playerVoteId); value = votes.Count; MessageUtilities.sendMessage($"{p.Username_} unvoted to stop the countdown."); MessageUtilities.sendMessage($"Votes: {value}/{Convert.ToInt32(Math.Ceiling(voteThresholds[voteType] * Convert.ToDouble(numPlayers)))}"); return; } } else if (voteType == "play") { if (GeneralUtilities.isOnLobby()) { MessageUtilities.sendMessage(p, "You can't vote for the next level in the lobby."); return; } if (G.Sys.GameManager_.ModeID_ == GameModeID.Trackmogrify) { MessageUtilities.sendMessage(p, "You can't vote for levels in trackmogrify."); return; } string levelName = parameter; FilteredPlaylist filterer = new FilteredPlaylist(GeneralUtilities.getAllLevelsAndModes()); if (!p.IsLocal_) { PlayCmd playCmd = Cmd.all.getCommand <PlayCmd>("play"); filterer.AddFiltersFromString(playCmd.playFilter); } MessageUtilities.pushMessageOption(new MessageStateOptionPlayer(p)); GeneralUtilities.sendFailures(GeneralUtilities.addFiltersToPlaylist(filterer, p, levelName, true), 4); MessageUtilities.popMessageOptions(); List <LevelPlaylist.ModeAndLevelInfo> lvls = filterer.Calculate().levelList; List <LevelResultsSortInfo> levelResults = new List <LevelResultsSortInfo>(); double threshold = voteThresholds["play"]; LevelPlaylist playlist = new LevelPlaylist(); playlist.CopyFrom(G.Sys.GameManager_.LevelPlaylist_); var currentPlaylist = playlist.Playlist_; AutoCmd autoCmd = Cmd.all.getCommand <AutoCmd>("auto"); int origIndex = G.Sys.GameManager_.LevelPlaylist_.Index_; int index = autoCmd.getInsertIndex(); int addCount = 0; foreach (LevelPlaylist.ModeAndLevelInfo lvl in lvls) { string id = $"{lvl.mode_}:{lvl.levelNameAndPath_.levelName_}:{lvl.levelNameAndPath_.levelPath_}"; List <string> votes; if (!parent.votes.TryGetValue(id, out votes)) { if (voteValue) { votes = new List <string>(); parent.votes[id] = votes; } else { //MessageUtilities.sendMessage($"{p.Username_} unvoted for these maps."); levelResults.Add(new LevelResultsSortInfo(lvl, 0, numPlayers, threshold, -1)); continue; } } string playerVoteId = GeneralUtilities.getUniquePlayerString(p); if (!voteValue) { votes.Remove(playerVoteId); if (votes.Count == 0) { parent.votes.Remove(id); } //MessageUtilities.sendMessage($"{p.Username_} unvoted for these maps."); levelResults.Add(new LevelResultsSortInfo(lvl, votes.Count, numPlayers, threshold, -1)); continue; } else { if (votes.Contains(playerVoteId)) { //MessageUtilities.sendMessage($"{p.Username_} has already voted for these maps."); levelResults.Add(new LevelResultsSortInfo(lvl, votes.Count, numPlayers, threshold, 0)); //return; continue; } else { votes.Add(playerVoteId); levelResults.Add(new LevelResultsSortInfo(lvl, votes.Count, numPlayers, threshold, 1)); if (Convert.ToDouble(votes.Count) / Convert.ToDouble(numPlayers) >= threshold) { currentPlaylist.Insert(index + addCount, lvl); parent.votes.Remove(id); addCount++; } } } } G.Sys.GameManager_.LevelPlaylist_.Clear(); foreach (var lvl in currentPlaylist) { G.Sys.GameManager_.LevelPlaylist_.Add(lvl); } G.Sys.GameManager_.LevelPlaylist_.SetIndex(origIndex); var playersThreshold = Convert.ToInt32(Math.Ceiling(voteThresholds[voteType] * Convert.ToDouble(numPlayers))); if (lvls.Count == 0) { MessageUtilities.sendMessage(p, "Can't find any levels with the filter '" + levelName + "'."); } string newMessage; int count; newMessage = ""; count = 0; foreach (LevelResultsSortInfo level in levelResults) { if (level.voteState == -1) { if (++count <= 10) { newMessage = newMessage + level.level.levelNameAndPath_.levelName_ + $"({level.votes}/{playersThreshold}), "; } } } if (count != 0) { if (count > 10) { MessageUtilities.sendMessage($"{p.Username_} unvoted for {newMessage} and {count - 10} more."); } else { MessageUtilities.sendMessage($"{p.Username_} unvoted for {newMessage}."); } } newMessage = ""; count = 0; foreach (LevelResultsSortInfo level in levelResults) { if (level.voteState >= 0) { if (++count <= 10) { newMessage = newMessage + level.level.levelNameAndPath_.levelName_ + $"({level.votes}/{playersThreshold}), "; } } } if (count != 0) { if (count > 10) { MessageUtilities.sendMessage($"{p.Username_} voted for {newMessage} and {count - 10} more."); } else { MessageUtilities.sendMessage($"{p.Username_} voted for {newMessage}."); } } newMessage = ""; count = 0; foreach (LevelResultsSortInfo level in levelResults) { if (level.success) { if (++count <= 10) { newMessage = newMessage + level.level.levelNameAndPath_.levelName_ + ", "; } } } if (count != 0) { if (count > 10) { MessageUtilities.sendMessage(newMessage + $"and {count - 10} more added."); } else { MessageUtilities.sendMessage(newMessage + "added."); } } } }
public override void use(ClientPlayerInfo p, string message) { if (message == "") { help(p); return; } if (Utilities.isOnLobby()) { Utilities.sendMessage("You can't set the next level here"); return; } if (G.Sys.GameManager_.ModeID_ == GameModeID.Trackmogrify) { Utilities.sendMessage("You can't manage the playlist in trackmogrify"); return; } Modifiers m = LevelList.extractModifiers(message); var list = LevelList.levels(m); if (list.Count == 0) { Utilities.sendMessage("Can't find a level with the filter '" + message + "'."); return; } if (!m.all && list.Count() > 1 && m.index.Count == 0) { LevelList.printLevels(list, m.page, 10, true); //LevelList.printLevels(list, 10, true); return; } if (playersCanAddMap && !p.IsLocal_) { var value = list[0]; list.Clear(); list.Add(value); } LevelPlaylist playlist = new LevelPlaylist(); playlist.Copy(G.Sys.GameManager_.LevelPlaylist_); var currentPlaylist = playlist.Playlist_; int index = G.Sys.GameManager_.LevelPlaylist_.Index_; Utilities.Shuffle(list, new Random()); foreach (var lvl in list) { currentPlaylist.Insert(index + 1, lvl); } G.Sys.GameManager_.LevelPlaylist_.Clear(); foreach (var lvl in currentPlaylist) { G.Sys.GameManager_.LevelPlaylist_.Add(lvl); } G.Sys.GameManager_.LevelPlaylist_.SetIndex(index); string lvlsStr = ""; foreach (var lvl in list) { lvlsStr += lvl.levelNameAndPath_.levelName_ + ", "; } Utilities.sendMessage("Level(s) " + lvlsStr.Substring(0, lvlsStr.Count() - 2) + " added to the playlist !"); }
public LevelPlaylist getPlaylistLevels(string search, LevelPlaylist activePlaylist) { int ignored; return(getPlaylistLevels(search, out ignored, activePlaylist)); }
public LevelPlaylist getPlaylistLevels(string search, out int count, LevelPlaylist activePlaylist) { var searchRegex = GeneralUtilities.getSearchRegex(search); List <string> playlists = GeneralUtilities.playlists(); playlists.RemoveAll((string s) => !Resource.FileExist(s)); playlists.RemoveAll(playlist => !Regex.IsMatch(Resource.GetFileNameWithoutExtension(playlist), searchRegex, RegexOptions.IgnoreCase)); if (canUseCurrentPlaylist) { List <string> miniList = new List <string>(); miniList.Add("current"); miniList.Add("upcoming"); miniList.Add("active"); miniList.RemoveAll(playlist => !Regex.IsMatch(playlist, searchRegex, RegexOptions.IgnoreCase)); playlists.AddRange(miniList); } count = playlists.Count; if (playlists.Count == 0) { return(null); } var selectedPlaylist = playlists[0]; LevelPlaylist playlistComp; switch (selectedPlaylist) { case "current": { playlistComp = LevelPlaylist.Create(true); playlistComp.CopyFrom(G.Sys.GameManager_.LevelPlaylist_); playlistComp.Name_ = "current"; break; } case "upcoming": { playlistComp = LevelPlaylist.Create(true); var currentList = G.Sys.GameManager_.LevelPlaylist_; for (int i = currentList.Index_ + 1; i < currentList.Count_; i++) { playlistComp.Playlist_.Add(currentList.Playlist_[i]); } playlistComp.Name_ = "upcoming"; break; } case "active": { if (activePlaylist == null) { return(null); } playlistComp = LevelPlaylist.Create(true); playlistComp.CopyFrom(activePlaylist); playlistComp.Name_ = activePlaylist.Name_; break; } default: { var gameObject = LevelPlaylist.Load(selectedPlaylist); playlistComp = gameObject.GetComponent <LevelPlaylist>(); break; } } return(playlistComp); }
public bool savePlaylist(LevelPlaylist selectedPlaylist, string name) { // playlists are attached to game objects // when a new level loads, all existing game objects are destroyed so we cannot properly save them // instead, we make a new one and copy the old playlist into the new object. LevelPlaylist list = LevelPlaylist.Create(true); list.CopyFrom(selectedPlaylist); list.IsCustom_ = true; selectedPlaylist = list; switch (name) { case "current": { if (canUseCurrentPlaylist) { G.Sys.GameManager_.LevelPlaylist_.CopyFrom(selectedPlaylist); G.Sys.GameManager_.LevelPlaylist_.SetIndex(0); GeneralUtilities.updateGameManagerCurrentLevel(); StaticTargetedEvent <Events.ServerToClient.SetLevelName.Data> .Broadcast(RPCMode.All, G.Sys.GameManager_.CreateSetLevelNameEventData()); return(true); } else { return(false); } } case "upcoming": { if (canUseCurrentPlaylist) { var currentPlaylist = G.Sys.GameManager_.LevelPlaylist_; if (currentPlaylist.Count_ > currentPlaylist.Index_ + 1) { currentPlaylist.Playlist_.RemoveRange(currentPlaylist.Index_ + 1, currentPlaylist.Count_ - currentPlaylist.Index_ - 1); } foreach (LevelPlaylist.ModeAndLevelInfo level in selectedPlaylist.Playlist_) { currentPlaylist.Add(level); } currentPlaylist.IsCustom_ = true; GeneralUtilities.updateGameManagerCurrentLevel(); StaticTargetedEvent <Events.ServerToClient.SetLevelName.Data> .Broadcast(RPCMode.All, G.Sys.GameManager_.CreateSetLevelNameEventData()); return(true); } else { return(false); } } case "active": { return(true); } default: { selectedPlaylist.Name_ = name; selectedPlaylist.Save(); return(true); } } }
public override void use(ClientPlayerInfo p, string message) { if (message == "") { help(p); return; } if (useVote && !p.IsLocal_) // host can always force play, never uses vote. { Cmd.all.getCommand <VoteHandler.VoteCMD>("vote").forceNextUse(); Cmd.all.getCommand <VoteHandler.VoteCMD>("vote").use(p, "y play " + message); return; } if (G.Sys.GameManager_.ModeID_ == GameModeID.Trackmogrify) { MessageUtilities.sendMessage(p, "You can't manage the playlist in trackmogrify."); return; } FilteredPlaylist filterer = new FilteredPlaylist(GeneralUtilities.getAllLevelsAndModes()); if (!p.IsLocal_) { filterer.AddFiltersFromString(playFilter); } MessageUtilities.pushMessageOption(new MessageStateOptionPlayer(p)); GeneralUtilities.sendFailures(GeneralUtilities.addFiltersToPlaylist(filterer, p, message, true), 4); MessageUtilities.popMessageOptions(); var list = filterer.Calculate().levelList; if (list.Count == 0) { MessageUtilities.sendMessage(p, "Can't find a level with the filter '" + message + "'."); return; } LevelPlaylist playlist = new LevelPlaylist(); playlist.CopyFrom(G.Sys.GameManager_.LevelPlaylist_); var currentPlaylist = playlist.Playlist_; AutoCmd autoCmd = Cmd.all.getCommand <AutoCmd>("auto"); int origIndex = G.Sys.GameManager_.LevelPlaylist_.Index_; int index = autoCmd.getInsertIndex(); var maxPerRoundLocal = 0; if (p.IsLocal_ || maxPerRound <= 0) { maxPerRoundLocal = int.MaxValue; } else { maxPerRoundLocal = maxPerRound; } var maxPerCmdLocal = 0; if (p.IsLocal_ || maxPerCmd <= 0) { maxPerCmdLocal = int.MaxValue; } else { maxPerCmdLocal = maxPerCmd; } var countCmd = 0; var countRound = 0; playerVotesThisRound.TryGetValue(GeneralUtilities.getUniquePlayerString(p), out countRound); string lvlsStr = ""; foreach (var lvl in list) { if (countRound + 1 > maxPerRoundLocal) { MessageUtilities.sendMessage(p, $"You have reached the maximum amount of maps you can add per round ({maxPerRound})"); break; } if (countCmd + 1 > maxPerCmdLocal) { MessageUtilities.sendMessage(p, "You have reached the maximum amount of maps you can add per " + GeneralUtilities.formatCmd("!play") + $" ({maxPerCmd})"); break; } countRound++; countCmd++; if (countCmd <= 10) { lvlsStr += lvl.levelNameAndPath_.levelName_ + ", "; } currentPlaylist.Insert(index + countCmd - 1, lvl); } playerVotesThisRound[GeneralUtilities.getUniquePlayerString(p)] = countRound; if (countCmd > 0) { G.Sys.GameManager_.LevelPlaylist_.Clear(); foreach (var lvl in currentPlaylist) { G.Sys.GameManager_.LevelPlaylist_.Add(lvl); } G.Sys.GameManager_.LevelPlaylist_.SetIndex(origIndex); lvlsStr = lvlsStr.Substring(0, lvlsStr.Count() - 2); if (countCmd > 10) { lvlsStr = lvlsStr + $" and {countCmd - 10} more"; } if (p.IsLocal_) { MessageUtilities.sendMessage(p, "Level(s) " + lvlsStr + " added to the playlist !"); } else { MessageUtilities.sendMessage("Level(s) " + lvlsStr + " added to the playlist by " + p.GetChatName() + "!"); } } }
public override void use(ClientPlayerInfo p, string message) { Match playlistCmdMatch = Regex.Match(message, @"^(\w+) ?(.*)$"); if (!playlistCmdMatch.Success) { help(p); return; } string uniquePlayerString = GeneralUtilities.getUniquePlayerString(p); string filterCmd = playlistCmdMatch.Groups[1].Value.ToLower(); string filterCmdData = playlistCmdMatch.Groups[2].Value; switch (filterCmd) { default: MessageUtilities.sendMessage(p, $"[A00000]Invalid sub-command `{filterCmd}`[-]"); help(p); break; case "list": { var searchRegex = GeneralUtilities.getSearchRegex(filterCmdData); var results = ""; foreach (KeyValuePair <string, string> pair in savedFilters) { if (Regex.IsMatch(pair.Key, searchRegex, RegexOptions.IgnoreCase)) { results += "\n" + pair.Key; } } if (results.Length == 0) { results = " None"; } MessageUtilities.sendMessage(p, "[FFFFFF]Found:[-]" + results); break; } case "save": { Match nameFilterMatch = Regex.Match(filterCmdData, @"^(.+?)\s+(.*)$"); if (!playlistCmdMatch.Success) { MessageUtilities.sendMessage(p, "[A00000]Bad format for save[-]"); help(p); return; } var saveAt = nameFilterMatch.Groups[1].Value; var saveFilter = nameFilterMatch.Groups[2].Value; if (saveAt == "") { MessageUtilities.sendMessage(p, "[A00000]Name required[-]"); help(p); return; } else if (saveFilter == "") { MessageUtilities.sendMessage(p, "[A00000]Filter required[-]"); help(p); return; } savedFilters[saveAt] = saveFilter; Entry.save(); PlaylistTools.LevelFilters.LevelFilterLast.SetActivePlayer(p); var result = FilteredPlaylist.ParseFiltersFromString(saveFilter); if (!result.value.Any(filter => filter is PlaylistTools.LevelFilters.LevelFilterLast)) { PlaylistTools.LevelFilters.LevelFilterLast.SaveFilter(p, saveFilter); } else { MessageUtilities.sendMessage(p, "[FFA000]The filter -last will always pull from your last-used filter " + "and does not have a consistent value. If you want to save your last used filter, " + "you will need to re-type it."); } MessageUtilities.pushMessageOption(new MessageStateOptionPlayer(p)); GeneralUtilities.sendFailures(result.failures, 4); MessageUtilities.popMessageOptions(); MessageUtilities.sendMessage(p, $"Saved filter to [FFFFFF]{saveAt}[-]:\n[FFFFFF]{saveFilter}[-]"); break; } case "del": { if (filterCmdData == "") { MessageUtilities.sendMessage(p, "[A00000]You must enter a name[-]"); break; } List <string> toDelete; var count = 0; if (deleteConfirmation.TryGetValue(uniquePlayerString, out toDelete)) { if (filterCmdData.ToLower() == "yes") { foreach (string filterName in toDelete) { savedFilters.Remove(filterName); count++; } MessageUtilities.sendMessage(p, $"Deleted {count} filters."); deleteConfirmation.Remove(uniquePlayerString); Entry.save(); break; } else if (filterCmdData.ToLower() == "no") { deleteConfirmation.Remove(uniquePlayerString); MessageUtilities.sendMessage(p, "Cancelled deletion."); break; } } var searchRegex = GeneralUtilities.getSearchRegex(filterCmdData); toDelete = new List <string>(); var results = ""; foreach (KeyValuePair <string, string> pair in savedFilters) { if (Regex.IsMatch(pair.Key, searchRegex, RegexOptions.IgnoreCase)) { toDelete.Add(pair.Key); results += "\n" + pair.Key; count++; } } if (count > 0) { deleteConfirmation[uniquePlayerString] = toDelete; MessageUtilities.sendMessage(p, $"[FFFFFF]Use [A05000]!filter del yes[-] to delete {count} filters:[-] {results}"); } else { MessageUtilities.sendMessage(p, "[A00000]No filters found[-]"); } } break; case "show": { var searchRegex = GeneralUtilities.getSearchRegex(filterCmdData); var results = ""; foreach (KeyValuePair <string, string> pair in savedFilters) { if (Regex.IsMatch(pair.Key, searchRegex, RegexOptions.IgnoreCase)) { results += $"\n{pair.Key}[FFFFFF]:[-] {pair.Value}"; } } if (results.Length == 0) { results = " None"; } MessageUtilities.sendMessage(p, "[FFFFFF]Found:[-]" + results); break; } case "current": { PlaylistCmd playlistCmd = Cmd.all.getCommand <PlaylistCmd>("playlist"); if (!playlistCmd.canUseCurrentPlaylist) { MessageUtilities.sendMessage(p, "Cannot modify current playlist right now."); break; } Console.WriteLine($"Filter txt: {filterCmdData}"); // 1. load current playlist into filter LevelPlaylist currentList = G.Sys.GameManager_.LevelPlaylist_; FilteredPlaylist preFilterer = new FilteredPlaylist(currentList.Playlist_); MessageUtilities.pushMessageOption(new MessageStateOptionPlayer(p)); GeneralUtilities.sendFailures(GeneralUtilities.addFiltersToPlaylist(preFilterer, p, filterCmdData, false), 4); MessageUtilities.popMessageOptions(); // 2. add filter that always allows the current level and helps us find it after calculation. var indexFilter = new ForceCurrentIndexFilter(currentList.Index_); preFilterer.AddFilter(indexFilter); // 3. Calculate filter results. CalculateResult levels = preFilterer.Calculate(); // 4. Update current playlist currentList.Playlist_.Clear(); currentList.Playlist_.AddRange(levels.levelList); // 4. Get current level index, set playlist index to current level index if (indexFilter.level != null) { int index = levels.levelList.IndexOf(indexFilter.level); if (index >= 0) { currentList.SetIndex(index); } else { currentList.SetIndex(0); MessageUtilities.sendMessage(p, "[A05000]Warning: could not find current level in new playlist (2). Reset to beginning.[-]"); } } else { currentList.SetIndex(0); MessageUtilities.sendMessage(p, "[A05000]Warning: could not find current level in new playlist. Reset to beginning.[-]"); } MessageUtilities.sendMessage(p, "Filtered current playlist. Upcoming:"); FilteredPlaylist filterer = new FilteredPlaylist(currentList.Playlist_, -currentList.Index_ - 1); filterer.AddFilter(new LevelFilterAll()); filterer.AddFilter(new LevelFilterIndex(new IntComparison(currentList.Index_, IntComparison.Comparison.Greater))); MessageUtilities.sendMessage(p, GeneralUtilities.getPlaylistText(filterer, GeneralUtilities.IndexMode.Initial, playlistCmd.levelFormat)); break; } case "upcoming": { PlaylistCmd playlistCmd = Cmd.all.getCommand <PlaylistCmd>("playlist"); if (!playlistCmd.canUseCurrentPlaylist) { MessageUtilities.sendMessage(p, "Cannot modify current playlist right now."); break; } // 1. load current playlist into filter LevelPlaylist currentList = G.Sys.GameManager_.LevelPlaylist_; if (currentList.Index_ == currentList.Count_ - 1) { MessageUtilities.sendMessage(p, "Cannot filter upcoming because you are on the last item of the list."); break; } var levelsUpcoming = currentList.Playlist_.GetRange(currentList.Index_ + 1, currentList.Count_ - currentList.Index_ - 1); FilteredPlaylist preFilterer = new FilteredPlaylist(levelsUpcoming); MessageUtilities.pushMessageOption(new MessageStateOptionPlayer(p)); GeneralUtilities.sendFailures(GeneralUtilities.addFiltersToPlaylist(preFilterer, p, filterCmdData, false), 4); MessageUtilities.popMessageOptions(); // 2. Calculate filter results. List <LevelPlaylist.ModeAndLevelInfo> levels = preFilterer.Calculate().levelList; // 3. Update current playlist currentList.Playlist_.RemoveRange(currentList.Index_ + 1, currentList.Count_ - currentList.Index_ - 1); currentList.Playlist_.AddRange(levels); // 4. Print results MessageUtilities.sendMessage(p, "Filtered current playlist. Upcoming:"); FilteredPlaylist filterer = new FilteredPlaylist(currentList.Playlist_, -currentList.Index_ - 1); filterer.AddFilter(new LevelFilterAll()); filterer.AddFilter(new LevelFilterIndex(new IntComparison(currentList.Index_, IntComparison.Comparison.Greater))); MessageUtilities.sendMessage(p, GeneralUtilities.getPlaylistText(filterer, GeneralUtilities.IndexMode.Initial, playlistCmd.levelFormat)); break; } } }
public override void use(ClientPlayerInfo p, string message) { Match playlistCmdMatch = Regex.Match(message, @"^(\w+) ?(.*)$"); if (!playlistCmdMatch.Success) { help(p); return; } MessageUtilities.pushMessageOption(new MessageStateOptionPlayer(p)); string uniquePlayerString = GeneralUtilities.getUniquePlayerString(p); string playlistCmd = playlistCmdMatch.Groups[1].Value.ToLower(); string playlistCmdData = playlistCmdMatch.Groups[2].Value; switch (playlistCmd) { default: MessageUtilities.sendMessage($"[A00000]Invalid sub-command `{playlistCmd}`[-]"); help(p); break; case "list": { List <string> playlists = getPlaylists(playlistCmdData); var results = ""; foreach (string playlist in playlists) { results += "\n" + (playlist == "current" ? playlist : Resource.GetFileNameWithoutExtension(playlist)); } if (results == "") { results = "None"; } MessageUtilities.sendMessage("[FFFFFF]Playlists: [-]" + results); break; } case "new": { LevelPlaylist list = LevelPlaylist.Create(true); list.Name_ = "New Playlist"; FilteredPlaylist levels = new FilteredPlaylist(GeneralUtilities.getAllLevelsAndModes()); GeneralUtilities.addFiltersToPlaylist(levels, p, playlistCmdData, true); list.Playlist_.AddRange(levels.Calculate().levelList); selectedPlaylists[uniquePlayerString] = list; MessageUtilities.sendMessage("[FFFFFF]New playlist with...[-]"); MessageUtilities.sendMessage(GeneralUtilities.getPlaylistText(levels, GeneralUtilities.IndexMode.Final, levelFormat)); break; } case "load": { int matchingCount = 0; LevelPlaylist selectedPlaylist = getPlaylistLevels(playlistCmdData, out matchingCount, getActivePlaylist(p)); if (matchingCount == 0) { MessageUtilities.sendMessage("[A00000]Could not find any playlists with that search[-]"); break; } else if (matchingCount == 1) { MessageUtilities.sendMessage($"{selectedPlaylist.Name_} is now active"); } else { MessageUtilities.sendMessage($"{selectedPlaylist.Name_} is now active, but {matchingCount - 1} others matched too"); } selectedPlaylists[uniquePlayerString] = selectedPlaylist; break; } case "save": { LevelPlaylist selectedPlaylist; if (!selectedPlaylists.TryGetValue(uniquePlayerString, out selectedPlaylist)) { MessageUtilities.sendMessage("[A00000]You have no active playlist[-]"); break; } if (selectedPlaylist.Playlist_.Count == 0) { MessageUtilities.sendMessage("[A00000]Your active playlist is empty[-]"); break; } if (playlistCmdData == "") { MessageUtilities.sendMessage($"[A05000]No name given. Using existing name: {selectedPlaylist.Name_}"); playlistCmdData = selectedPlaylist.Name_; } bool result = savePlaylist(selectedPlaylist, playlistCmdData); switch (playlistCmdData) { case "current": if (result) { MessageUtilities.sendMessage("Set current playlist to active playlist."); } else { MessageUtilities.sendMessage("You cannot save to the current playlist right now."); } break; case "upcoming": if (result) { MessageUtilities.sendMessage("Set upcoming levels to active playlist."); } else { MessageUtilities.sendMessage("You cannot save to the current playlist right now."); } break; case "active": MessageUtilities.sendMessage("No changes made."); break; default: selectedPlaylist.Name_ = playlistCmdData; MessageUtilities.sendMessage($"Saved playlist as {playlistCmdData}."); break; } break; } case "active": { LevelPlaylist selectedPlaylist; if (!selectedPlaylists.TryGetValue(uniquePlayerString, out selectedPlaylist)) { MessageUtilities.sendMessage("[A00000]You have no active playlist[-]"); break; } MessageUtilities.sendMessage(selectedPlaylist.Name_); break; } case "del": { if (playlistCmdData == "") { MessageUtilities.sendMessage("[A00000]You must enter a name[-]"); break; } List <string> toDelete; var count = 0; if (deleteConfirmation.TryGetValue(uniquePlayerString, out toDelete)) { if (playlistCmdData.ToLower() == "yes") { foreach (string playlist in toDelete) { FileEx.Delete(playlist); count++; } MessageUtilities.sendMessage($"Deleted {count} playlists."); deleteConfirmation.Remove(uniquePlayerString); break; } else if (playlistCmdData.ToLower() == "no") { deleteConfirmation.Remove(uniquePlayerString); MessageUtilities.sendMessage("Cancelled deletion."); break; } } var searchRegex = GeneralUtilities.getSearchRegex(playlistCmdData); List <string> playlists = GeneralUtilities.playlists(); playlists.RemoveAll((string s) => !Resource.FileExist(s)); toDelete = new List <string>(); var results = ""; foreach (string playlist in playlists) { if (Regex.IsMatch(playlist == "current" ? playlist : Resource.GetFileNameWithoutExtension(playlist), searchRegex, RegexOptions.IgnoreCase)) { toDelete.Add(playlist); results += "\n" + (playlist == "current" ? playlist : Resource.GetFileNameWithoutExtension(playlist)); count++; } } if (count > 0) { deleteConfirmation[uniquePlayerString] = toDelete; MessageUtilities.sendMessage($"[FFFFFF]Use [A05000]!playlist del yes[-] to delete {count} playlists:[-] {results}"); } else { MessageUtilities.sendMessage("[A00000]No playlists found[-]"); } } break; case "show": { LevelPlaylist selectedPlaylist; if (!selectedPlaylists.TryGetValue(uniquePlayerString, out selectedPlaylist)) { MessageUtilities.sendMessage("[A00000]You have no active playlist[-]"); break; } FilteredPlaylist filterer = new FilteredPlaylist(selectedPlaylist.Playlist_); GeneralUtilities.addFiltersToPlaylist(filterer, p, playlistCmdData, false); MessageUtilities.sendMessage(GeneralUtilities.getPlaylistText(filterer, GeneralUtilities.IndexMode.Initial, levelFormat)); break; } case "filter": { LevelPlaylist selectedPlaylist; if (!selectedPlaylists.TryGetValue(uniquePlayerString, out selectedPlaylist)) { MessageUtilities.sendMessage("[A00000]You have no active playlist[-]"); break; } FilteredPlaylist filterer = new FilteredPlaylist(selectedPlaylist.Playlist_); GeneralUtilities.addFiltersToPlaylist(filterer, p, playlistCmdData, false); selectedPlaylist.Playlist_.Clear(); selectedPlaylist.Playlist_.AddRange(filterer.Calculate().levelList); MessageUtilities.sendMessage("[FFFFFF]Filtered:[-]"); MessageUtilities.sendMessage(GeneralUtilities.getPlaylistText(filterer, GeneralUtilities.IndexMode.Final, levelFormat)); break; } case "add": { LevelPlaylist selectedPlaylist; if (!selectedPlaylists.TryGetValue(uniquePlayerString, out selectedPlaylist)) { MessageUtilities.sendMessage("[A00000]You have no active playlist[-]"); break; } FilteredPlaylist filterer = new FilteredPlaylist(GeneralUtilities.getAllLevelsAndModes()); GeneralUtilities.addFiltersToPlaylist(filterer, p, playlistCmdData, true); selectedPlaylist.Playlist_.AddRange(filterer.Calculate().levelList); MessageUtilities.sendMessage("[FFFFFF]Added:[-]"); MessageUtilities.sendMessage(GeneralUtilities.getPlaylistText(filterer, GeneralUtilities.IndexMode.Final, levelFormat)); break; } case "clear": { LevelPlaylist selectedPlaylist; if (!selectedPlaylists.TryGetValue(uniquePlayerString, out selectedPlaylist)) { MessageUtilities.sendMessage("[A00000]You have no active playlist[-]"); break; } selectedPlaylist.Playlist_.Clear(); MessageUtilities.sendMessage("[FFFFFF]Cleared[-]"); break; } } MessageUtilities.popMessageOptions(); }
public override void use(ClientPlayerInfo p, string message) { if (message == "") { help(p); return; } if (G.Sys.GameManager_.ModeID_ == GameModeID.Trackmogrify) { MessageUtilities.sendMessage(p, "You can't manage the playlist in trackmogrify"); return; } Match match = Regex.Match(message, cmdPattern); if (!match.Success) { help(p); MessageUtilities.sendMessage(p, "For example, !dels 0 5"); } string id1s = match.Groups[1].Value; string id2s = match.Groups[2].Value; Console.WriteLine($"{id1s}"); Console.WriteLine($"{id2s}"); int id1 = 0; int id2 = 0; int.TryParse(id1s, out id1); int.TryParse(id2s, out id2); if (id1 < 0 || id2 < 0) { MessageUtilities.sendMessage(p, "The indices must be positive numbers or 0."); return; } else if (id1 > id2) { MessageUtilities.sendMessage(p, "indexStart must be <= indexEnd."); } int index = G.Sys.GameManager_.LevelPlaylist_.Index_; int playListSize = G.Sys.GameManager_.LevelPlaylist_.Playlist_.Count - index - 1; if (id2 >= playListSize) { MessageUtilities.sendMessage(p, "The playlist has only " + playListSize + " maps."); return; } LevelPlaylist playlist = new LevelPlaylist(); playlist.CopyFrom(G.Sys.GameManager_.LevelPlaylist_); var currentPlaylist = playlist.Playlist_; for (int id = id1; id <= id2; id++) { currentPlaylist.RemoveAt(index + id1 + 1); } G.Sys.GameManager_.LevelPlaylist_.Clear(); foreach (var lvl in currentPlaylist) { G.Sys.GameManager_.LevelPlaylist_.Add(lvl); } G.Sys.GameManager_.LevelPlaylist_.SetIndex(index); MessageUtilities.sendMessage(p, $"{id2 - id1 + 1} maps removed !"); }
// Use this for initialization void Start() { var mus=GameObject.FindGameObjectWithTag("MusicSys"); if (mus) music_sys=mus.GetComponent<MusicSys>(); level_stats=GameObject.FindGameObjectWithTag("LevelPlaylist").GetComponent<LevelPlaylist>(); gameoverPanel.gameObject.SetActive(false); score_list=new List<PlayerScoreData>(); State=GameState.Setup; var entDB=GameObject.FindGameObjectWithTag("EntityDatabase"); stats=entDB.GetComponent<GameplayDatabase>().Stats[0]; scores=new List<int>(); scores.Add(stats.Score_first); scores.Add(stats.Score_second); scores.Add(stats.Score_third); scores.Add(stats.Score_fourth); if (music_sys) music_sys.StopCurrent(); }