public int GetDifficulty(string song_name, LevelStaticData.Difficulty difficulty)
        {
            writer = new StreamWriter(Environment.CurrentDirectory.Replace('\\', '/') + "/CustomSongs/.Output" + "/" + song_name + "_" + difficulty + "_song_parse.txt", false);
            writer.Write(song_name + " " + difficulty + Environment.NewLine);

            if (_notes.Length < 1)
            {
                writer.Write("No Notes in file, not handled!");
                return(1);
            }

            Array.Sort(_notes, delegate(Note x, Note y) { return(x._time.CompareTo(y._time)); }); // Not always sorted in some cases
            _secondsPerBeat = 1.0f / (_beatsPerMinute / 60.0f);
            _length         = _notes[_notes.Length - 1]._time - _notes[0]._time;
            writer.Write("Seconds Per Beat: " + _secondsPerBeat + Environment.NewLine);

            //float temp = UnityEngine.Random.Range(0.0f, 10.0f);
            //int temp2 = (int)(temp * 100.0f);
            int   temp       = 0;
            float diff_score = 0.0f;

            try
            {
                ArrayList note_diffs = getNoteDifficulty();
                diff_score = parseDifficultyData(note_diffs);
            }
            catch (Exception e)
            {
                writer.Write(e.Message);
                writer.Write(e.StackTrace);
            }
            temp = (int)(diff_score * 100.0f); // Don't worry, DifficultyDisplay.cs will fix this

            writer.Close();
            return(temp);
        }
        private CustomLevelStaticData LoadNewSong(CustomSongInfo song, GameScenesManager gameScenesManager)
        {
            CustomLevelStaticData newLevel = null;

            try
            {
                newLevel          = ScriptableObject.CreateInstance <CustomLevelStaticData>();
                newLevel.jsonPath = song.path;
            }
            catch (NullReferenceException)
            {
                //LevelStaticData.OnEnable throws null reference exception because we don't have time to set _difficultyLevels
            }

            ReflectionUtil.SetPrivateField(newLevel, "_levelId", song.levelId);
            ReflectionUtil.SetPrivateField(newLevel, "_authorName", song.authorName);
            ReflectionUtil.SetPrivateField(newLevel, "_songName", song.songName);
            ReflectionUtil.SetPrivateField(newLevel, "_songSubName", song.songSubName);
            ReflectionUtil.SetPrivateField(newLevel, "_previewStartTime", song.previewStartTime);
            ReflectionUtil.SetPrivateField(newLevel, "_previewDuration", song.previewDuration);
            ReflectionUtil.SetPrivateField(newLevel, "_beatsPerMinute", song.beatsPerMinute);
            StartCoroutine(LoadSprite("file://" + song.path + "/" + song.coverImagePath, newLevel, "_coverImage"));

            SceneInfo newSceneInfo = ScriptableObject.CreateInstance <SceneInfo>();

            ReflectionUtil.SetPrivateField(newSceneInfo, "_gameScenesManager", gameScenesManager);
            ReflectionUtil.SetPrivateField(newSceneInfo, "_sceneName", song.environmentName);

            ReflectionUtil.SetPrivateField(newLevel, "_environmetSceneInfo", newSceneInfo);

            List <CustomLevelStaticData.CustomDifficultyLevel> difficultyLevels =
                new List <CustomLevelStaticData.CustomDifficultyLevel>();

            foreach (CustomSongInfo.DifficultyLevel diffLevel in song.difficultyLevels)
            {
                CustomLevelStaticData.CustomDifficultyLevel newDiffLevel =
                    new CustomLevelStaticData.CustomDifficultyLevel();
                try
                {
                    LevelStaticData.Difficulty difficulty =
                        diffLevel.difficulty.ToEnum(LevelStaticData.Difficulty.Normal);
                    ReflectionUtil.SetPrivateField(newDiffLevel, "_difficulty", difficulty);
                    ReflectionUtil.SetPrivateField(newDiffLevel, "_difficultyRank", diffLevel.difficultyRank);

                    if (!File.Exists(song.path + "/" + diffLevel.jsonPath))
                    {
                        Logger.Log("Couldn't find difficulty json " + song.path + "/" + diffLevel.jsonPath);
                        continue;
                    }

                    newDiffLevel.jsonPath  = song.path + "/" + diffLevel.jsonPath;
                    newDiffLevel.audioPath = song.path + "/" + diffLevel.audioPath;
                    difficultyLevels.Add(newDiffLevel);
                }
                catch (Exception e)
                {
                    Logger.Log("Error parsing difficulty level in song: " + song.path);
                    Logger.Log(e.Message);
                    continue;
                }
            }

            if (difficultyLevels.Count == 0)
            {
                return(null);
            }

            ReflectionUtil.SetPrivateField(newLevel, "_difficultyLevels", difficultyLevels.ToArray());
            return(newLevel);
        }