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 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); }