protected override void BuildQuiz() { base.BuildQuiz(); affirmationsPositions = new List <Vector2>(); List <string> answers = new List <string>(sortedAnswers); switch (EstadoDoJogo.Instance.Metodologia.nome) { case "Aprendizagem Baseada em Problemas": upperScore = abpUpperScore; middleScore = abpMiddleScore; lowerScore = abpLowerScore; break; case "Sala de Aula Invertida": upperScore = saiUpperScore; middleScore = saiMiddleScore; lowerScore = saiLowerScore; break; case "Aprendizagem Baseada em Projetos": upperScore = abprojUpperScore; middleScore = abprojMiddleScore; lowerScore = abprojLowerScore; break; default: Debug.LogError("Metodologia não selecionada"); break; } for (int i = 0; i < draggables.Count; i++) { draggables[i].canvas = canvas; } for (int i = 0; i < affirmations.Count; i++) { if (i < maxAffirmations) { affirmations[i].text.text = answers[Random.Range(0, answers.Count)]; affirmations[i].correctPosition = sortedAnswers.IndexOf(affirmations[i].text.text); answers.Remove(affirmations[i].text.text); affirmationsPositions.Add(affirmations[i].GetComponent <RectTransform>().anchoredPosition); } else { AffirmationSorted affirmation = affirmations[i]; affirmations.Remove(affirmation); Destroy(affirmation.gameObject); } } }
public void NotifyDrag(AffirmationSorted affirmation) { int oldIndex = affirmations.IndexOf(affirmation); RectTransform affirmationRect = affirmation.GetComponent <RectTransform>(); for (int i = 0; i < affirmations.Count; ++i) { if (affirmationRect.anchoredPosition.y > affirmationsPositions[i].y) { if (oldIndex != i) { affirmations.Remove(affirmation); affirmations.Insert(i, affirmation); int startIndex = i < oldIndex ? i : oldIndex; for (int j = startIndex; j < affirmations.Count; j++) { RectTransform modifiedAffirmationRect = affirmations[j].GetComponent <RectTransform>(); modifiedAffirmationRect.anchoredPosition = affirmationsPositions[j]; affirmations[j].lockedPosition = modifiedAffirmationRect.anchoredPosition; } } else { affirmationRect.anchoredPosition = affirmation.lockedPosition; } return; } } affirmationRect.anchoredPosition = affirmation.lockedPosition; }