示例#1
0
 void Update()
 {
     if (Time.time >= m_nextBeat)
     {
         OnBeat?.Invoke(this, EventArgs.Empty);
         m_nextBeat = Time.time + (60.0f / Bpm);
     }
 }
示例#2
0
 private void Beat()
 {
     counted = true;
     SoundManager.Instance.PlaySound(sound);
     OnBeat?.Invoke();
     if (transform.localScale.x > scalePower)
     {
         transform.localScale -= new Vector3(scalePower, scalePower, scalePower);
     }
 }
 private void Update()
 {
     for (int i = 0; i < isBeatPerBand.Length; ++i)
     {
         if (isBeatPerBand[i])
         {
             OnBeat?.Invoke(i);
         }
     }
 }
示例#4
0
    // Use this for initialization
    void Start()
    {
        audio_source = GetComponent <AudioSource>();

        /*
         * System.IO.File.WriteAllLines("beats.txt",
         *  Enumerable.Range(1, 300 * 32)
         *      .Select(t => beatLerper.TimeFromBeat((float)t / 32).ToString())
         *      .ToArray());
         */
        Song song = BeatFile.ReadStepfile("Assets/music/Baby Bowser's Lullaby.sm");

        //beatLerper = new BeatLerper(song.bpmEvents, song.offset);
        //notes_iter = song.notes.OrderBy(note => note.beat);
        onBeat += SpawnNotes;
    }
示例#5
0
    public void playBeat()
    {
        // Create UI bars
        var barOffset = new Vector3(1000, 0, 0);

        if (barPrefab)
        {
            Vector3    leftBarPosition  = barTarget.transform.position - barOffset;
            Vector3    rightBarPosition = barTarget.transform.position + barOffset;
            GameObject leftBar          = Instantiate(barPrefab, leftBarPosition, Quaternion.identity);
            GameObject rightBar         = Instantiate(barPrefab, rightBarPosition, Quaternion.identity);
            leftBar.transform.SetParent(canvas.transform);
            rightBar.transform.SetParent(canvas.transform);
        }

        OnBeat?.Invoke();
    }
    void Update()
    {
        //Set the time to the current audio system time
        time = AudioSettings.dspTime;
        if (time > nextClick)
        {
            //Play the audio clip once one cycle according to the nextClick variable is complete
            sources[flip].PlayScheduled(nextClick);

            //Increment the nextClick
            nextClick += 60.0f / bpm;

            //Flip the audio source
            flip = 1 - flip;

            OnBeat?.Invoke();
        }
    }
示例#7
0
    protected void Beat()  // Sequences beats in the propper order and triggers their events. Invoked by OnEnable()
    {
        lastBeat = Time.time;

        if (showTiming)
        {
            Debug.Log(lastMainIndex + "-" + lastOffIndex + ":\n" + System.DateTime.Now.Second + "." + System.DateTime.Now.Millisecond);
        }
        if (visualizeBeat && beatGraphic)
        {
            if (beatGraphic.localScale == Vector3.one)
            {
                beatGraphic.localScale *= 2;
            }
            else
            {
                beatGraphic.localScale = Vector3.one;                                                                                                        // Displays the beat on-screen directly
            }
        }
        if (++lastOffIndex > offBeats) // Next Main Beat
        {
            lastOffIndex = 0;
            if (++lastMainIndex > beats) // Next Bar
            {
                lastMainIndex = 0;
                NewBar?.Invoke();
            }
            OnBeat?.Invoke();
            if (lastMainIndex == beats)
            {
                OnBeatLast?.Invoke();
            }
        }
        else // Next Off Beat
        {
            OffBeat?.Invoke();
            if (lastOffIndex == offBeats /* && lastMainIndex == beats*/)
            {
                OffBeatLast?.Invoke();
            }
        }
    }
示例#8
0
 /// <summary>
 /// Event called when the metronome beats.
 /// </summary>
 private void OnMetronomeBeat()
 {
     OnBeat?.Invoke();
 }
 public void AddBeatListener(OnBeat onBeatFunc, int index = 0)
 {
     _onBeatDelegates[index] += onBeatFunc;
 }
示例#10
0
 public void RemoveBeatListener(OnBeat onBeatFunc, int index = 0)
 {
     _onBeatDelegates[index] -= onBeatFunc;
 }
示例#11
0
 public void AddSubBeatCallback(OnBeat callback)
 {
     onSubBeat += callback;
 }
示例#12
0
 public void AddStrongBeatCallback(OnBeat callback)
 {
     onStrongBeat += callback;
 }
示例#13
0
 public void RemoveBeatListener(OnBeat onBeatFunc, int index = 0)
 {
     _onBeatDelegates[index] -= onBeatFunc;
 }
示例#14
0
 public void AddBeatListener(OnBeat onBeatFunc, int index = 0)
 {
     _onBeatDelegates[index] += onBeatFunc;
 }
示例#15
0
 public static void CallOnbeat()
 {
     OnBeat?.Invoke();
 }