diff --git a/Assets/__Scripts/UI/AnswerButton.cs b/Assets/__Scripts/UI/AnswerButton.cs index d758cc3..80642ae 100644 --- a/Assets/__Scripts/UI/AnswerButton.cs +++ b/Assets/__Scripts/UI/AnswerButton.cs @@ -31,6 +31,9 @@ public class AnswerButton : MonoBehaviour private SoundController sc; private List answerButtons; + public Answer AnswerValue => answerValue; + public bool IsDisabled => isDisabled; + void Start() { gc = FindObjectOfType(); diff --git a/Assets/__Scripts/UI/LifelinesUI.cs b/Assets/__Scripts/UI/LifelinesUI.cs index 30c5c8f..202f950 100644 --- a/Assets/__Scripts/UI/LifelinesUI.cs +++ b/Assets/__Scripts/UI/LifelinesUI.cs @@ -1,5 +1,6 @@ using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; using UnityEngine.UI; using OpenTDB; @@ -121,7 +122,19 @@ private string GetLifelineAnswer() } else { - return Enum.RandomValue().ToString(); + // Get a random (and not disabled) answer + var buttons = FindObjectsOfType(); + + do + { + Answer value = Enum.RandomValue(); + AnswerButton button = buttons.First(b => b.AnswerValue == value); + + if (!button.IsDisabled) + { + return value.ToString(); + } + } while (true); } }