okay my problem is i have a QandA game and i created a 50/50 lifeline button which removes two of the wrong answers in the choices so my question is how to get it back after answering that question so i get the logic i need to add again but the problem is it keeps on adding everytime i answered correctly okay here’s the code hope you help me
private List<string[]> questions = new List<string[]>();
public List<int> answerOrder = new List<int>(new int[] {1,2,3,4});
void DrawInfo() { Rect rect = new Rect(500, 100, 400, 200);
Rect close = new Rect(10, 10, 200, 100);
if(GUI.Button(close, "Question")) {
PopUp = !PopUp;
}
if (PopUp) {
GUI.Box(rect, Info);
GUI.Label(new Rect(520, 110, 400, 30), questions[0][0]);
if (GUI.Button(new Rect(520, 200, 100, 30), questions[0][answerOrder[0]])) {
HandleAnswer(answerOrder[0]);
}
if (GUI.Button(new Rect(520, 250, 100, 30), questions[0][answerOrder[1]])) {
HandleAnswer(answerOrder[1]);
}
if (GUI.Button(new Rect(780, 200, 100, 30), questions[0][answerOrder[2]])) {
HandleAnswer(answerOrder[2]);
}
if (GUI.Button(new Rect(780, 250, 100, 30), questions[0][answerOrder[3]])) {
HandleAnswer(answerOrder[3]);
}
}
}
private void HandleAnswer(int answer) {
if (answer == 1) {
NextQuestion();
answerOrder.Add(3);
answerOrder.Add(2);
}
else {
}
}
void OnGUI() {
if (GUI.Button(new Rect(300, 250, 100, 30),"50/50")) {
answerOrder.Remove(3);
answerOrder.Remove(2);
}
if(questions.Count > 0) {
DrawInfo();
}
}
void Start() {
questions.Add(new string[] { "A series of curved bones that are articulated with the vertebrae and occur in pairs.", "Rib", "Radius", "Scapular", "Skull"});
questions.Add(new string[] { "What is the part of the skull that encloses the brain?", "Cranium", "Coccyx", "Carpals", "Clavicle" });
questions.Add(new string[] { "It is the bony skeleton of the head of vertebrates.", "Skull", "Face", "Ulna", "Tibia"});
questions.Add(new string[] { "What is the longest, and strongest bone in the human body that extends from the pelvis to the knee?", "Femur", "Fibula", "Metacarpals", "Humerus"});
questions.Add(new string[] { "Which of these is the bone of the fingers or toes?", "Phalanges", "Sacrum", "Scapular", "Carpals"});
questions.Add(new string[] { "It is the bones of the wrist.", "Carpals", "Clavicle", "Coccyx", "Cranium"});
Shuffle(questions);
Shuffle(answerOrder);
}
void NextQuestion() {
questions.RemoveAt(0);
Shuffle(answerOrder);
}
static readonly System.Random rng = new System.Random();
public static void Shuffle<T>(IList<T> list) {
int n = list.Count;
while(n > 1) {
n--;
int k = rng.Next(n + 1);
T value = list[k];
list[k] = list[n];
list[n] = value;
}
}
}