Exemple #1
0
    public AnswerStatus CheckAnswer(AnswerRow solution)
    {
        bool          incorrect = false;
        StringBuilder sb        = new StringBuilder();

        for (int i = 0; i < GameManager.ANSWER_COUNT; i++)
        {
            if (colors[i] == solution.colors[i])
            {
                sb.Append(string.Format("P{0} correct, ", i + 1));
            }
            else
            {
                sb.Append(string.Format("P{0} incorrect, ", i + 1));
                incorrect = true;
            }
        }

        // Update display string
        this.statusTextMesh.text = sb.ToString();

        if (incorrect)
        {
            return(AnswerStatus.Incorrect);
        }
        return(AnswerStatus.Correct);
    }
Exemple #2
0
 public void CheckAnswer(AnswerRow value)
 {
     if (value.description.text.Equals(FileManager.Instance.GetAnswers() [Globals.value]))
     {
         Console.Instance.Write("MUY BIEN");
     }
     else
     {
         Console.Instance.Write("HAS FALLADO");
     }
 }
Exemple #3
0
 public void InitCorrectAnswers(AnswerRow previous, AnswerRow solution)
 {
     for (int i = 0; i < GameManager.ANSWER_COUNT; i++)
     {
         if (previous.colors[i] == solution.colors[i])
         {
             colors[i] = previous.colors[i];
             renderers[i].material.color = previous.renderers[i].material.color;
         }
     }
 }
Exemple #4
0
    void PopulateListFromFile()
    {
        int length = fileManager.GetAnswers().Length;

        string[] items = new string[length];
        System.Array.Copy(fileManager.GetAnswers(), items, length);

        foreach (var item in items)
        {
            GameObject newRow = Instantiate(sampleRow) as GameObject;
            newRow.transform.SetParent(contentPanel, false);
            AnswerRow row = newRow.GetComponent <AnswerRow>();
            row.description.text = item;
        }
    }
            public AnswerRow AddAnswerRow(int AnswerID, string Answer, string VoterAnswer, int VoterId, int QuestionId, int SectionNumber)
            {
                AnswerRow rowAnswerRow = ((AnswerRow)(this.NewRow()));

                rowAnswerRow.ItemArray = new object[] {
                    AnswerID,
                    Answer,
                    VoterAnswer,
                    VoterId,
                    QuestionId,
                    SectionNumber
                };
                this.Rows.Add(rowAnswerRow);
                return(rowAnswerRow);
            }
Exemple #6
0
    private Material FindTarget(string name)
    {
        Debug.Log(string.Format("GameManager.FindTarget name: {0}", name));

        // Get current prefab gameobject
        GameObject answerRowPrefab = answers[currentAnswerIndex];

        // Get prefab script (reference to renderer and material
        AnswerRow answerRow = answerRowPrefab.GetComponent <AnswerRow>();

        switch (name)
        {
        case "PositionOne": return(answerRow.renderers[0].material);

        case "PositionTwo": return(answerRow.renderers[1].material);

        case "PositionThree": return(answerRow.renderers[2].material);

        case "PositionFour": return(answerRow.renderers[3].material);

        default: return(null);
        }
    }
 public AnswerRowChangeEvent(AnswerRow row, DataRowAction action)
 {
     this.eventRow    = row;
     this.eventAction = action;
 }
 public void RemoveAnswerRow(AnswerRow row)
 {
     this.Rows.Remove(row);
 }
 public void AddAnswerRow(AnswerRow row)
 {
     this.Rows.Add(row);
 }
Exemple #10
0
    public void SubmitAnswer()
    {
        Debug.Log("GameManager.SubmitAnswer");

        try
        {
            // Get current prefab gameobject
            GameObject answerRowPrefab = answers[currentAnswerIndex];

            // Get prefab script (reference to renderer and material
            AnswerRow answerRow = answerRowPrefab.GetComponent <AnswerRow>();

            if (answerRow.IsValid())
            {
                Debug.Log("GameManager.SubmitAnswer Valid Answer");
                var answerStatus = answerRow.CheckAnswer(solution);

                if (answerStatus == AnswerStatus.Correct)
                {
                    // Win case
                    ShowHideWinMessage(true);

                    // Clear answers
                    ClearAnswers();
                }
                else
                {
                    if (currentAnswerIndex + 1 >= GameManager.TRY_COUNT)
                    {
                        // You lose, exceeded try count
                        ShowHideLoseMessage(true);

                        // Clear answers
                        ClearAnswers();
                    }
                    else
                    {
                        // Create next row
                        GameObject newAnswerRowPrefab = GetNewAnswerRow(currentTopLeft);

                        // Get script
                        AnswerRow newAnswerRow = newAnswerRowPrefab.GetComponent <AnswerRow>();

                        // Init new row with correct answers
                        newAnswerRow.InitCorrectAnswers(answerRow, solution);

                        // Add to answers collection
                        answers[++currentAnswerIndex] = newAnswerRowPrefab;
                    }
                }
            }
            else
            {
                Debug.Log("GameManager.SubmitAnswer Invalid Answer");
            }
        }
        catch (Exception ex)
        {
            Debug.Log(string.Format("GameManager.SubmitAnswer Error: {0}", ex.Message));
        }
    }
Exemple #11
0
    public void ChangeTargetColor(string targetName, string colorName)
    {
        if (currentAnswerIndex < 0)
        {
            return;
        }

        Debug.Log(string.Format("GameManager.ChangeTargetColor2 target: {0}, color: {1}", targetName, colorName));

        // Get current prefab gameobject
        GameObject answerRowPrefab = answers[currentAnswerIndex];

        // Get prefab script (reference to renderer and material
        AnswerRow answerRow = answerRowPrefab.GetComponent <AnswerRow>();

        // Get targetColor enum
        GameColor targetColor = GetGameColorForString(colorName);

        // Get index for target
        int index = GetIndexForTargetName(targetName);

        // Set answer row color
        answerRow.SetByPosition(index, targetColor);

        // Get target material
        var targetMaterial = FindTarget(targetName);

        if (targetMaterial == null)
        {
            Debug.Log("GameManager.ChangeTargetColor2 target is null");
        }
        else
        {
            switch (colorName)
            {
            case "red":
            {
                targetMaterial.color = Color.red;
                break;
            }

            case "blue":
            {
                targetMaterial.color = Color.blue;
                break;
            }

            case "green":
            {
                targetMaterial.color = Color.green;
                break;
            }

            case "yellow":
            {
                targetMaterial.color = Color.yellow;
                break;
            }

            default:
            {
                break;
            }
            }
        }
    }
 public AnswerRowChangeEvent(AnswerRow row, global::System.Data.DataRowAction action)
 {
     this.eventRow    = row;
     this.eventAction = action;
 }
 public AnswerRowChangeEvent(AnswerRow row, DataRowAction action) {
     this.eventRow = row;
     this.eventAction = action;
 }
 public void RemoveAnswerRow(AnswerRow row) {
     this.Rows.Remove(row);
 }
 public void AddAnswerRow(AnswerRow row) {
     this.Rows.Add(row);
 }