Пример #1
0
        public float CalcScoreWindow(float startTime, float endTime)
        {
            float         score        = 0f;
            DialInputData lastInput    = new DialInputData();
            bool          bRecordScore = false;

            foreach (DialInputData input in DialInputs)
            {
                if (input.TimeSeconds > endTime)
                {
                    if (!bRecordScore)
                    {
                        score = (endTime - startTime) * lastInput.DialScore;
                    }
                    else
                    {
                        score += (endTime - lastInput.TimeSeconds) * lastInput.DialScore;
                    }

                    bRecordScore = false;

                    break;
                }
                else if (!bRecordScore && input.TimeSeconds > startTime)
                {
                    bRecordScore = true;

                    score += (input.TimeSeconds - startTime) * lastInput.DialScore;
                }
                else if (bRecordScore)
                {
                    score += (input.TimeSeconds - lastInput.TimeSeconds) * lastInput.DialScore;
                }

                lastInput = input;
            }

            // Get any remaining time after the final input
            if (bRecordScore)
            {
                score += (endTime - lastInput.TimeSeconds) * lastInput.DialScore;
            }

            return(score);
        }
Пример #2
0
        public float GetTotalScore(float routineLengthSeconds)
        {
            float total = 0f;

            for (int i = 0; i < DialInputs.Count - 1; ++i)
            {
                DialInputData first  = DialInputs[i];
                DialInputData second = DialInputs[i + 1];

                float timeDelta = second.TimeSeconds - first.TimeSeconds;

                total += timeDelta * first.DialScore;
            }

            // Finsihed routines have an event at the end, so this if is only for in progress calculations
            if (routineLengthSeconds > 0f && DialInputs.Count > 0)
            {
                DialInputData last = DialInputs.Last();

                total += (routineLengthSeconds - last.TimeSeconds) * last.DialScore;
            }

            return(total);
        }