示例#1
0
 public void LoadSongJson(string songName)
 {
     if (_SongToLoad == null)
     {
         _SongToLoad = JsonToSong.GetSongJson(songName);
     }
 }
示例#2
0
    public void LoadSong(SongJson songToLoad)
    {
        Song loadedSong = JsonToSong.SongJsonToSong(songToLoad);

        Global._PlayingSong = loadedSong;
        _HasLoadedSong      = true;
    }
示例#3
0
    public static Song SongJsonToSong(SongJson songJson)
    {
        //Notes
        List <Note> notes = new List <Note>();

        if (songJson.Notes != null)
        {
            foreach (NoteJson noteJson in songJson.Notes)
            {
                Note.Direction direction = GetDirection(noteJson.Key);
                notes.Add(new Note(direction, noteJson.Beat, noteJson.Duration));
            }
        }

        //Effects
        List <Effect> effects = new List <Effect>();

        if (songJson.Effects != null)
        {
            foreach (EffectJson effectJson in songJson.Effects)
            {
                Effect.EffectType type = GetEffect(effectJson.Effect);
                effects.Add(new Effect(type, effectJson.Beat, effectJson.Scale));
            }
        }

        //Audio
        AudioClip clip = AssetLoader.GetClipFromFile(songJson.Backtrack);

        return(new Song(notes, effects, clip, songJson.BPM, songJson.NoteSpeed));
    }
示例#4
0
    public static SongJson GetSongJson(string songName)
    {
        string   path       = Application.streamingAssetsPath + "/Songs/" + songName + ".json";
        string   jsonString = File.ReadAllText(path);
        SongJson songJson   = JsonUtility.FromJson <SongJson>(jsonString);

        return(songJson);
    }