コード例 #1
0
        public uint GetCappedLengthForPos(uint pos)
        {
            uint newLength = length;

            if (pos > tick)
            {
                newLength = pos - tick;
            }
            else
            {
                newLength = 0;
            }

            Starpower nextSp = null;

            if (song != null && chart != null)
            {
                int arrayPos = SongObjectHelper.FindClosestPosition(this, chart.starPower);
                if (arrayPos == SongObjectHelper.NOTFOUND)
                {
                    return(newLength);
                }

                while (arrayPos < chart.starPower.Count - 1 && chart.starPower[arrayPos].tick <= tick)
                {
                    ++arrayPos;
                }

                if (chart.starPower[arrayPos].tick > tick)
                {
                    nextSp = chart.starPower[arrayPos];
                }

                if (nextSp != null)
                {
                    // Cap sustain length
                    if (nextSp.tick < tick)
                    {
                        newLength = 0;
                    }
                    else if (pos > nextSp.tick)
                    {
                        // Cap sustain
                        newLength = nextSp.tick - tick;
                    }
                }
                // else it's the only starpower or it's the last starpower
            }

            return(newLength);
        }
コード例 #2
0
        /// <summary>
        /// Converts a tick position into the time it will appear in the song.
        /// </summary>
        /// <param name="position">Tick position.</param>
        /// <param name="resolution">Ticks per beat, usually provided from the resolution song of a Song class.</param>
        /// <returns>Returns the time in seconds.</returns>
        public float TickToTime(uint position, float resolution)
        {
            int previousBPMPos = SongObjectHelper.FindClosestPosition(position, bpms);

            if (bpms[previousBPMPos].tick > position)
            {
                --previousBPMPos;
            }

            BPM   prevBPM = bpms[previousBPMPos];
            float time    = prevBPM.assignedTime;

            time += (float)TickFunctions.DisToTime(prevBPM.tick, position, resolution, prevBPM.value / 1000.0f);

            return(time);
        }