Exemplo n.º 1
0
 void Awake()
 {
     if (current == null)
     {
         current = this;
     }
     _beatMapExists   = true;
     _audioClipExists = true;
     _audio           = GetComponent <AudioSource>();
     if (_audio.clip == null)
     {
         _audioClipExists = false;
         Debug.LogError("Maestro: No Audio Clip!");
     }
     else
     {
         if ("BeatMap_" + _audio.clip.name.Replace(".mp3", "") != beatmapFile.name)
         {
             Debug.LogWarning("Maestro: Audio Clip and Beatmap File name mismatch!");
         }
     }
     _beatIndex = 0;
     onBeat     = OnBeat;
     lateOnBeat = LateOnBeat;
     listeners  = new List <MusicBehaviour>();
     beatmap    = BeatMapSerializer.BeatMapReader.ReadBeatMap(beatmapFile);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Unsubscribe the specified listener to the Maestro.
 /// </summary>
 /// <param name="listener">Listener (should be a subclass of MusicBehaviour).</param>
 public void Unsubscribe(MusicBehaviour listener)
 {
     if (listeners.Contains(listener))
     {
         listeners.Remove(listener);
         onBeat     -= listener.OnBeat;
         lateOnBeat -= listener.LateOnBeat;
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Subscribe the specified listener to the Maestro.
 /// </summary>
 /// <param name="listener">Listener (should be a subclass of MusicBehaviour).</param>
 public void Subscribe(MusicBehaviour listener)
 {
     if (!listeners.Contains(listener))
     {
         listeners.Add(listener);
         onBeat     += listener.OnBeat;
         lateOnBeat += listener.LateOnBeat;
     }
 }
 public void UnSubscribe(OnBeatDelegate function, float beatMeasure)
 {
     for (int i = 0; i < m_Observers.Count; i++)
     {
         if (m_Observers[i].Measure == beatMeasure)
         {
             m_Observers[i].OnTrigger -= function;
             return;
         }
     }
 }
Exemplo n.º 5
0
 // Unsubscribes method from unknown.
 public void Unsubscribe(OnBeatDelegate subscriber)
 {
     OnAdvanced32nd    -= subscriber;
     OnAdvanced16th    -= subscriber;
     OnAdvanced8th     -= subscriber;
     OnAdvancedQuarter -= subscriber;
     OnAdvancedHalf    -= subscriber;
     OnAdvancedWhole   -= subscriber;
     On32nd            -= subscriber;
     On16th            -= subscriber;
     On8th             -= subscriber;
     OnQuarter         -= subscriber;
     OnHalf            -= subscriber;
     OnWhole           -= subscriber;
 }
        public void SubScribe(OnBeatDelegate function, float beatMeasure)
        {
            // Search for active BeatObserver
            for (int i = 0; i < m_Observers.Count; i++)
            {
                if (m_Observers[i].Measure == beatMeasure)
                {
                    m_Observers[i].OnTrigger += function;
                    return;
                }
            }

            // Add new BeatObserver if there is none for the measure yet.
            BeatObserver observer = CreateNewBeatObserver(beatMeasure);

            observer.OnTrigger += function;
        }
Exemplo n.º 7
0
 public void ClearOnBeatDelegate()
 {
     onBeatDelegate = null;
 }
Exemplo n.º 8
0
 public void RemoveFunctionFromOnBeatDelegate(OnBeatDelegate func)
 {
     onBeatDelegate -= func;
 }
Exemplo n.º 9
0
 /// <summary>
 /// If a function needs to be called on beat with the music, pass it in here!
 /// </summary>
 /// <param name="func"> Function to be called on beat </param>
 public void AssignFunctionToOnBeatDelegate(OnBeatDelegate func)
 {
     onBeatDelegate += func;
 }
Exemplo n.º 10
0
    public void Unsubscribe(OnBeatDelegate subscriber, TriggerTiming triggerTiming, bool advanced = false)
    {
        if (advanced)
        {
            switch (triggerTiming)
            {
            case TriggerTiming.Thirtyseconds:
            {
                OnAdvanced32nd -= subscriber;
                return;
            }

            case TriggerTiming.Sixteenths:
            {
                OnAdvanced16th -= subscriber;
                return;
            }

            case TriggerTiming.Eighths:
            {
                OnAdvanced8th -= subscriber;
                return;
            }

            case TriggerTiming.Quarters:
            {
                OnAdvancedQuarter -= subscriber;
                return;
            }

            case TriggerTiming.Halves:
            {
                OnAdvancedHalf -= subscriber;
                return;
            }

            case TriggerTiming.Wholes:
            {
                OnAdvancedWhole -= subscriber;
                return;
            }
            }
        }
        else
        {
            switch (triggerTiming)
            {
            case TriggerTiming.Thirtyseconds:
            {
                On32nd -= subscriber;
                return;
            }

            case TriggerTiming.Sixteenths:
            {
                On16th -= subscriber;
                return;
            }

            case TriggerTiming.Eighths:
            {
                On8th -= subscriber;
                return;
            }

            case TriggerTiming.Quarters:
            {
                OnQuarter -= subscriber;
                return;
            }

            case TriggerTiming.Halves:
            {
                OnHalf -= subscriber;
                return;
            }

            case TriggerTiming.Wholes:
            {
                OnWhole -= subscriber;
                return;
            }
            }
        }
    }
Exemplo n.º 11
0
 void Awake()
 {
     if (current == null) {
         current = this;
     }
     _beatMapExists = true;
     _audioClipExists = true;
     _audio = GetComponent<AudioSource>();
     if (_audio.clip == null) {
         _audioClipExists = false;
         Debug.LogError("Maestro: No Audio Clip!");
     }
     else {
         if ("BeatMap_" + _audio.clip.name.Replace(".mp3", "") != beatmapFile.name) {
             Debug.LogWarning("Maestro: Audio Clip and Beatmap File name mismatch!");
         }
     }
     _beatIndex = 0;
     onBeat = OnBeat;
     lateOnBeat = LateOnBeat;
     listeners = new List<MusicBehaviour>();
     beatmap = BeatMapSerializer.BeatMapReader.ReadBeatMap(beatmapFile);
 }
Exemplo n.º 12
0
 /// <summary>
 /// Unsubscribe the specified listener to the Maestro.
 /// </summary>
 /// <param name="listener">Listener (should be a subclass of MusicBehaviour).</param>
 public void Unsubscribe(MusicBehaviour listener)
 {
     if (listeners.Contains(listener)) {
         listeners.Remove(listener);
         onBeat -= listener.OnBeat;
         lateOnBeat -= listener.LateOnBeat;
     }
 }
Exemplo n.º 13
0
 /// <summary>
 /// Subscribe the specified listener to the Maestro.
 /// </summary>
 /// <param name="listener">Listener (should be a subclass of MusicBehaviour).</param>
 public void Subscribe(MusicBehaviour listener)
 {
     if (!listeners.Contains(listener)) {
         listeners.Add(listener);
         onBeat += listener.OnBeat;
         lateOnBeat += listener.LateOnBeat;
     }
 }
Exemplo n.º 14
0
 public void RemoveBeatListener(OnBeatDelegate function, float measure)
 {
     m_BeatManager.UnSubscribe(function, measure);
 }
Exemplo n.º 15
0
 public void AddBeatListener(OnBeatDelegate function, float measure)
 {
     m_BeatManager.SubScribe(function, measure);
 }