public static List <string> GetAllPlayableLevelNames() { List <string> playableLevelNames = new List <string>(); MazeLevelNamesData levelNamesData = new JsonMazeLevelListFileReader().ReadData <MazeLevelNamesData>(); if (levelNamesData == null) { return(playableLevelNames); } for (int i = 0; i < levelNamesData.LevelNames.Count; i++) { MazeLevelNameData levelNameData = levelNamesData.LevelNames[i]; if (!levelNameData.IsPlayable) { continue; } if (levelNameData.LevelName == MazeLevelGameplayManager.Instance?.Level?.Name) { continue; } playableLevelNames.Add(levelNameData.LevelName); } if (playableLevelNames.Count == 0) { Logger.Warning("Found 0 playable levels!"); } return(playableLevelNames); }
public MazeLevelNamesData(string levelName) { MazeLevelNamesData oldData = new JsonMazeLevelListFileReader().ReadData <MazeLevelNamesData>(); if (oldData != null) { LevelNames = oldData.LevelNames; } }
private void ToggleLevelPlayability(string levelName, List <string> arguments) { if (arguments.Count < 1) { string message = "The command '<color=" + ConsoleConfiguration.HighlightColour + ">configure maze playable</color>' needs an additional argument saying 'true' or 'false'."; throw new NotEnoughArgumentsConsoleException(message); } MazeLevelNamesData levelNamesData = new JsonMazeLevelListFileReader().ReadData <MazeLevelNamesData>(); string sanatisedLevelName = levelName.ToLower().Replace(" ", "-"); int levelNameIndex = levelNamesData.LevelNames.FindIndex(l => l.LevelName == sanatisedLevelName); if (levelNameIndex == -1) { string message = $"Could not find the maze level '<color={sanatisedLevelName}>info maze</color>' in the list with known maze levels."; throw new MazeLevelNameNotFoundConsoleException(message); } MazeLevelNameData levelNameData = levelNamesData.LevelNames.ElementAt(levelNameIndex); if (levelNameData == null) { string message = $"Could not find the maze level '<color={sanatisedLevelName}>info maze</color>' in the list with known maze levels."; throw new MazeLevelNameNotFoundConsoleException(message); } switch (arguments[0]) { case "true": levelNameData.IsPlayable = true; break; case "false": levelNameData.IsPlayable = false; break; default: string message = $"The command '<color={ConsoleConfiguration.HighlightColour}>configure maze {levelName} playable</color>' needs a last argument saying 'true' or 'false'."; throw new UnknownArgumentConsoleException(message); } levelNamesData.LevelNames[levelNameIndex] = levelNameData; JsonMazeLevelListFileWriter jsonMazeLevelListFileWriter = new JsonMazeLevelListFileWriter(); jsonMazeLevelListFileWriter.SerialiseData(levelNamesData); }
public void OnEnable() { MazeLevelNamesData levelNamesData = new JsonMazeLevelListFileReader().ReadData <MazeLevelNamesData>(); LevelNameToggleData.Clear(); for (int i = 0; i < levelNamesData.LevelNames.Count; i++) { MazeLevelNameData levelNameData = levelNamesData.LevelNames[i]; GameObject levelNameToggleGO = Instantiate(PlayableLevelNameTogglePrefab, PlayableLevelListContainer); PlayableMazeLevelNameToggle playableLevelNameToggle = levelNameToggleGO.GetComponent <PlayableMazeLevelNameToggle>(); playableLevelNameToggle.Initialise(levelNameData); LevelNameToggleData.Add(playableLevelNameToggle, levelNameData); } IsOpen = true; }
public static MazeLevelNamesData GetAllMazeLevelNamesData() { MazeLevelNamesData levelNamesData = new JsonMazeLevelListFileReader().ReadData <MazeLevelNamesData>(); return(levelNamesData); }