예제 #1
0
    /// <summary>
    /// 找到最近的谱面索引
    /// </summary>
    /// <returns></returns>
    public int GetNearestPlayerActionInfoIndex(int _iIndex)
    {
        SongInfo song         = m_musicManager.currentSongInfo;
        int      nearestIndex = 0;

        List <OnBeatActionInfo>           kBeatActionInfos = song.onBeatActionSequence[_iIndex];
        SequenceSeeker <OnBeatActionInfo> kSeeker          = m_kScoringUnitSeekers.GetSeeker(_iIndex);

        if (kSeeker.nextIndex == 0)//-如果目的位置是开头的话,没有前一个标记,所以不比较。
        {
            nearestIndex = 0;
        }
        else if (kSeeker.nextIndex >= kBeatActionInfos.Count)//-当前索引的位置比序列的尺寸大的时候(过了最后的标记时间的时候)应该不会大于
        {
            Debug.Assert(kSeeker.nextIndex > kBeatActionInfos.Count);
            nearestIndex = kBeatActionInfos.Count - 1;
        }
        else//与前后的定时相比较
        {
            OnBeatActionInfo crnt_action = kBeatActionInfos[kSeeker.nextIndex];//-当前位置
            OnBeatActionInfo prev_action = kBeatActionInfos[kSeeker.nextIndex - 1];                      //-前一个位置

            float act_timing = m_playerAction.GetLastActionInof(_iIndex).triggerBeatTiming;              //-玩家在哪个拍子按下的

            if (crnt_action.triggerBeatTiming - act_timing < act_timing - prev_action.triggerBeatTiming) //-如果是当前位置比较近
            {
                nearestIndex = kSeeker.nextIndex;
            }
            else//-如果是前一个位置比较近
            {
                nearestIndex = kSeeker.nextIndex - 1;
            }
        }

        return(nearestIndex);
    }
예제 #2
0
    /// <summary>
    /// Process the specified _iIndex.
    /// </summary>
    /// <returns>The process.</returns>
    /// <param name="_iIndex">I index.</param>
    void Process(int _iIndex)
    {
        float additionalTemper = 0;

#if false
        bool hitBefore = false;
        bool hitAfter  = false;
#endif

        SequenceSeeker <OnBeatActionInfo> kSeeker = m_kScoringUnitSeekers.GetSeeker(_iIndex);

        int      nearestIndex = GetNearestPlayerActionInfoIndex(_iIndex);
        SongInfo song         = m_musicManager.currentSongInfo;
        if (song.onBeatActionSequence[_iIndex] == null)
        {
            Debug.Log("Out of range : " + _iIndex);
        }
        if (nearestIndex >= song.onBeatActionSequence[_iIndex].Count)
        {
            //-Debug.Log("Out of range : " + nearestIndex + " >= " + song.onBeatActionSequence[_iIndex].Count);
            return;
        }
        OnBeatActionInfo marker_act = song.onBeatActionSequence[_iIndex][nearestIndex]; //-找到最近的谱面
        OnBeatActionInfo player_act = m_playerAction.GetLastActionInof(_iIndex);        //-找到玩家操作的信息

        bool bHit = false;
        if (marker_act.triggerBeatTiming <= m_musicManager.beatCountFromStart &&
            nearestIndex != m_previousHitIndex && DebugTest == true)
        {
            bHit = true;

            OnBeatActionInfo actionInfo = new OnBeatActionInfo();
            actionInfo.triggerBeatTiming = m_musicManager.beatCountFromStart;
            actionInfo.playerActionType  = PlayerActionEnum.Jump;
            player_act = actionInfo;
        }


        if (m_playerAction.GetCurrentPlayerAction(_iIndex)
            != PlayerActionEnum.None || bHit)//-如果这一拍玩家有操作???
        {
            m_lastResults[_iIndex].timingError = player_act.triggerBeatTiming
                                                 - marker_act.triggerBeatTiming;//-找到玩家操作的拍子和最近谱面时间的差值
            m_lastResults[_iIndex].markerIndex = nearestIndex;

            if (nearestIndex == m_previousHitIndex)//-如果已经判定过了,则扣分
            {
                m_fAdditionalScore = missScore;
                additionalTemper   = missHeatupRate;
            }
            else//-计算得分
            {
                m_fAdditionalScore = CheckScore(nearestIndex
                                                , m_lastResults[_iIndex].timingError
                                                , out additionalTemper);
            }

            if (m_fAdditionalScore > 0)//-得分
            {
                //-记录当前的索引,防止将相同的标记判定为两次
                m_previousHitIndex = nearestIndex;
#if false
                if (nearestIndex == kSeeker.nextIndex)//-判断当前按下的是前一个还是后一个
                {
                    hitAfter = true;
                }
                else
                {
                    hitBefore = true;
                }
#endif

                //增加分数的时候播放动画
                OnScoreAdded(_iIndex, nearestIndex);
            }

            m_fScore += m_fAdditionalScore;
            temper   += additionalTemper;
            m_onPlayGUI.RythmHitEffect(_iIndex
                                       , m_previousHitIndex
                                       , m_fAdditionalScore
                                       , m_fScore);

#if false
            //-记录日志
            DebugWriteLogPrev();
            DebugWriteLogPost(hitBefore, hitAfter);
#endif
        }

        if (kSeeker.nextIndex > 0)//-如果还没结束,计算得分率,用总分数,除以假设全部是最佳的得分
        {
            m_scoreRate = m_fScore / (kSeeker.nextIndex * excellentScore);
        }
    }