Ejemplo n.º 1
0
    // MUSICS
    public void PlayMusic(MusicNames musicID)
    {
        if (_selectedMusic != null)
        {
            StopMusic();
            _finishingMusic = _selectedMusic;
        }
        _selectedMusic = Musics.Find(music => music.MusicID == musicID);
        if (_selectedMusic == null)
        {
            Debug.LogError("The music to play has not been found -- " + musicID);
            return;
        }
        if (MusicSources.ContainsKey(musicID))
        {
            Debug.LogWarning("The music is already being played -- " + musicID);
            return;
        }

        if (_finishingMusic != null)
        {
            StartCoroutine(FadeMixerGroup.StartFade(AudioMixer, "Fading", FadingTime, -40f));
            StartCoroutine(ChangePlayingMusic());
        }
        else
        {
            _musicCoroutine = StartCoroutine(PlayingMusic(_selectedMusic));
        }
    }
Ejemplo n.º 2
0
    public void Load(MusicNames MusicName, Levels level)
    {
        NotesManager notesManager = (NotesManager)FindObjectOfType(typeof(NotesManager));
        MoveManager  moveManager  = (MoveManager)FindObjectOfType(typeof(MoveManager));
        JudgeScript  judgeScript  = (JudgeScript)FindObjectOfType(typeof(JudgeScript));

        string folderName = "Data/" + MusicName.ToString() + "/";

        TextAsset    musicData = Resources.Load <TextAsset>(folderName + tuneData);
        StringReader sr        = new StringReader(musicData.text);

        while (sr.Peek() != -1)
        {
            string        _str = sr.ReadLine();
            string[]      str  = _str.Split(',');
            TuneDataIndex tuneDataIndex;
            Enum.TryParse <TuneDataIndex>(str[0], out tuneDataIndex);
            switch (tuneDataIndex)
            {
            case TuneDataIndex.NAME:
                musicName = str[1];
                break;

            case TuneDataIndex.BPM:
                bpm = float.Parse(str[1]);
                break;

            case TuneDataIndex.OFFSET:
                offset = float.Parse(str[1]);
                break;
            }
        }
        notesManager.SetBPM(bpm);
        notesManager.SetOffset(offset);

        TextAsset notesData = Resources.Load <TextAsset>(folderName + level.ToString() + "NotesData");

        notesManager.Load(notesData);
        AudioClip clip = Resources.Load <AudioClip>(folderName + clipName);

        moveManager.Init();
        moveManager.SetClip(clip);
        judgeScript.Init();

        moveManager.MusicStart();
    }
Ejemplo n.º 3
0
 public void PlayTheMusic()
 {
     AudioManager.StopAllMusic();
     nowPlaying = musicToPlay[Random.Range(0, musicToPlay.Length)];
     AudioManager.PlayMusic(nowPlaying.ToString(), transform.position);
 }