Ejemplo n.º 1
0
        private void UpdateBPM()
        {
            if (bpmInfos.Count - 1 > bpmInfoLastIndex)
            {
                BPMInfo nextInfo = bpmInfos[bpmInfoLastIndex + 1];
                float   barDiff  = GetBarDifference(bar, beat, nextInfo.bar, nextInfo.beat);
                if (barDiff >= 0.0f)
                {
                    float bpmDiffRatio = nextInfo.bpm / bpm;
                    float fixedBarDiff = barDiff * bpmDiffRatio;

                    bar  = nextInfo.bar;
                    beat = 0.0f;
                    if (nextInfo.beat > 0.0f)
                    {
                        ++bar;
                    }

                    beat += fixedBarDiff * GlobalDefines.BeatPerBar;
                    if (beat >= GlobalDefines.BeatPerBar)
                    {
                        bar += (int)beat / GlobalDefines.BeatPerBar;
                        beat = beat % (float)GlobalDefines.BeatPerBar;
                    }

                    isStopEffect = nextInfo.stopEffect;
                    CurrentBPM   = nextInfo.bpm;
                    position     = nextInfo.position + fixedBarDiff * barToRailLength;
                    ++bpmInfoLastIndex;
                    Debug.Log("" + barDiff + ", " + fixedBarDiff);
                }
            }
        }
Ejemplo n.º 2
0
 public float GetBPMWithBarBeat(int _bar, float _beat = 0.0f)
 {
     for (int i = bpmInfos.Count - 1; i >= 0; --i)
     {
         BPMInfo info         = bpmInfos[i];
         int     infoStartBar = (info.beat == 0.0f) ? info.bar : info.bar + 1;
         if (infoStartBar <= _bar)
         {
             return(info.bpm);
         }
     }
     return(60.0f);
 }
Ejemplo n.º 3
0
        public void AddNewBPMInfo(int _bar, float _beat, float _bpm, bool _stopEffect = false)
        {
            BPMInfo info = new BPMInfo()
            {
                bar        = _bar,
                beat       = _beat,
                bpm        = _bpm,
                stopEffect = _stopEffect
            };

            BPMInfo lastInfo = null;

            for (int i = 0; i <= bpmInfos.Count; ++i)
            {
                if (i == bpmInfos.Count)
                {
                    bpmInfos.Add(info);
                    break;
                }
                else
                {
                    lastInfo = bpmInfos[i];
                    if (GetBarDifference(_bar, _beat, lastInfo.bar, lastInfo.beat) < 0.0f)
                    {
                        bpmInfos.Insert(i, info);
                        break;
                    }
                }
            }

            if (bpmInfos.Count > 1 && lastInfo != null)
            {
                double pivotPos = lastInfo.position;
                if (lastInfo.stopEffect)
                {
                    info.position = pivotPos;
                }
                else
                {
                    int   lastInfoStartBar = (lastInfo.beat == 0.0f) ? lastInfo.bar : lastInfo.bar + 1;
                    float barDiff          = GetBarDifference(_bar, _beat, lastInfoStartBar, 0.0f);
                    info.position = pivotPos + (barDiff *
                                                (GlobalDefines.RailLength / GlobalDefines.DefaultBarCount * (lastInfo.bpm / 60.0f)));
                }
            }
            else
            {
                info.position = 0.0f;
            }
        }
Ejemplo n.º 4
0
        public double BarBeatToPosition(int _bar, float _beat = 0.0f)
        {
            for (int i = bpmInfos.Count - 1; i >= 0; --i)
            {
                BPMInfo info         = bpmInfos[i];
                int     infoStartBar = (info.beat == 0.0f) ? info.bar : info.bar + 1;
                if (infoStartBar <= _bar)
                {
                    if (info.stopEffect)
                    {
                        return(info.position);
                    }
                    else
                    {
                        return(info.position + GetBarDifference(_bar, _beat, infoStartBar, 0.0f) *
                               (GlobalDefines.RailLength / GlobalDefines.DefaultBarCount * (info.bpm / 60.0f)));
                    }
                }
            }

            return(0.0f);
        }