Exemplo n.º 1
0
    void InitQuestionUI(QuestionCard q)
    {
        centerImg.gameObject.SetActive(true);

        question.text = q.Question;

        for (int i = 0; i < q.Answers.Count; i++)
        {
            AnswerPanel p = panels[i];
            p.gameObject.SetActive(true);
            switch (countMode)

            {
            case CountMode.Numeric:
                p.AnswerNumber.text = numeric[i];
                break;

            case CountMode.Alphabetic:
                p.AnswerNumber.text = alphabetic[i];
                break;

            case CountMode.Roman:
                p.AnswerNumber.text = roman[i];
                break;

            default:
                p.AnswerNumber.text = numeric[i];
                break;
            }

            p.AnswerText.text = q.Answers[i];
        }

        centerImg.sprite = q.Image;
    }
Exemplo n.º 2
0
    void InitQuestionUI(QuestionCard q)
    {
        question.text = q.Question;
        for (int i = 0; i < q.Answers.Count; i++)
        {
            AnswerPanel p = panels[i];
            p.gameObject.SetActive(true);
            switch (countMode)
            {
            case CountMode.Numeric:
                p.AnswerNumber.text = numeric[i];
                break;

            case CountMode.Alphabetic:
                p.AnswerNumber.text = alphabetic[i];
                break;

            case CountMode.Roman:
                p.AnswerNumber.text = roman[i];
                break;

            default:
                p.AnswerNumber.text = numeric[i];
                break;
            }

            p.AnswerText.text = q.Answers[i];
            p.Bulb.GetComponent <MeshRenderer>().enabled = true;
            p.Bulb.GetComponent <MeshRenderer>().material.SetColor(emissionId, colorsDimm[i]);
        }
    }
Exemplo n.º 3
0
 private void OnAnswerClick(AnswerPanel answerPanel, bool isValid)
 {
     if (!_isWaiting)
     {
         return;
     }
     _isWaiting     = false;
     _isValidAnswer = isValid;
     answerPanel.SetColor(isValid ? validColor : invalidColor);
 }
Exemplo n.º 4
0
 public void SetPanelAnswer(GameObject panel, bool mul)
 {
     if (mul)
     {
         APMultiple = panel.GetComponent <AnswerPanel>();
     }
     else
     {
         APSingle = panel.GetComponent <AnswerPanel>();
     }
 }
Exemplo n.º 5
0
        private void FindButtonEx_Click(object sender, EventArgs e)
        {
            if (InputQuestEx.Text == "")
            {
                MessageBox.Show("Please input file First !");
            }
            else
            {
                matrixReady();
                string[] S = InputQuestEx.Text.Split('\\');
                X.inputFromFileQuestion(S[S.Length - 1]);
                Solution[] Solutions = new Solution[X.getinc2()];
                for (int i = 0; i < X.getinc2(); i++)
                {
                    Check    c = new Check();
                    Solution s = new Solution();
                    H.Trace(X.getquestion(i, 0), X.getquestion(i, 1), X.getquestion(i, 2), c, s);
                    if (c.getFound())
                    {
                        X.setQuestion(i, 3, 1);
                    }
                    else
                    {
                        X.setQuestion(i, 3, 0);
                        s.Add('-');
                    }
                    Solutions[i] = s;
                }
                for (int i = 0; i < X.getinc2(); i++)
                {
                    Ways.Text += i + 1 + " .";
                    for (int j = 0; j <= 2; j++)
                    {
                        Ways.Text += X.getquestion(i, j) + " ";
                    }
                    Ways.Text += " - ";
                    if (X.getquestion(i, 3) == 1)
                    {
                        Ways.Text += "YES, Route : ";
                        for (int j = 0; j < Solutions[i].getLength() - 1; j++)
                        {
                            Ways.Text += Solutions[i].getElement(j) + " - ";
                        }
                        Ways.Text += Solutions[i].getElement(Solutions[i].getLength() - 1) + "\n";
                    }
                    else
                    {
                        Ways.Text += "NO ROUTE MAN !\n";
                    }
                }

                AnswerPanel.BringToFront();
            }
        }
Exemplo n.º 6
0
        private void SetAnswerPanel(TcpSignalizationClient client)
        {
            client.OnNewPacketIncome -= client_OnNewPacketIncome;
            client.Send(SignalizationCommand.Ringing);
            isBusy = true;

            AnswerPanel answerPanel = new AnswerPanel(client);

            answerPanel.OnAnsweringResult += answerPanel_OnAnsweringResult;
            SetPanel(answerPanel);
        }
Exemplo n.º 7
0
    /// <summary>
    /// The Lamps glow for the set "glowTime" while reading the available Answers.
    /// The mesh filter changes from glowing to normal after the glowTime is finished.
    /// The User has the set time "answerTime" to think what the right answer is.
    /// The Lamp corresponding to the right answer glows up and the other Lamps and answers disappear (are disabled).
    /// </summary>
    /// <param name="q"></param>
    /// <returns></returns>
    IEnumerator AskQuestion(QuestionCard q)
    {
        InitQuestionUI(q);

        Vector3 cornerPosition = room.Corners[q.TrueAnswer];

        //highlight the answers
        for (int i = 0; i < q.Answers.Count; i++)
        {
            GameObject bulb = panels[i].Bulb;

            MeshFilter   mF = bulb.GetComponent <MeshFilter>();
            MeshRenderer mR = bulb.GetComponent <MeshRenderer>();
            mF.mesh = glowing;
            mR.material.SetColor(emissionId, colorsBright[i]);
            yield return(new WaitForSeconds(glowTime));

            mR.material.SetColor(emissionId, colorsDimm[i]);
            mF.mesh = normal;
        }

        countDownBar.enabled = true;
        yield return(timer.UITimer(answerTime, countDownMask, countDownText));

        Vector3 playerPosition = BodyDisplay.Instance.GetBodyPosition();

        if (BodyDisplay.Instance.GetBodyBoundingBox(out Bounds b))
        {
            if (b.IntersectXZCircle(cornerPosition, 1f))
            {
                Debug.Log("Correct");
            }
        }
        //TODO: Get the position of the player and compare it to the specified corner.

        countDownBar.enabled = false;

        for (int i = 0; i < q.Answers.Count; i++)
        {
            AnswerPanel p = panels[i];
            if (i != q.TrueAnswer)
            {
                p.gameObject.SetActive(false);
            }
            else
            {
                p.Bulb.GetComponent <MeshFilter>().mesh = glowing;
                p.Bulb.GetComponent <MeshRenderer>().material.SetColor(emissionId, colorsBright[i]);
            }
        }

        yield return(new WaitForSeconds(showCorrectAnswerTime));
    }
Exemplo n.º 8
0
 public void EnableMouse(bool TurnOn)
 {
     if (TurnOn)
     {
         FPC.enabled      = false;
         Cursor.visible   = true;
         Cursor.lockState = CursorLockMode.None;
     }
     else
     {
         FPC.enabled      = true;
         Cursor.visible   = false;
         Cursor.lockState = CursorLockMode.Locked;
         QuestionPanel.SetActive(false);
         AnswerPanel.SetActive(false);
     }
 }
Exemplo n.º 9
0
    // Update is called once per frame
    void Update()
    {
        float CloseDistance = 100000f;
        int   Subject       = 0;

        for (int i = 0; i < Triggers.Length; i++) // i = Counter.
        {
            float thisDistance = Vector3.Distance(Triggers[i].transform.position, Player.transform.position);
            // If current distance is less that close distance, then close distance will be the new current distance.
            if (thisDistance < CloseDistance)
            {
                CloseDistance = thisDistance;
                Subject       = i;
            }
        }
        // Checks if the Player enters the close distance of the Trigger box.
        if (CloseDistance < TriggerDistance)
        {
            if (!isUIDisplaying)
            {
                HintPanel.SetActive(true); // If the Player enters this TriggerDistance, then activate Hint Panel from Unity.

                if (Input.GetKey("e"))
                {
                    QsAs(Subject);              // Call the functions.
                    isUIDisplaying = true;      // Calls the boolean.
                    EnableMouse(true);          // Enable the mouse.
                    HintPanel.SetActive(false); // Disable the Hint Panel when the Player presses E.
                }
            }
        }
        // Otherwise, checks if the Player left the close distance.
        else
        {
            HintPanel.SetActive(false);

            if (isUIDisplaying)
            {
                QuestionPanel.SetActive(false);
                AnswerPanel.SetActive(false);
                isUIDisplaying = false;
                EnableMouse(false);
            }
        }
    }
Exemplo n.º 10
0
    public void As(int Rep)
    {
        QuestionPanel.SetActive(false);
        AnswerPanel.SetActive(true);
        switch (Rep)
        {
        case 0:
            Reply.text = Answers[Answer0];
            break;

        case 1:
            Reply.text = Answers[Answer1];
            break;

        case 2:
            Reply.text = Answers[Answer2];
            break;
        }
    }
Exemplo n.º 11
0
    protected override IEnumerator Execute()
    {
        room = RoomManager.Instance.LoadRoom();

        if (room == null)
        {
            yield break;
        }

        //get Questionary from json
        List <QuestionCard> questions = QuestionManager.Instance.GetQuestions(questionAmount);

        Debug.Log("before trim: " + questions[0].ToString());
        QuestionManager.Instance.TrimQuestions(questions, answerAmount, true);
        Debug.Log("after trim: " + questions[0].ToString());

        panels = new AnswerPanel[answerAmount];

        for (int i = 0; i < panels.Length; i++)
        {
            GameObject p = Instantiate(panel);
            p.transform.SetParent(panelHolder.transform, false);
            AnswerPanel a = p.GetComponent <AnswerPanel>();
            a.Bulb.GetComponent <MeshRenderer>().material = GetMaterial(colorsDimm[i]);
            panels[i] = a;
        }
        //List<QuestionCard> questions = QuestionManager.Instance.TrimQuestions(questionSet, 4, true);

        while (questions.Count > 0)
        {
            QuestionCard q = questions[Random.Range(0, questions.Count)];

            yield return(StartCoroutine(AskQuestion(q)));

            questions.Remove(q);
        }

        yield return(new WaitForSeconds(3));

        ClearQuestionUI();
    }
Exemplo n.º 12
0
 public void GoBack(int X)
 {
     QuestionPanel.SetActive(true);
     AnswerPanel.SetActive(false);
 }
Exemplo n.º 13
0
 private void FindButtonNonEx_Click(object sender, EventArgs e)
 {
     //InputNonEx.Text = "Plis muncul";
     if (InputNonEx.Text == "")
     {
         MessageBox.Show("Please Input Some Question(s)");
     }
     else
     {
         matrixReady();
         String[] s = InputNonEx.Text.Split('\n');
         int[,] ques = new int[s.Length, s[0].Length];
         for (int i = 0; i < s.Length; i++)
         {
             if (s[i] != "")
             {
                 String[] y = s[i].Split(' ');
                 for (int j = 0; j < y.Length; j++)
                 {
                     ques[i, j] = Convert.ToInt32(y[j]);
                 }
             }
         }
         Solution[] Solutions = new Solution[s.Length];
         for (int i = 0; i < s.Length; i++)
         {
             if (s[i] != "")
             {
                 Check    c = new Check();
                 Solution S = new Solution();
                 H.Trace(ques[i, 0], ques[i, 1], ques[i, 2], c, S);
                 if (c.getFound())
                 {
                     ques[i, 3] = 1;
                 }
                 else
                 {
                     ques[i, 3] = 0;
                     S.Add('-');
                 }
                 Solutions[i] = S;
             }
         }
         for (int i = 0; i < s.Length; i++)
         {
             if (s[i] != "")
             {
                 Ways.Text += i + 1 + " .";
                 for (int j = 0; j <= 2; j++)
                 {
                     Ways.Text += ques[i, j] + " ";
                 }
                 Ways.Text += " - ";
                 if (ques[i, 3] == 1)
                 {
                     Ways.Text += "YES, Route : ";
                     for (int j = 0; j < Solutions[i].getLength() - 1; j++)
                     {
                         Ways.Text += Solutions[i].getElement(j) + " - ";
                     }
                     Ways.Text += Solutions[i].getElement(Solutions[i].getLength() - 1) + "\n";
                 }
                 else
                 {
                     Ways.Text += "NO ROUTE MAN !\n";
                 }
             }
         }
         AnswerPanel.BringToFront();
     }
 }
Exemplo n.º 14
0
    /// <summary>
    /// The Lamps glow for the set "glowTime" while reading the available Answers.
    /// The mesh filter changes from glowing to normal after the glowTime is finished.
    /// The User has the set time "answerTime" to think what the right answer is.
    /// The Lamp corresponding to the right answer glows up and the other Lamps and answers disappear (are disabled).
    /// </summary>
    /// <param name="q"></param>
    /// <returns></returns>
    IEnumerator AskQuestion(QuestionCard q)
    {
        q.Reshuffle();
        InitQuestionUI(q);

        yield return(new WaitForSeconds(conf.questionTime));

        bool correct = false;

        switch (conf.answeringMode)
        {
        case AnsweringMode.MOVE_X_AXIS:
        {
            Vector3 playerPosition = Vector3.zero;

            ToggleSlider(true);

            float remainingTime = conf.answerTime;
            countDownBar.enabled = true;
            countDownMask.gameObject.SetActive(true);
            while (remainingTime > 0f)
            {
                playerPosition = BodyDisplay.Instance.GetBodyPosition();
                float adjustedX = Mathf.Clamp(playerPosition.x, -1, 1f);

                if (conf.flipX)
                {
                    adjustedX *= -1;
                }

                adjustedX   *= 0.5f;
                adjustedX   += 0.5f;
                slider.value = adjustedX;

                remainingTime           -= Time.deltaTime;
                countDownMask.fillAmount = 1 - remainingTime / conf.answerTime;
                countDownText.text       = Mathf.RoundToInt(remainingTime).ToString();
                yield return(null);
            }

            //yield return timer.UITimer(answerTime, countDownMask, countDownText);

            countDownText.text   = "";
            countDownBar.enabled = false;
            countDownMask.gameObject.SetActive(false);
            ToggleSlider(false);

            correct = (q.TrueAnswer == 0) ?
                      playerPosition.x <= 0f :
                      playerPosition.x > 0f;
            break;
        }

        case AnsweringMode.RAISE_HANDS:
        {
            float remainingTime = conf.answerTime / 2f;
            countDownBar.enabled = true;
            countDownMask.gameObject.SetActive(true);
            while (remainingTime > 0f)
            {
                remainingTime           -= Time.deltaTime;
                countDownMask.fillAmount = 1 - remainingTime / conf.answerTime;
                countDownText.text       = Mathf.RoundToInt(remainingTime).ToString();
                yield return(null);
            }

            //yield return timer.UITimer(answerTime, countDownMask, countDownText);

            countDownText.text   = "";
            countDownBar.enabled = false;
            countDownMask.gameObject.SetActive(false);

            bool leftHandRaised  = BodyDisplay.Instance.JointCompare(JointId.Head, JointId.HandLeft, hRC);
            bool rightHandRaised = BodyDisplay.Instance.JointCompare(JointId.Head, JointId.HandRight, hRC);

            //Debug.Log("Left" + leftHandRaised);
            //Debug.Log("Right" + rightHandRaised);

            correct = (q.TrueAnswer == 0) ?
                      leftHandRaised && !rightHandRaised :
                      rightHandRaised && !leftHandRaised;

            break;
        }
        }

        answerFeedback.gameObject.SetActive(true);
        countDownBar.gameObject.SetActive(false);
        countDownText.gameObject.SetActive(false);

        if (correct)
        {
            answerFeedback.text = StringRes.Get("_RightAnswer");
            ConfettiBurst();
        }
        else
        {
            answerFeedback.text = StringRes.Get("_WrongAnswer");
        }

        for (int i = 0; i < q.Answers.Count; i++)
        {
            AnswerPanel p = panels[i];
            if (i != q.TrueAnswer)
            {
                p.gameObject.SetActive(false);
            }
        }

        centerImg.gameObject.SetActive(false);

        yield return(new WaitForSeconds(conf.showCorrectAnswerTime));

        answerFeedback.gameObject.SetActive(false);
        countDownBar.gameObject.SetActive(true);
        countDownText.gameObject.SetActive(true);
    }
Exemplo n.º 15
0
    public static void CheckObjectiveComplete()
    {
        string obj = phasesObjectives[phase][objective];

        string[] objSplit = obj.Split(' ');
        switch (objSplit[0])
        {
        case "grab":
            if (objSplit[1].Trim() == "atom")
            {
                if (atomsGrabbed == 1)
                {
                    lastObjective = objSplit[1];
                    objective++;
                }
            }
            else if (objSplit[1].Trim() == "atoms")
            {
                if (atomsGrabbed == 2)
                {
                    lastObjective = objSplit[1];
                    objective++;
                }
            }
            else if (objSplit[1].Trim() == "gear")
            {
                if (pivotGrabbed)
                {
                    lastObjective = objSplit[1];
                    objective++;
                }
            }
            break;

        case "touch":
            if (atomsTouched)
            {
                objective++;
            }
            break;

        case "move":
            if (moleculeRotated)
            {
                objective++;
            }
            break;

        case "let":
            if (atomsGrabbed == 0)
            {
                objective++;
            }
            break;

        case "bond":
            if (bondCreated)
            {
                objective++;
            }
            break;

        case "separate":
            if (bondBroken)
            {
                objective++;
            }
            break;
        }
        if (objective >= phasesObjectives[phase].Count)
        {
            phase++;
            objective = 0;
        }
        if (atomsTouched)
        {
            atomsTouched = false;
        }
        if (bondCreated)
        {
            bondCreated = false;
        }
        if (pivotGrabbed)
        {
            pivotGrabbed = false;
        }
        if (moleculeRotated)
        {
            moleculeRotated = false;
        }
        if (bondBroken)
        {
            bondBroken = false;
        }

        if (phase > phasesObjectives.Count && final)
        {
            string space = "\n" + "\n" + "\n";
            BBM.UpdateText(space + "Parabéns, terminaste o tutorial com sucesso!" + "\n" + "Carrega no botão que está em cima da mesa no lado esquerdo para voltares ao menu principal");
            APSingle = GameObject.Find("ControlPanelAnswer").GetComponent <AnswerPanel>();
            APSingle.Appear();
            final = false;
        }
        else
        {
            UpdateBoard();
        }
    }