Sprint 4
This commit is contained in:
93
Assets/Hangman/Scripts/HangmanGameEndedPanel.cs
Normal file
93
Assets/Hangman/Scripts/HangmanGameEndedPanel.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
/// <summary>
|
||||
/// The hangman-variant of the ScoreBoard
|
||||
/// </summary>
|
||||
public class HangmanGameEndedPanel : AbstractGameEndedPanel
|
||||
{
|
||||
/// <summary>
|
||||
/// Tell the scoreboard that the scoreboard is for HangMan
|
||||
/// </summary>
|
||||
protected override MinigameIndex minigameIndex
|
||||
{
|
||||
get { return MinigameIndex.HANGMAN; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// "VERLOREN" or "GEWONNEN"
|
||||
/// </summary>
|
||||
public TMP_Text endText;
|
||||
|
||||
/// <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>
|
||||
/// Word that needed to be guessed
|
||||
/// </summary>
|
||||
public TMP_Text wordText;
|
||||
|
||||
/// <summary>
|
||||
/// Score
|
||||
/// </summary>
|
||||
public TMP_Text scoreText;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the end result image
|
||||
/// </summary>
|
||||
public Image image;
|
||||
|
||||
/// <summary>
|
||||
/// Generate the content of the GameEnded panel
|
||||
/// </summary>
|
||||
/// <param name="guessWord">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="sprite">Sprite to be displayed alongside the final score</param>
|
||||
/// <param name="result">"VERLOREN" or "GEWONNEN"</param>
|
||||
/// <param name="score">Final score</param>
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user