public static bool SaveLevel(string fileName, LevelJSON level) { var json = JsonConvert.SerializeObject(level); File.WriteAllText(fileName, json); return(true); }
public static BeatSaberJSONClass ConvertUnityDataToBSData(BeatMapData data) { BeatSaberJSONClass bsaberJSON = new BeatSaberJSONClass(); bsaberJSON.info = new InfoJSON(); bsaberJSON.info.beatsPerMinute = (int)data.beatsPerMinute; bsaberJSON.info.authorName = data.mapArtist; bsaberJSON.info.songSubName = data.songArtist; bsaberJSON.info.songName = data.songName; // TODO merge with existing info if any // bsaberJSON.info.difficultyLevels = new DifficultyLevel[1]; bsaberJSON.info.difficultyLevels[0] = DifficultyLevel.Generate(data.difficulty, data.songFileName, (int)data.songOffset); List <BSNote> notes = new List <BSNote>(); for (int count = 0; count < data.notes.Length; count++) { if (!data.notes[count].inverted) { BSNote bSNote = new BSNote(); if (data.notes[count].color == Note.NoteColor.LEFT) { bSNote._type = 0; } else { bSNote._type = 1; } bSNote._cutDirection = BSNote.GetBSaberCutDirection(data.notes[count].slashDirection); bSNote._lineIndex = (int)data.notes[count].gridPosition.x; bSNote._lineLayer = (int)data.notes[count].gridPosition.y; bSNote._time = data.notes[count].timeToSpawn; notes.Add(bSNote); } } BeatMap.Log("Notes exported with count " + notes.Count); LevelJSON level = new LevelJSON(); level._beatsPerMinute = (int)data.beatsPerMinute; level._version = "1.0"; level._beatsPerBar = 16; level._noteJumpSpeed = 10; level._shufflePeriod = .5f; level._notes = notes.ToArray(); bsaberJSON.level = level; return(bsaberJSON); }
//used when saving private void SetAllJSONLevelInstances() { ListOfAllLevelJSON = new List<LevelJSON>(); for (int i = 0; i < ListOfAllLevelScriptInstances.Count; i++) { LevelJSON levelJSONToAdd = new LevelJSON(); levelJSONToAdd.SceneNr = ListOfAllLevelScriptInstances[i].SceneNr; levelJSONToAdd.Name = ListOfAllLevelScriptInstances[i].Name; levelJSONToAdd.IsBonusLevel = ListOfAllLevelScriptInstances[i].IsBonusLevel; levelJSONToAdd.IsActive = ListOfAllLevelScriptInstances[i].IsActive; levelJSONToAdd.IsPassed = ListOfAllLevelScriptInstances[i].IsPassed; levelJSONToAdd.InformationList = ListOfAllLevelScriptInstances[i].InformationList; levelJSONToAdd.StarValue = ListOfAllLevelScriptInstances[i].StarValue; levelJSONToAdd.WorldPageNumber = ListOfAllLevelScriptInstances[i].WorldPageNumber; levelJSONToAdd.WorldName = ListOfAllLevelScriptInstances[i].WorldName; ListOfAllLevelJSON.Add(levelJSONToAdd); } }