Beispiel #1
0
    public WordScramblePatch(BombComponent bombComponent) : base(bombComponent)
    {
        componentType    = componentType ?? (componentType = ReflectionHelper.FindType("WordScrambleModule"));
        AnswerField      = AnswerField ?? (AnswerField = componentType.GetField("Answer", BindingFlags.NonPublic | BindingFlags.Instance));
        SolutionField    = SolutionField ?? (SolutionField = componentType.GetField("_solution", BindingFlags.NonPublic | BindingFlags.Instance));
        EnterButtonField = EnterButtonField ?? (EnterButtonField = componentType.GetField("EnterButton", BindingFlags.Public | BindingFlags.Instance));

        component = bombComponent.GetComponent(componentType);
        if (AnswerField == null || SolutionField == null || EnterButtonField == null)
        {
            return;
        }

        if ((string)SolutionField.GetValue(component) == "sapper")
        {
            var enterButton         = (KMSelectable)EnterButtonField.GetValue(component);
            var previousInteraction = enterButton.OnInteract;
            enterButton.OnInteract = () =>
            {
                if ((string)AnswerField.GetValue(component) == "papers")
                {
                    SolutionField.SetValue(component, "papers");
                }

                previousInteraction();

                return(false);
            };
        }
    }
Beispiel #2
0
 public void resetAllButtons(AnswerField answerField)
 {
     foreach (AnswerField af in this.answerFieldList)
     {
         if (af.Index != answerField.Index)
         {
             af.GetComponent <Toggle>().isOn = false;
         }
     }
 }
Beispiel #3
0
    public void RenderScreen(Exam exam)
    {
        answerFieldList.Clear();
        answerCheck = 0;
        Query query = exam.getCurrentQuery();

        for (int i = 0; i < query.Answers.Length; i++)
        {
            Answer answer = query.Answers[i];

            if (answer.IsCorrect)
            {
                answerCheck |= 1 << i;
            }

            GameObject    go            = GameObject.Instantiate(answerFieldPrefab.gameObject, answerArea);
            RectTransform rectTransform = go.GetComponent <RectTransform>();
            AnswerField   answerField   = go.GetComponent <AnswerField>();

            rectTransform.localPosition = rectTransform.localPosition - new Vector3(0, rectTransform.rect.height * i);
            answerField.Index           = i;
            answerField.Answer          = answer;
            answerField.AnswerType      = query.Type;
            Toggle toggle = answerField.GetComponent <Toggle>();
            toggle.onValueChanged.AddListener(delegate {
                AnswerField af = toggle.gameObject.GetComponent <AnswerField>();
                if (af.AnswerType == QueryType.CLOSED_SINGLE && toggle.isOn)
                {
                    resetAllButtons(af);
                }

                if (toggle.isOn)
                {
                    itemsCheck |= 1 << af.Index;
                }
                else
                {
                    itemsCheck &= ~(1 << af.Index);
                }
                if (itemsCheck > 0)
                {
                    btnCheckAndContinue.SetActive(true);
                }
                else
                {
                    btnCheckAndContinue.SetActive(false);
                }
            });

            answerFieldList.Add(answerField);
        }

        situationField.text = query.Situation;
        questionField.text  = query.Question;
    }
Beispiel #4
0
        void Update()
        {
            if (_counter >= 1)
            {
                question.text = ("Have no more attempts!");
                AnswerField.SetActive(false);
            }

            CountOfKills.text = ("Destroyed bots : " + Spawnedbothp.Countofkilled);
            TotalScore.text   = ("Total score : " + LocalScoringByDifficulty.Currently_score.ToString("F2"));
        }