public Typeface Read(Stream stream) { var little = BitConverter.IsLittleEndian; using (BinaryReader input = new ByteOrderSwappingBinaryReader(stream)) { UInt32 version = input.ReadUInt32(); UInt16 tableCount = input.ReadUInt16(); UInt16 searchRange = input.ReadUInt16(); UInt16 entrySelector = input.ReadUInt16(); UInt16 rangeShift = input.ReadUInt16(); var tables = new List <TableEntry>(tableCount); for (int i = 0; i < tableCount; i++) { tables.Add(TableEntry.ReadFrom(input)); } var header = Head.From(FindTable(tables, "head")); var maximumProfile = MaxProfile.From(FindTable(tables, "maxp")); var glyphLocations = new GlyphLocations(FindTable(tables, "loca"), maximumProfile.GlyphCount, header.WideGlyphLocations); var glyphs = Glyf.From(FindTable(tables, "glyf"), glyphLocations); var cmaps = CmapReader.From(FindTable(tables, "cmap")); var horizontalHeader = HorizontalHeader.From(FindTable(tables, "hhea")); var metricsTable = MetricsTable.From(FindTable(tables, "OS/2")); var horizontalMetrics = HorizontalMetrics.From(FindTable(tables, "hmtx"), horizontalHeader.HorizontalMetricsCount, maximumProfile.GlyphCount); return(new Typeface(header.Bounds, header.UnitsPerEm, metricsTable.LineSpacing, glyphs, cmaps, horizontalMetrics)); } }
internal void GameFinished(int lapsedSeconds, MetricsTable metricsTable) { currentMetric.SetLapsedSeconds(lapsedSeconds); CalculateFinalScore(currentMetric, metricsTable); CalculeteStars(currentMetric); SaveMetric(currentMetric); }
public void GameFinished(MetricsTable metricsTable) { Timer.GetTimer().FinishTimer(); //metricsModel.GameFinished(Timer.GetTimer().GetLapsedSeconds(), minSeconds, pointsPerSecond, pointsPerError); metricsModel.GameFinished(Timer.GetTimer().GetLapsedSeconds(), metricsTable); saveToDisk(); }
public void EndGame(MetricsTable metricsTable) { MetricsController.GetController().GameFinished(metricsTable); ViewController.GetController().LoadLevelCompleted(); }
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); }