Пример #1
0
 private void Update()
 {
     if (Time.time >= NextBeat)
     {
         Beat?.Invoke();
     }
 }
Пример #2
0
 void Update()
 {
     if (_audioSoruce.isPlaying && _song.CheckBeat())
     {
         _beatNumber++;
         Beat?.Invoke(_beatNumber);
     }
 }
Пример #3
0
    IEnumerator beat()
    {
        yield return(new WaitForSecondsRealtime(delay));

        while (true)
        {
            yield return(new WaitForSecondsRealtime(beatTime));

            Beat?.Invoke();
        }
    }
Пример #4
0
        IEnumerator Counter()
        {
            var i = 1;

            ElapsedTime = 0;
            var iniTime = 0f;

            while (true)
            {
                if (!_canPlay)
                {
                    i           = 0;
                    TotalBeats  = 0;
                    ElapsedTime = 0;
                    yield return(null);

                    iniTime = Time.time;
                    continue;
                }

                var lastTime = ElapsedTime;
                _t = 0f;

                while (_t <= 60f / Bpm)
                {
                    yield return(null);

                    var delta = ElapsedTime - lastTime;
                    lastTime = ElapsedTime;
                    _t      += delta;
                }

                TotalBeats++;
                //ElapsedTime = TotalBeats * (60f / Bpm);

                Beat?.Invoke(i);

                foreach (var action in _routineBeat)
                {
                    StartCoroutine(action(i));
                }

                i = (i + 1) % Tempo;
            }
        }
Пример #5
0
    private void Update()
    {
        if (ended)
        {
            if (!audioSource.isPlaying)
            {
                audioSource.Stop();
                SceneManager.LoadScene("Menu");
            }
        }
        else
        {
            if (started)
            {
                elapsedTime       = audioSource.time + extraTime;
                elapsedNormalTime = (float)normalSecondsBetweenBeats * beatCounter;
                elapsedFastTime   = (float)fastSecondsBetweenBeats * fastBeatCounter;

                CheckRange();

                if (elapsedTime >= elapsedNormalTime + elapsedFastTime - 0.3d + 0.04d && elapsedTime < elapsedNormalTime + elapsedFastTime + 0.04d)
                {
                    currentlyInBeat = true;
                    postBeatInvoked = false;

                    if (earlyBeat != null)
                    {
                        earlyBeat.Invoke();
                    }
                }
                else if (elapsedTime >= elapsedNormalTime + elapsedFastTime + 0.04d /*&& elapsedTime <= elapsedNormalTime + elapsedFastTime + 0.05d + 0.033d*/)
                {
                    BeatCount();
                    BeatAnim();

                    Instantiate(beatTick, GameObject.Find("BeatCounter").transform).GetComponent <BeatTick>().direction = 1;
                    Transform leftBeatTick = Instantiate(beatTick, GameObject.Find("BeatCounter").transform).transform;
                    leftBeatTick.GetComponent <BeatTick>().direction = -1;
                    leftBeatTick.position = new Vector2(Screen.width, leftBeatTick.position.y);

                    if (beat != null)
                    {
                        beat.Invoke();
                    }
                }
                else if (elapsedTime > normalSecondsBetweenBeats * (beatCounter - 1) + fastSecondsBetweenBeats * (fastBeatCounter - 1) + 0.04d && elapsedTime <= normalSecondsBetweenBeats * (beatCounter - 1) + fastSecondsBetweenBeats * (fastBeatCounter - 1) + 0.3d + 0.04d)
                {
                    if (lateBeat != null)
                    {
                        lateBeat.Invoke();
                    }
                }
                else
                {
                    if (!postBeatInvoked)
                    {
                        postBeatInvoked = true;
                        postBeat.Invoke();
                        PostBeat();
                    }
                }
            }
        }
    }
Пример #6
0
 private void Tick(object state)
 => Beat?.Invoke(this, new HeartbeatEventArgs(BeatCycleTimeMillis, ++CurrentBeat));
Пример #7
0
 protected virtual void OnBeat(MetronomeEventArgs e)
 {
     //Console.WriteLine(currentBar + "/" + currentBeat);
     label_beat.Text = (e.BeatNumber + 1).ToString() + "/" + numericUpDown_metronomeMeasuse.Value.ToString();
     Beat?.Invoke(this, e);
 }
Пример #8
0
 protected virtual void OnBeat()
 {
     Beat?.Invoke(this, EventArgs.Empty);
 }
Пример #9
0
 protected virtual void OnBeat(SongSynchronizer sender)
 {
     Beat?.Invoke(sender, EventArgs.Empty);
 }