Sprint 4
This commit is contained in:
102
Assets/SpellingBee/Scripts/SpellingBeeGameEndedPanel.cs
Normal file
102
Assets/SpellingBee/Scripts/SpellingBeeGameEndedPanel.cs
Normal file
@@ -0,0 +1,102 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class SpellingBeeGameEndedPanel : AbstractGameEndedPanel
|
||||
{
|
||||
/// <summary>
|
||||
/// Tell the scoreboard that the scoreboard is for SpellingBee
|
||||
/// </summary>
|
||||
protected override MinigameIndex minigameIndex
|
||||
{
|
||||
get { return MinigameIndex.SPELLING_BEE; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// "VERLOREN" or "GEWONNEN"
|
||||
/// </summary>
|
||||
public TMP_Text endText;
|
||||
|
||||
/// <summary>
|
||||
/// LPM
|
||||
/// </summary>
|
||||
public TMP_Text lpmText;
|
||||
|
||||
/// <summary>
|
||||
/// Letters ( right | wrong )
|
||||
/// </summary>
|
||||
public TMP_Text lettersRightText;
|
||||
public TMP_Text lettersWrongText;
|
||||
|
||||
/// <summary>
|
||||
/// Letters
|
||||
/// </summary>
|
||||
public TMP_Text lettersTotalText;
|
||||
|
||||
/// <summary>
|
||||
/// Accuracy
|
||||
/// </summary>
|
||||
public TMP_Text accuracyText;
|
||||
|
||||
/// <summary>
|
||||
/// Words
|
||||
/// </summary>
|
||||
public TMP_Text wordsText;
|
||||
|
||||
/// <summary>
|
||||
/// Time
|
||||
/// </summary>
|
||||
public TMP_Text timeText;
|
||||
|
||||
/// <summary>
|
||||
/// Score
|
||||
/// </summary>
|
||||
public TMP_Text scoreText;
|
||||
|
||||
/// <summary>
|
||||
/// Generate the content of the GameEnded panel
|
||||
/// </summary>
|
||||
/// <param name="startTime">Time of starting the minigame</param>
|
||||
/// <param name="totalWords">Total number of words</param>
|
||||
/// <param name="correctLetters">Total number of correctly spelled letters</param>
|
||||
/// <param name="incorrectLetters">Total number of incorrectly spelled letters</param>
|
||||
/// <param name="result">"VERLOREN" or "GEWONNEN"</param>
|
||||
/// <param name="score">Final score</param>
|
||||
public void GenerateContent(DateTime startTime, int totalWords, int correctLetters, int incorrectLetters, string result, int score)
|
||||
{
|
||||
// Final result
|
||||
endText.text = result;
|
||||
|
||||
// LPM
|
||||
TimeSpan duration = DateTime.Now.Subtract(startTime);
|
||||
lpmText.text = (60f * correctLetters / duration.TotalSeconds).ToString("#") + " LPM";
|
||||
|
||||
// Letters ( right | wrong ) total
|
||||
lettersRightText.text = correctLetters.ToString();
|
||||
lettersWrongText.text = incorrectLetters.ToString();
|
||||
lettersTotalText.text = (correctLetters + incorrectLetters).ToString();
|
||||
|
||||
// Accuracy
|
||||
if (correctLetters + incorrectLetters > 0)
|
||||
{
|
||||
accuracyText.text = ((correctLetters) * 100f / (correctLetters + incorrectLetters)).ToString("#.##") + "%";
|
||||
}
|
||||
else
|
||||
{
|
||||
accuracyText.text = "-";
|
||||
}
|
||||
|
||||
// Words
|
||||
wordsText.text = $"{totalWords}";
|
||||
|
||||
// Time
|
||||
timeText.text = duration.ToString(@"mm\:ss");
|
||||
|
||||
// Score
|
||||
scoreText.text = $"Score: {score}";
|
||||
SetScoreBoard();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user