Resolve WES-144 "Feedback justsign"
This commit is contained in:
@@ -14,7 +14,7 @@ public class HangmanController : AbstractFeedback
|
||||
/// The scriptable with all the themes, will be used to select a random word for hangman.
|
||||
/// The spellingthemeList will be used for the words.
|
||||
/// </summary>
|
||||
public ThemeList themelist;
|
||||
public ThemeList themeList;
|
||||
|
||||
/// <summary>
|
||||
/// reference to the fingerspelling-theme to reach the letter-thresholds
|
||||
@@ -86,6 +86,16 @@ public class HangmanController : AbstractFeedback
|
||||
/// </summary>
|
||||
public GameObject inputPanel;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to display the score
|
||||
/// </summary>
|
||||
public TMP_Text scoreDisplay;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to display the points lost/won
|
||||
/// </summary>
|
||||
public TMP_Text scoreBonus;
|
||||
|
||||
///// <summary>
|
||||
///// This panel holds the panels for input and playing the game, sharing webcam and feedback
|
||||
///// </summary>
|
||||
@@ -171,7 +181,7 @@ public class HangmanController : AbstractFeedback
|
||||
/// <summary>
|
||||
/// Holds the time which the user needs to hold the sign for, for it to be accepted.
|
||||
/// </summary>
|
||||
private float maxTime = 1f;
|
||||
private float maxTime = 0.3f;
|
||||
|
||||
/// <summary>
|
||||
/// Holds the current amount of time the user has held their sign for
|
||||
@@ -208,8 +218,26 @@ public class HangmanController : AbstractFeedback
|
||||
/// </summary>
|
||||
public const int MAX_EXC_WORD_LENGHT = 17;
|
||||
|
||||
/// <summary>
|
||||
/// Number of fails before the game ends
|
||||
/// </summary>
|
||||
public const int NUMBER_OF_FAILS_BEFORE_GAMEOVER = 7;
|
||||
|
||||
/// <summary>
|
||||
/// Score obtained when guessing a correct letter
|
||||
/// </summary>
|
||||
private int correctLetterScore = 10;
|
||||
|
||||
/// <summary>
|
||||
/// Score obtained when guessing an incorrect letter
|
||||
/// </summary>
|
||||
private int incorrectLetterScore = -5;
|
||||
|
||||
/// <summary>
|
||||
/// Score obtained when guessing the entire word
|
||||
/// </summary>
|
||||
private int winScore = 25;
|
||||
|
||||
/// <summary>
|
||||
/// Start is called before the first frame update
|
||||
/// </summary>
|
||||
@@ -293,6 +321,9 @@ public class HangmanController : AbstractFeedback
|
||||
DisplayWord(currentWord);
|
||||
ChangeSprite();
|
||||
|
||||
scoreDisplay.text = $"Score: {CalculateScore()}";
|
||||
scoreBonus.text = "";
|
||||
|
||||
// Temporary
|
||||
//timer.SetActive(true);
|
||||
}
|
||||
@@ -353,15 +384,15 @@ public class HangmanController : AbstractFeedback
|
||||
// Then get a random index for a word to pull
|
||||
|
||||
// First get random index for the themes
|
||||
int amountThemes = themelist.themes.Count;
|
||||
int amountThemes = themeList.themes.Count;
|
||||
int themeIndex = Random.Range(0, amountThemes);
|
||||
|
||||
// Check how many words are in this theme
|
||||
int amountWords = themelist.themes[themeIndex].learnables.Count;
|
||||
int amountWords = themeList.themes[themeIndex].learnables.Count;
|
||||
int wordIndex = Random.Range(0, amountWords);
|
||||
|
||||
// Take the word, but lowercase it.
|
||||
currentWord = themelist.themes[themeIndex].learnables[wordIndex].name.ToUpper();
|
||||
currentWord = themeList.themes[themeIndex].learnables[wordIndex].name.ToUpper();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -447,9 +478,8 @@ public class HangmanController : AbstractFeedback
|
||||
case 2: // Sign your letter
|
||||
if (!guesses.Contains(currentSign))
|
||||
{
|
||||
confirmPanel.SetActive(true);
|
||||
confirmText.text = $"Letter '{currentSign.ToUpper()}' ?";
|
||||
mode = 3;
|
||||
ConfirmAccept();
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -477,9 +507,6 @@ public class HangmanController : AbstractFeedback
|
||||
// The guess was wrong, the wrongs integer needs to be incremented
|
||||
wrongs++;
|
||||
|
||||
// For now, we will loop back to stage zero after we reach the losing stage 10
|
||||
//wrongs = wrongs % NUMBER_OF_FAILS_BEFORE_GAMEOVER;
|
||||
|
||||
// Afterwards, the next stage needs to be displayed
|
||||
ChangeSprite();
|
||||
}
|
||||
@@ -533,6 +560,10 @@ public class HangmanController : AbstractFeedback
|
||||
|
||||
// Set the new sprite as the Image component's source image
|
||||
hangmanImage.sprite = sprite;
|
||||
|
||||
scoreDisplay.text = $"Score: {CalculateScore()}";
|
||||
scoreBonus.text = $"{incorrectLetterScore}";
|
||||
scoreBonus.color = new Color(0xf5 / 255.0f, 0x49 / 255.0f, 0x3d / 255.0f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -541,6 +572,8 @@ public class HangmanController : AbstractFeedback
|
||||
/// <param name="c">The letter that needs to be updated</param>
|
||||
private void UpdateWord(string c)
|
||||
{
|
||||
int hits = 0;
|
||||
|
||||
for (int i = 0; i < currentWord.Length; i++)
|
||||
{
|
||||
if (currentWord[i] == c[0])
|
||||
@@ -553,21 +586,23 @@ public class HangmanController : AbstractFeedback
|
||||
|
||||
// You correctly guessed a letter
|
||||
corrects++;
|
||||
hits++;
|
||||
}
|
||||
}
|
||||
|
||||
scoreDisplay.text = $"Score: {CalculateScore()}";
|
||||
scoreBonus.text = $"+{hits * correctLetterScore}";
|
||||
scoreBonus.color = new Color(0x8b / 255.0f, 0xd4 / 255.0f, 0x5e / 255.0f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function returns the score that the user currently has
|
||||
/// </summary>
|
||||
/// <returns>The current score of the user</returns>
|
||||
private int GetScore()
|
||||
private int CalculateScore()
|
||||
{
|
||||
// Scoring works as follows:
|
||||
// You get 3 points for each letter in the word that is correctly guessed (corrects * 3)
|
||||
// You get 9 points for each part of the hangman figure which is NOT displayed ((10 - wrongs) * 9)
|
||||
|
||||
return 3 * corrects + (MAX_EXC_WORD_LENGHT - wrongs) * 9;
|
||||
int won = corrects == currentWord.Length ? 1 : 0;
|
||||
return corrects * correctLetterScore + wrongs * incorrectLetterScore + winScore * won;
|
||||
}
|
||||
|
||||
// The following functions originate from Spellingbee
|
||||
@@ -610,7 +645,7 @@ public class HangmanController : AbstractFeedback
|
||||
private void SaveScores()
|
||||
{
|
||||
// Calculate new score
|
||||
int newScore = GetScore();
|
||||
int newScore = CalculateScore();
|
||||
// Save the score as a tuple: < int score, string time ago>
|
||||
Score score = new Score();
|
||||
score.scoreValue = newScore;
|
||||
@@ -653,7 +688,7 @@ public class HangmanController : AbstractFeedback
|
||||
incorrectLetters: wrongs,
|
||||
sprite: hangmanImage.sprite,
|
||||
result: "GEWONNEN",
|
||||
score: GetScore()
|
||||
score: CalculateScore()
|
||||
);
|
||||
|
||||
gameEndedPanel.SetActive(true);
|
||||
@@ -678,7 +713,7 @@ public class HangmanController : AbstractFeedback
|
||||
incorrectLetters: wrongs,
|
||||
sprite: hangmanImage.sprite,
|
||||
result: "VERLOREN",
|
||||
score: GetScore()
|
||||
score: CalculateScore()
|
||||
);
|
||||
|
||||
gameEndedPanel.SetActive(true);
|
||||
@@ -701,6 +736,15 @@ public class HangmanController : AbstractFeedback
|
||||
float accuracy = highestPrediction.Value;
|
||||
string predictedSign = highestPrediction.Key;
|
||||
|
||||
// vvv TEMPORARY STUFF vvv
|
||||
if (predictedSign == "J" && accuracy <= 0.965f)
|
||||
{
|
||||
highestPrediction = signPredictor.learnableProbabilities.Aggregate((x, y) => x.Value > y.Value && x.Key != "J" ? x : y);
|
||||
}
|
||||
accuracy = highestPrediction.Value;
|
||||
predictedSign = highestPrediction.Key;
|
||||
// ^^^ TEMPORARY STUFF ^^^
|
||||
|
||||
// Grab the threshold for the most probable letter
|
||||
Learnable letter = fingerSpelling.learnables.Find((l) => l.name == predictedSign);
|
||||
float threshold = letter.thresholdPercentage;
|
||||
@@ -746,7 +790,7 @@ public class HangmanController : AbstractFeedback
|
||||
previousSign = predictedSign;
|
||||
currentTime = 0;
|
||||
if ((mode == 1) ||
|
||||
(mode == 2 && !guesses.Contains(previousSign.ToLower())))
|
||||
(mode == 2 && !guesses.Contains(previousSign.ToUpper())))
|
||||
{
|
||||
runTime = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user