示例#1
0
 MusicArea(LoopTrack[] other)
 {
     loops = new LoopTrack[other.Length];
     for (int i = 0; i < other.Length; ++i){
         loops[i] = new LoopTrack(other[i]);
     }
 }
示例#2
0
 MusicArea(LoopTrack[] other)
 {
     loops = new LoopTrack[other.Length];
     for (int i = 0; i < other.Length; ++i)
     {
         loops[i] = new LoopTrack(other[i]);
     }
 }
示例#3
0
 public void initializeEditorAudio(LoopTrack[] loops)
 {
     editorAudio.Clear();
     foreach (LoopTrack track in loops){
         AudioSource aud = createAudioSource(track, "Editor Audio");
         print ("Adding " + track.clip.name);
         editorAudio.Add(aud);
     }
 }
    public void AddTrack(LoopTrack aTrack)
    {
        PlayingTrack pt = new PlayingTrack();

        pt.audioSource = GetNewAudioSource(aTrack);
        pt.loopTrack   = aTrack;

        playingTracks.Add(pt);
    }
示例#5
0
 public static void CreateMusicArea(GameObject obj, LoopTrack[] other)
 {
     MusicArea ma = obj.AddComponent<MusicArea>();
     ma.loops = new LoopTrack[other.Length];
     obj.name = "Music Area " + number++;
     for (int i = 0; i < other.Length; ++i){
         ma.loops[i] = new LoopTrack(other[i]);
     }
 }
    public void StopTrack(LoopTrack aTrack)
    {
        PlayingTrack pt = playingTracks.Find(x => x.loopTrack == aTrack);

        if (pt == null)
        {
            Debug.LogError("Trying to stop track that hasn't been added: " + aTrack.ToString());
            return;
        }

        pt.targetVolume = 0;
    }
    public void SetBaseTrack(LoopTrack aTrack)
    {
        PlayingTrack pt = playingTracks.Find(x => x.loopTrack == aTrack);

        if (pt == null)
        {
            Debug.LogError("Trying to set base track that hasn't been added: " + aTrack.ToString());
            return;
        }

        baseTrack = pt;
    }
    void OnLoopStopped(LoopTrack aTrack)
    {
        if (currentTracksToRemove.Exists(x => x == aTrack))
        {
            currentTracksToRemove.Remove(aTrack);
            musicLooper.RemoveTrack(aTrack);

            if (currentTracksToRemove.Count == 0)
            {
                PlaySequenceTracks();
                musicLooper.onLoopStopped -= OnLoopStopped;
            }
        }
    }
示例#9
0
    void OnLoopStopped(LoopTrack aTrack)
    {
        if (currentChange != null && aTrack == currentChange.track)
        {
            currentChange = null;
        }

        if (currentTransition.state == Transition.State.StoppingPrevious)
        {
            if (currentTransition.tracksToRemove.Exists(x => x == aTrack))
            {
                currentTransition.state = Transition.State.WaitToStartNextLoops;
            }
        }
    }
示例#10
0
    AudioSource createAudioSource(LoopTrack track, string name)
    {
        GameObject go = new GameObject();

        go.transform.parent = transform;
        go.AddComponent <AudioSource>();
        go.transform.position = transform.position;
        go.transform.rotation = Quaternion.Euler(0, 0, 0);
        go.name = name;
        AudioSource aud = go.GetComponent <AudioSource>();

        aud.loop   = true;
        aud.clip   = track.clip;
        aud.volume = track.volume;
        return(aud);
    }
示例#11
0
    void OnLoopStarted(LoopTrack aTrack)
    {
        if (currentChange != null && aTrack == currentChange.track)
        {
            currentChange = null;
        }

        if (currentTransition.state == Transition.State.StartingTransitionTracks)
        {
            StopTracksToRemove();
        }
        else if (currentTransition.state == Transition.State.StartingNextLoops &&
                 currentTransition.nextCollection.loopBase == aTrack)
        {
            CompleteTransition();
        }
    }
    public void RemoveTrack(LoopTrack aTrack)
    {
        PlayingTrack pt = playingTracks.Find(x => x.loopTrack == aTrack);

        if (pt == null)
        {
            Debug.LogError("Trying to remove track that hasn't been added: " + aTrack.ToString());
            return;
        }

        if (pt == baseTrack)
        {
            Debug.LogError("Trying to remove base track [" + aTrack.ToString() + "], replace with another track first!");
            return;
        }

        Destroy(pt.audioSource);
        playingTracks.Remove(pt);
    }
    AudioSource GetNewAudioSource(LoopTrack aLoopTrack)
    {
        AudioSource audioSource = gameObject.AddComponent <AudioSource>();

        audioSource.clip   = aLoopTrack.clip;
        audioSource.volume = 0;
        audioSource.loop   = true;
        audioSource.outputAudioMixerGroup = mixer;

        audioSource.Play();

        float time = 0;

        if (baseTrack != null)
        {
            time = baseTrack.audioSource.time % aLoopTrack.clip.length;
        }

        audioSource.time = time;

        return(audioSource);
    }
示例#14
0
 AudioSource createAudioSource(LoopTrack track, string name)
 {
     GameObject go = new GameObject();
     go.transform.parent = transform;
     go.AddComponent<AudioSource>();
     go.transform.position = transform.position;
     go.transform.rotation = Quaternion.Euler(0,0,0);
     go.name = name;
     AudioSource aud = go.GetComponent<AudioSource>();
     aud.loop = true;
     aud.clip = track.clip;
     aud.volume = track.volume;
     return aud;
 }
 public PlayingTrack GetPlayingTrackIfActive(LoopTrack aTrack)
 {
     return(playingTracks.Find(x => x.loopTrack == aTrack));
 }
示例#16
0
 public Track(LoopTrack aLoopTrack)
 {
     loopTrack = aLoopTrack;
 }
示例#17
0
 public LoopTrack(LoopTrack other)
 {
     clip   = other.clip;
     volume = other.volume;
 }
示例#18
0
 AudioSource createAudioSource(LoopTrack track)
 {
     return createAudioSource(track, "Audio Track");
 }
示例#19
0
 public void playAllLoops(LoopTrack[] loops)
 {
     if (inGameplay) return;
     transform.position = follow.transform.position;
     if (editorAudio.Count != 0) return;
     initializeEditorAudio(loops);
     foreach(AudioSource aud in editorAudio){
         if (aud) aud.Play();
     }
 }
示例#20
0
 void AddTrack(LoopTrack aTrack)
 {
     musicLooper.AddTrack(aTrack);
 }
示例#21
0
 void AddTrackChange(LoopTrack aTrack, bool aShouldPlay)
 {
     AddTrackChange(new LoopChange(aTrack, aShouldPlay));
 }
示例#22
0
 void RemoveTrack(LoopTrack aTrack)
 {
     musicLooper.RemoveTrack(aTrack);
 }
示例#23
0
 public LoopChange(LoopTrack aTrack, bool aStart)
 {
     track = aTrack;
     play  = aStart;
 }
示例#24
0
 AudioSource createAudioSource(LoopTrack track)
 {
     return(createAudioSource(track, "Audio Track"));
 }
示例#25
0
 //    Public Function
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 //    setTracks is called by a MusicArea when the music area is activated
 //    calling set tracks queues the new tracks to be added in the next time loopbase reaches its end
 public void setTracks(LoopTrack[] area)
 {
     for (int i  = 0; i < area.Length; ++i){
         waitingLayers[i] = createAudioSource(area[i], "AudioTrack from Set");
     }
 }