private void CalculateFinalScore(GameMetrics gameMetrics, MetricsTable metricsTable) { for (int i = 0; i < metricsTable.RangeMetricsInfos.Count; i++) { RangeMetricsInfo currentRangeMetricInfo = metricsTable.RangeMetricsInfos[i]; if (gameMetrics.GetWrongAnswers() <= currentRangeMetricInfo.MaxErrors && gameMetrics.GetLapsedSeconds() <= currentRangeMetricInfo.MaxTime) { Range range = (Range) (i); float deltaRange = (range.GetDelta() / (currentRangeMetricInfo.MaxErrors - currentRangeMetricInfo.MinErrors + 1)); float baseForErrorsQuantity = deltaRange * ( currentRangeMetricInfo.MaxErrors - gameMetrics.GetWrongAnswers()); float score = range.GetMinScore() + baseForErrorsQuantity; float bonusFromTime = 0; if (gameMetrics.GetLapsedSeconds() <= currentRangeMetricInfo.MaxTimeToBonus) { float secondsToSubtract = gameMetrics.GetLapsedSeconds() - metricsTable.FreeTime; bonusFromTime = deltaRange; if (secondsToSubtract > 0) { bonusFromTime -= secondsToSubtract*(deltaRange / currentRangeMetricInfo.MaxTimeToBonus); } } score += bonusFromTime; gameMetrics.SetScore(Mathf.RoundToInt(score)); gameMetrics.SetBonusTime(Mathf.RoundToInt(bonusFromTime)); gameMetrics.SetRange(range); return; } } gameMetrics.SetScore(500); gameMetrics.SetBonusTime(0); gameMetrics.SetRange(Range.Rookie); }
private void groupGames(List<GameMetrics> metrics) { int gruopSize = (int)Math.Ceiling((metrics.Count + 0.0f) / (MAX_COLUMNS + 0.0f)); this.note.text = gruopSize + (SettingsController.GetController().GetLanguage() == 0 ? " en " : " in ") + "1"; for(int i = 0; i < Math.Ceiling((metrics.Count + 0.0f) / (gruopSize + 0.0f)); i++) { List<GameMetrics> currentGroup = metrics.GetRange(i * gruopSize, (i * gruopSize + gruopSize) <= metrics.Count ? gruopSize : metrics.Count - metricsPoints.Count * gruopSize); GameMetrics currentMetric = new GameMetrics(currentGroup[0].GetArea(), currentGroup[0].GetIndex(), currentGroup[0].GetLevel()); currentMetric.SetDate(currentGroup[0].GetDate()); for(int j = 0; j < currentGroup.Count; j++) { currentMetric.SetScore(currentMetric.GetScore() + currentGroup[j].GetScore()); currentMetric.SetLapsedSeconds(currentMetric.GetLapsedSeconds() + currentGroup[j].GetLapsedSeconds()); currentMetric.SetRightAnswers(currentMetric.GetRightAnswers() + currentGroup[j].GetRightAnswers()); currentMetric.SetWrongAnswers(currentMetric.GetWrongAnswers() + currentGroup[j].GetWrongAnswers()); } currentMetric.SetScore(Average(currentMetric.GetScore(), currentGroup.Count)); currentMetric.SetLapsedSeconds(Average(currentMetric.GetLapsedSeconds(), currentGroup.Count)); currentMetric.SetRightAnswers(Average(currentMetric.GetRightAnswers(), currentGroup.Count)); currentMetric.SetWrongAnswers(Average(currentMetric.GetWrongAnswers(), currentGroup.Count)); metricsPoints.Add(currentMetric); } }
private void CalculateFinalScore(GameMetrics gameMetrics, int minSeconds, int pointsPerSecond, int pointsPerError) { gameMetrics.SetScore(MAX_SCORE - pointsPerSecond * (gameMetrics.GetLapsedSeconds() < minSeconds ? 0 : gameMetrics.GetLapsedSeconds() - minSeconds) - gameMetrics.GetWrongAnswers() * pointsPerError); if (gameMetrics.GetScore() < MIN_SCORE) gameMetrics.SetScore(MIN_SCORE); }