Skip to content

Commit

Permalink
Remove foreach loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexciao committed Nov 25, 2022
1 parent 27863c0 commit 17af40a
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions Assets/Scripts/Score/GuessManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,15 @@ public void UpdateGuesses()
{
rightGuess = Random.Range(0, _guessButtons.Length);

foreach (GameObject guessButton in _guessButtons)
{
guessButton.GetComponentInChildren<TextMeshProUGUI>().text = "";
}

for (int i = 0; i < _guessButtons.Length; i++)
{
if (i != rightGuess)
if (i == rightGuess)
{
_guessButtons[i].GetComponentInChildren<TextMeshProUGUI>().text = _jsonManager.table.elements[Random.Range(0, _jsonManager.table.elements.Count)].symbol;
_guessButtons[i].GetComponentInChildren<TextMeshProUGUI>().text = _jsonManager._rElement.symbol;
}
else
{
_guessButtons[i].GetComponentInChildren<TextMeshProUGUI>().text = _jsonManager._rElement.symbol;
_guessButtons[i].GetComponentInChildren<TextMeshProUGUI>().text = _jsonManager.table.elements[Random.Range(0, _jsonManager.table.elements.Count)].symbol;
}
}
}
Expand Down

0 comments on commit 17af40a

Please sign in to comment.