Ejemplo n.º 1
0
    /// <summary>
    /// Compares the answer <see cref="Matrix2x2"/> provided by the Player with the <see cref="solutionMatrix"/>.
    /// <para>
    ///     The <see cref="ResultText"/> will display whether or not the Player got the right answer.
    ///     This information will be recorded in the Google Sheets for Unity system (GSFU) via <see cref="CloudConnectorCore"/>.
    /// </para>
    /// <para>
    ///     Additional information can be sent to the <see cref="MatrixLogger"/> as well.
    /// </para>
    /// </summary>
    /// <param name="answerMatrix">The final answer the User submitted.</param>
    public void CheckAnswer(Matrix2x2 answerMatrix)
    {
        bool isCorrect = Matrix2x2.IsEqual(solutionMatrix, answerMatrix);

        if (isCorrect)
        {
            ResultText.text = "Correct!";
            MatrixLogger.Add("Correct! The answer was:\n" + solutionMatrix.ToString());
            SubmissionResultPanel.SetActive(true);

            answertime = Time.timeSinceLevelLoad;
            CloudConnectorCore.UpdateObjects("playerInfo", "name", Playername, q, answertime.ToString(), true);
            StopCoroutine("RemoveResultPanelAfterSomeSeconds");
            StartCoroutine("RemoveResultPanelAfterSomeSeconds");
        }
        else
        {
            MatrixLogger.Add("Incorrect! Your answer was:\n" + answerMatrix.ToString());

            ResultText.text = "Incorrect...";
            SubmissionResultPanel.SetActive(true);

            StopCoroutine("RemoveResultPanelAfterSomeSeconds");
            StartCoroutine("RemoveResultPanelAfterSomeSeconds");
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Add the text in the <see cref="InputField"/> to the <see cref="MatrixLogger"/>.
    /// </summary>
    public void Add()
    {
        string input = InputField.text;

        input.Trim();

        if (!string.IsNullOrEmpty(input))
        {
            MatrixLogger.Add(input);
            InputField.text = string.Empty;
        }
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Print a <see cref="Matrix2x2"/> to the <see cref="MatrixLogger"/>.
    /// </summary>
    public void PrintMatrix()
    {
        Matrix2x2 matrix = new Matrix2x2();

        MatrixLogger.Add(matrix.ToString());
    }
Ejemplo n.º 4
0
 /// <summary>
 /// Clear the <see cref="MatrixLogger"/> and <see cref="InputField"/>.
 /// </summary>
 public void Clear()
 {
     MatrixLogger.Clear();
     InputField.text = string.Empty;
 }