using System; using System.Collections.Generic; using System.Linq; using TMPro; using UnityEngine; using UnityEngine.UI; /// /// The hangman-variant of the ScoreBoard /// public class HangmanGameEndedPanel : AbstractGameEndedPanel { /// /// Tell the scoreboard that the scoreboard is for HangMan /// protected override MinigameIndex minigameIndex { get { return MinigameIndex.HANGMAN; } } /// /// "VERLOREN" or "GEWONNEN" /// public TMP_Text endText; /// /// Letters ( right | wrong ) /// public TMP_Text lettersRightText; public TMP_Text lettersWrongText; /// /// Letters /// public TMP_Text lettersTotalText; /// /// Accuracy /// public TMP_Text accuracyText; /// /// Word that needed to be guessed /// public TMP_Text wordText; /// /// Score /// public TMP_Text scoreText; /// /// Reference to the end result image /// public Image image; /// /// Generate the content of the GameEnded panel /// /// Total number of words /// Total number of correctly spelled letters /// Total number of incorrectly spelled letters /// Sprite to be displayed alongside the final score /// "VERLOREN" or "GEWONNEN" /// Final score public void GenerateContent(string guessWord, int correctLetters, int incorrectLetters, Sprite sprite, string result, int score) { // Final result endText.text = result; image.sprite = sprite; // 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 wordText.text = guessWord; // Score scoreText.text = $"Score: {score}"; SetScoreBoard(); } }