public override void SetQuestion(BaseQuestion info, Action <int, int, bool, List <SequenceOfClick> > Answered)
    {
        base.SetQuestion(info, Answered);
        Set();

        float t = Mathf.InverseLerp(9, 6, 3);
    }
Ejemplo n.º 2
0
    public void ShowGameplay(bool isReset = true)
    {
        if (isReset)
        {
            if (CurrentQuestionPanel != null)
            {
                Debug.LogError("From ShowGameplay");
                CurrentQuestionPanel.Reset();
            }
        }

        ShowHideElementsOfGameplayAccordingToMode();

        BaseQuestion currentQuestion = GameManager.Instance.GetCurrentQuestion();

        QuestionText.text = currentQuestion.Question;

        if (currentQuestion.HasTimerValue)
        {
            UITimer.SetTimer(Mathf.RoundToInt(GameManager.Instance.GetCurrentQuestion(true).TimeForQuestion));
            ShowHideGameObject(UITimer.gameObject, ShowHideAction.Show);
        }
        else
        {
            ShowHideGameObject(UITimer.gameObject, ShowHideAction.Hide);
        }
    }
Ejemplo n.º 3
0
    public void ShowSecondaryQuestion()
    {
        BaseQuestion question = GameManager.Instance.GetCurrentQuestion();

        if (question.SecondaryQuestion.Count == 0)
        {
            return;
        }

        QuestionText.text = question.SecondaryQuestion[0];
    }
Ejemplo n.º 4
0
    public BaseQuestion GetUIQuestion(int questionIndex, int answerButtons = 4)
    {
        ConfusionTouch questionType = ConfusionTouchList[questionIndex];

        AnswerInfos.Clear();

        CurrentColorID = AnswerID.None;

        int colors = EnumUtil.GetValues <ColorEnum>().Count;

        //Initializing a Question
        BaseQuestion bq = new BaseQuestion();

        bq.IgnoreClickCount       = true;
        bq.IgnoreClickTime        = true;
        bq.HasSequenceAnswer      = false;
        bq.HasBoolValue           = false;
        bq.HasTimerValue          = true;
        bq.HasSequentialQuestions = true;
        bq.Pattern         = QPattern.ConfusionTouch;
        bq.QuestionType    = QuestionType.Base;
        bq.TimeForQuestion = 0;
        bq.Options         = new List <AnswerSpriteHolder>();
        for (int i = 0; i < answerButtons; i++)
        {
            AnswerSpriteHolder answer = new AnswerSpriteHolder();
            bq.Options.Add(answer);
        }
        //

        //Getting a random color for the question
        int randomColorIndex = (int)Random.Range(0, colors);

        //Shuffle
        FisherYatesShuffle shuffle = new FisherYatesShuffle(colors);

        shuffle.ShuffleList();
        List <int> colorIndex = shuffle.ShuffledList;

        //Setting up button info for later assignment and setting up current answerID Color for the current question
        for (int i = 0; i < answerButtons; i++)
        {
            ConfusionTouchAnswerInfo answerInfo = GetNewAnswerButton();
            AnswerInfos.Add(answerInfo);
        }

        SetAnswerForQuestion();
        SetAnswerID((ColorEnum)randomColorIndex);

        //Assignment to answer buttons
        SetAnswerOption(ref bq, (ColorEnum)randomColorIndex, questionType);

        return(bq);
    }
Ejemplo n.º 5
0
    public void swapElem(int index1, int index2)
    {
        //index1 = testHold.Questions.FindIndex(f => f.sortOrder == 1004);
        //index2 = testHold.Questions.FindIndex(f => f.sortOrder == 1005);

        BaseQuestion bq = AnotherHolder.Questions[index2];

        AnotherHolder.Questions[index2] = AnotherHolder.Questions[index1];
        AnotherHolder.Questions[index1] = bq;

        for (int i = 0; i < AnotherHolder.Questions.Count; i++)
        {
            AnotherHolder.Questions[i].sortOrder = -1;
        }
    }
Ejemplo n.º 6
0
 public List <KeyValuePair <string, string> > GetContentByQuestion(BaseQuestion question)
 {
     Question   = question;
     QuestionId = question.Id;
     return(question.Type switch
     {
         "checkbox" => GetContentForCheckbox(),
         "links" => GetContentForLinks(),
         "radio" => GetContentForRadio(),
         "text" => GetContentForText(),
         "text_gap" => GetContentForTextGap(),
         "match_group" => GetContentForMatchGroupAnswer(),
         "text_selection" => GetContentForTextSelection(),
         "text_compose" => GetContentForTextCompose(),
         "file" => new List <KeyValuePair <string, string> >(),
         _ => throw new ArgumentException($"Invalid input type {question.Type}")
     });
Ejemplo n.º 7
0
    public override void SetUI(QuestionUIInfo info)
    {
        if (isUISet)
        {
            return;
        }

        AnswerParent.gameObject.Hide();
        base.SetUI(info);
        this.info = info;
        GameManager.Instance.TimeTicker += TimerTick;


        BaseQuestion question = GameManager.Instance.GetCurrentQuestion();


        hasQuestionStarted = true;
        displayTime        = info.QuestionData_Float[0];
        showAfterSeconds   = GameManager.Instance.timerInt + (int)displayTime;

        for (int i = 0; i < question.QuestionSprite.Count; i++)
        {
            QuestionImages[i].sprite = GetCorrectSpriteByID.Instance.GetSpriteFromID(question.QuestionSprite[i].Sprite);
        }

        QimageParent.gameObject.Show();
        isUISet = true;


        //EProz.INSTANCE.WaitAndCall(displayTime, () =>
        //{
        //QimageParent.gameObject.SetActive(false);
        ////QuestionDisplay.text = info.SecondaryQuestion [0];
        //
        //UIManager.Instance.ShowSecondaryQuestion();
        //AnswerParent.gameObject.SetActive(true);
        ////    UIManager.Instance.ShowSecondaryQuestion();
        //
        //for (int i = 0; i < mButtonHolder.Count; i++)
        //{
        //    mButtonHolder[i].SetAnswerButtonProperties(info.ButtonAnswer[i]);
        //}
        //
        //});
    }
Ejemplo n.º 8
0
    public void swapElem()
    {
        #if UNITY_EDITOR
        EditorUtility.SetDirty(testHold);
        #endif

        index1 = testHold.Questions.FindIndex(f => f.sortOrder == 1004);
        index2 = testHold.Questions.FindIndex(f => f.sortOrder == 1005);

        BaseQuestion bq = testHold.Questions[index2];
        testHold.Questions[index2] = testHold.Questions[index1];
        testHold.Questions[index1] = bq;

        for (int i = 0; i < testHold.Questions.Count; i++)
        {
            testHold.Questions[i].sortOrder = -1;
        }
    }
Ejemplo n.º 9
0
    public void aksjdak()
    {
        List <BaseQuestion> QuestionAnd4Ans = qData.Questions.Where(f => (f.Pattern == QPattern.QuestionAnd4Answers)).ToList();
        List <BaseQuestion> PicAnd4Ans      = qData.Questions.Where(f => (f.Pattern == QPattern.PictureAnd4Answers)).ToList();
        List <BaseQuestion> CatchMonkey     = qData.Questions.Where(f => (f.Pattern == QPattern.CatchMonkey)).ToList();
        List <BaseQuestion> SlowFast        = qData.Questions.Where(f => (f.Pattern == QPattern.SlowFast)).ToList();
        List <BaseQuestion> TchAppearOrder3 = qData.Questions.Where(f => (f.Pattern == QPattern.TouchAppearOrder3)).ToList();
        List <BaseQuestion> TchAppearOrder5 = qData.Questions.Where(f => (f.Pattern == QPattern.TouchAppearOrder5)).ToList();
        List <BaseQuestion> TestSight       = qData.Questions.Where(f => (f.Pattern == QPattern.TestYourSight)).ToList();
        List <BaseQuestion> ConfusionTch    = qData.Questions.Where(f => (f.Pattern == QPattern.ConfusionTouch)).ToList();
        List <BaseQuestion> SpeedTch        = qData.Questions.Where(f => (f.Pattern == QPattern.SpeedTouch)).ToList();
        List <BaseQuestion> objInPrev       = qData.Questions.Where(f => (f.Pattern == QPattern.ObjectInPrevious)).ToList();
        List <BaseQuestion> trufals         = qData.Questions.Where(f => (f.Pattern == QPattern.TrueFalse)).ToList();
        List <BaseQuestion> ifElse          = qData.Questions.Where(f => (f.Pattern == QPattern.IfElse)).ToList();
        List <BaseQuestion> TextAnd4Ans     = qData.Questions.Where(f => (f.Pattern == QPattern.TextAnd4Answers)).ToList();
        List <BaseQuestion> smallBig        = qData.Questions.Where(f => (f.Pattern == QPattern.SmallestAndBiggest)).ToList();
        List <BaseQuestion> xyz             = qData.Questions.Where(f => (f.Pattern == QPattern.XYZSeconds)).ToList();
        List <BaseQuestion> homofon         = qData.Questions.Where(f => (f.Pattern == QPattern.Homophone)).ToList();
        List <BaseQuestion> tchOneMan       = qData.Questions.Where(f => (f.Pattern == QPattern.TouchOneManQuickly)).ToList();
        List <BaseQuestion> tchFiveman      = qData.Questions.Where(f => (f.Pattern == QPattern.TouchFiveMen)).ToList();
        List <BaseQuestion> uniq            = qData.Questions.Where(t => (t.QuestionType == QuestionType.NoBase)).ToList();

        int Qand4A_count      = 0;
        int picAnd4A_count    = 0;
        int catchMonkey_count = 0;
        int slowfast_count    = 0;
        int tao3_count        = 0;
        int tao5_count        = 0;
        int testSight_count   = 0;
        int confuseTch_count  = 0;
        int speedTch_count    = 0;
        int objInPrev_count   = 0;
        int tf_count          = 0;
        int ifels_count       = 0;
        int text4ans_count    = 0;
        int sb_count          = 0;
        int xyz_count         = 0;
        int homof_count       = 0;
        int tch1_count        = 0;
        int tch5_count        = 0;
        int uniq_count        = 0;

        for (int i = 0; i < QuestionAnd4Ans.Count; i++)
        {
            QuestionAnd4Ans[i].sortOrder = Qand4A[i];
        }

        for (int i = 0; i < trufals.Count; i++)
        {
            trufals[i].sortOrder = TrueFalse[i];
            //TrueFalse[i] - 1;
        }

        for (int i = 0; i < homofon.Count; i++)
        {
            homofon[i].sortOrder = Homofon[i] - 1;
        }

        for (int i = 0; i < PicAnd4Ans.Count; i++)
        {
            PicAnd4Ans[i].sortOrder = Picand4A[i] - 1;
        }

        for (int i = 0; i < uniq.Count; i++)
        {
            uniq[i].sortOrder = uniqueIndex[i] - 1;
        }


        QuestionAnd4Ans = QuestionAnd4Ans.OrderBy(x => x.sortOrder).ToList();
        PicAnd4Ans      = PicAnd4Ans.OrderBy(x => x.sortOrder).ToList();
        trufals         = trufals.OrderBy(x => x.sortOrder).ToList();
        homofon         = homofon.OrderBy(x => x.sortOrder).ToList();
        uniq            = uniq.OrderBy(x => x.sortOrder).ToList();

        BaseQuestion bq = new BaseQuestion();

        //<<<<<<< HEAD
        #if UNITY_EDITOR
        EditorUtility.SetDirty(AnotherHolder);
        #endif
        //=======
        //        EditorUtility.SetDirty(AnotherHolder);
        //>>>>>>> 8566da3ed22e947d6d1543226c6f15a83d76b111

        for (int i = 0; i < indexes.Count; i++)
        {
//            if (indexes[i] == "P")
//                Debug.Log(indexes[i] + "   " + (i + 1).ToString());

            switch (indexes[i].Trim())
            {
            case "M":
                bq = CatchMonkey[catchMonkey_count++];
                break;

            case "C":
                //           Debug.Log(ConfusionTch.Count + "     " + confuseTch_count);
                bq = ConfusionTch[confuseTch_count++];
                //  confuseTch_count = Mathf.Clamp(confuseTch_count, 0, ConfusionTch.Count - 1);
                break;

            case "H":
                bq = homofon[homof_count++];
                //return QPattern.Homophone;
                break;

            case "E":
                bq = ifElse[ifels_count++];
                //return QPattern.IfElse;
                break;

            case "O":
                bq = objInPrev[objInPrev_count++];
                //    return QPattern.ObjectInPrevious;
                break;

            case "P":
                //         Debug.Log(picAnd4A_count + "   " + PicAnd4Ans.Count);
                bq = PicAnd4Ans[picAnd4A_count++];
                //   return QPattern.PictureAnd4Answers;
                break;

            case "Q":
                bq = QuestionAnd4Ans[Qand4A_count++];
                // return QPattern.QuestionAnd4Answers;
                break;

            case "F":
                bq = SlowFast[slowfast_count++];
                //     return QPattern.SlowFast;
                break;

            case "S":
                bq = SpeedTch[speedTch_count++];
                //    return QPattern.SpeedTouch;
                break;

            case "Y":
                bq = TestSight[testSight_count++];
//                    return QPattern.TestYourSight;
                break;

            case "TA":
                bq = TchAppearOrder3[tao3_count++];
                //          return QPattern.TouchAppearOrder3;
                break;

            case "TAf":
                bq = TchAppearOrder5[tao5_count++];
                //     return QPattern.TouchAppearOrder5;
                break;

            case "TF":
                bq = tchFiveman[tch5_count++];
                //         return QPattern.TouchFiveMen;
                break;

            case "TO":
                bq = tchOneMan[tch1_count++];
                //           return QPattern.TouchOneManQuickly;
                break;

            case "X":
                bq = xyz[xyz_count++];
                //              return QPattern.XYZSeconds;
                break;

            case "T":
                bq = trufals[tf_count++];
                //return QPattern.TrueFalse;
                break;

            case "B":
                bq = smallBig[sb_count++];
                //                  return QPattern.SmallestAndBiggest;
                break;

            case "A":
                bq = TextAnd4Ans[text4ans_count++];
                //                  return QPattern.TextAnd4Answers;
                break;

            default:
                bq = uniq[uniq_count++];
                //                  return QPattern.Default;
                break;
            }

            //   Debug.Log("   " + bq.Question + "        P   :     " + bq.Pattern.ToString());

            AnotherHolder.Questions.Add(bq);
        }
    }
Ejemplo n.º 10
0
    public void Multiplayer()
    {
        #if UNITY_EDITOR
        EditorUtility.SetDirty(AnotherHolder);
        EditorUtility.SetDirty(Buckets);
        #endif


        List <BaseQuestion> P_list  = AnotherHolder.Questions.Where(f => (f.Pattern == QPattern.PictureAnd4Answers)).ToList();
        List <BaseQuestion> Q_list  = AnotherHolder.Questions.Where(f => (f.Pattern == QPattern.QuestionAnd4Answers)).ToList();
        List <BaseQuestion> T_list  = AnotherHolder.Questions.Where(f => (f.Pattern == QPattern.TrueFalse)).ToList();
        List <BaseQuestion> H_list  = AnotherHolder.Questions.Where(f => (f.Pattern == QPattern.Homophone)).ToList();
        List <BaseQuestion> A_list  = AnotherHolder.Questions.Where(f => (f.Pattern == QPattern.TextAnd4Answers)).ToList();
        List <BaseQuestion> U_list  = AnotherHolder.Questions.Where(t => (t.QuestionType == QuestionType.NoBase)).ToList();
        List <BaseQuestion> B_list  = AnotherHolder.Questions.Where(f => (f.Pattern == QPattern.SmallestAndBiggest)).ToList();
        List <BaseQuestion> O_list  = AnotherHolder.Questions.Where(f => (f.Pattern == QPattern.ObjectInPrevious)).ToList();
        List <BaseQuestion> F_list  = AnotherHolder.Questions.Where(f => (f.Pattern == QPattern.SlowFast)).ToList();
        List <BaseQuestion> TO_list = AnotherHolder.Questions.Where(f => (f.Pattern == QPattern.TouchOneManQuickly)).ToList();
        List <BaseQuestion> M_list  = AnotherHolder.Questions.Where(f => (f.Pattern == QPattern.CatchMonkey)).ToList();
        List <BaseQuestion> TA_list = AnotherHolder.Questions.Where(f => (f.Pattern == QPattern.TouchAppearOrder3 || f.Pattern == QPattern.TouchAppearOrder5)).ToList();
        List <BaseQuestion> Y_list  = AnotherHolder.Questions.Where(f => (f.Pattern == QPattern.TestYourSight)).ToList();
        List <BaseQuestion> TF_list = AnotherHolder.Questions.Where(f => (f.Pattern == QPattern.TouchFiveMen)).ToList();
        List <BaseQuestion> E_list  = AnotherHolder.Questions.Where(f => (f.Pattern == QPattern.IfElse)).ToList();


        //Removing 1 pic and 4 answer of pack of 4
        BaseQuestion rem = P_list.Find(q => q.Question.Contains("suite"));
        Debug.Log(rem.Question);
        P_list.Remove(rem);

        // Removing 2 true false of pack of 4
        rem = T_list.Find(q => q.Question.Contains("dice"));
        Debug.Log(rem.Question);
        T_list.Remove(rem);
        rem = T_list.Find(q => q.Question.Contains("potbellied"));
        Debug.Log(rem.Question);
        T_list.Remove(rem);


        // Removing 1 Homophone pattern of pack of 4
        rem = H_list.Find(q => q.Question.Contains("Waste"));
        Debug.Log(rem.Question);
        H_list.Remove(rem);

        // Removing 4 question and 4 answer of pack of 4
        rem = Q_list.Find(q => q.Question.Contains("black poker"));
        Debug.Log(rem.Question);
        Q_list.Remove(rem);
        rem = Q_list.Find(q => q.Question.Contains("total poker"));
        Debug.Log(rem.Question);
        Q_list.Remove(rem);
        rem = Q_list.Find(q => q.Question.Contains("picture was ..."));
        Debug.Log(rem.Question);
        Q_list.Remove(rem);
        rem = Q_list.Find(q => q.Question.Contains("basket was ..."));
        Debug.Log(rem.Question);
        Q_list.Remove(rem);

        //Removing Specified Questions

        Q_list.RemoveAt(15);
        Q_list.RemoveAt(16);
        Q_list.RemoveAt(17);


        U_list.RemoveAt(3);


        List <BaseQuestion> col1 = new List <BaseQuestion>();
        List <BaseQuestion> col2 = new List <BaseQuestion>();
        List <BaseQuestion> col3 = new List <BaseQuestion>();
        List <BaseQuestion> col4 = new List <BaseQuestion>();
        List <BaseQuestion> col5 = new List <BaseQuestion>();

        int P_Index  = 0;
        int Q_Index  = 0;
        int T_Index  = 0;
        int H_Index  = 0;
        int A_Index  = 0;
        int U_Index  = 0;
        int B_Index  = 0;
        int O_Index  = 0;
        int F_Index  = 0;
        int TO_Index = 0;
        int M_Index  = 0;
        int TA_Index = 0;
        int Y_Index  = 0;
        int TF_Index = 0;
        int E_Index  = 0;

        // Filling First Column

        for (int i = 0; i < 42; i++)
        {
            if (i < 33)
            {
                col1.Add(P_list[P_Index]);
                P_Index++;
            }
            else
            {
                col1.Add(Q_list[Q_Index]);
                Q_Index++;
            }
        }

        Debug.Log("COL1 COUNT = " + col1.Count);

        // Filling Second Column

        for (int i = 0; i < 42; i++)
        {
            if (i < 6)
            {
                col2.Add(Q_list[Q_Index]);
                Q_Index++;
            }
            else if (i >= 6 && i < 9)
            {
                col2.Add(T_list[T_Index]);
                T_Index++;
            }
            else if (i >= 9 && i < 23)
            {
                col2.Add(Q_list[Q_Index]);
                Q_Index++;
            }
            else if (i >= 23 && i < 26)
            {
                col2.Add(T_list[T_Index]);
                T_Index++;
            }
            else if (i == 26)
            {
                col2.Add(Q_list[Q_Index]);
                Q_Index++;
            }
            else if (i > 26 && i < 40)
            {
                col2.Add(T_list[T_Index]);
                T_Index++;
            }
            else if (i >= 40)
            {
                col2.Add(H_list[H_Index]);
                H_Index++;
            }
        }

        Debug.Log("COL2 COUNT = " + col2.Count);

        // Filling 3rd Column

        for (int i = 0; i < 42; i++)
        {
            if (i < 5)
            {
                col3.Add(H_list[H_Index]);
                H_Index++;
            }
            else if (i >= 5 && i < 10)
            {
                col3.Add(A_list[A_Index]);
                A_Index++;
            }
            else if (i >= 10 && i < 12)
            {
                col3.Add(T_list[T_Index]);
                T_Index++;
            }
            else if (i >= 12 && i < 18)
            {
                col3.Add(H_list[H_Index]);
                H_Index++;
            }
            else if (i >= 18 && i < 21)
            {
                col3.Add(U_list[U_Index]);
                U_Index++;
            }
            else if (i >= 21 && i < 31)
            {
                col3.Add(B_list[B_Index]);
                B_Index++;
            }
            else if (i >= 31 && i < 37)
            {
                col3.Add(U_list[U_Index]);
                U_Index++;
            }
            else if (i >= 37)
            {
                col3.Add(O_list[O_Index]);
                O_Index++;
            }
        }

        Debug.Log("COL3 COUNT = " + col3.Count);

        // Filling 4th column

        for (int i = 0; i < 42; i++)
        {
            if (i < 2)
            {
                col4.Add(O_list[O_Index]);
                O_Index++;
            }
            else if (i >= 2 && i < 4)
            {
                col4.Add(F_list[F_Index]);
                F_Index++;
            }
            else if (i >= 4 && i < 14)
            {
                col4.Add(U_list[U_Index]);
                U_Index++;
            }
            else if (i >= 14 && i < 19)
            {
                col4.Add(TO_list[TO_Index]);
                TO_Index++;
            }
            else if (i >= 19 && i < 24)
            {
                col4.Add(M_list[M_Index]);
                M_Index++;
            }
            else if (i >= 24 && i < 28)
            {
                col4.Add(TA_list[TA_Index]);
                TA_Index++;
            }
            else if (i >= 28 && i < 33)
            {
                col4.Add(Y_list[5 + Y_Index]);
                Y_Index++;
            }
            else if (i >= 33 && i < 37)
            {
                col4.Add(TF_list[TF_Index]);
                TF_Index++;
            }
            else if (i >= 33)
            {
                col4.Add(Y_list[Y_Index - 5]);
                Y_Index++;
            }
        }

        Debug.Log("COL4 COUNT = " + col4.Count);

        //Filling 5th column

        for (int i = 0; i < 42; i++)
        {
            if (i < 5)
            {
                // TO
                col5.Add(TO_list[TO_Index]);
                TO_Index++;
            }
            else if (i >= 5 && i < 10)
            {
                //M
                col5.Add(M_list[M_Index]);
                M_Index++;
            }
            else if (i >= 10 && i < 15)
            {
                // TA
                col5.Add(TA_list[TA_Index]);
                TA_Index++;
            }
            else if (i >= 15 && i < 25)
            {
                //Y
                col5.Add(Y_list[Y_Index]);
                Y_Index++;
            }
            else if (i >= 25 && i < 30)
            {
                //TF
                col5.Add(TF_list[TF_Index]);
                TF_Index++;
            }
            else if (i >= 30 && i < 32)
            {
                //O
                col5.Add(O_list[O_Index]);
                O_Index++;
            }
            else if (i >= 32 && i < 37)
            {
                col5.Add(F_list[F_Index]);
                F_Index++;
            }
            else if (i >= 37)
            {
                col5.Add(E_list[E_Index]);
                E_Index++;
            }
        }

        Debug.Log("COL5 COUNT = " + col5.Count);

        //Adding in questions in bucket from each column

        for (int i = 0; i < 42; i++)
        {
            Buckets.Questions.Add(col1[i]);
            Buckets.Questions.Add(col2[i]);
            Buckets.Questions.Add(col3[i]);
            Buckets.Questions.Add(col4[i]);
            Buckets.Questions.Add(col5[i]);
        }
    }
Ejemplo n.º 11
0
 public override void SetQuestion(BaseQuestion info, Action <int, int, bool, List <SequenceOfClick> > Answered)
 {
     base.SetQuestion(info, Answered);
     Set();
 }
Ejemplo n.º 12
0
 private void UpdateQuestion(int index, BaseQuestion question)
 {
     _questions[index] = question;
 }
Ejemplo n.º 13
0
    private void SetAnswerOption(ref BaseQuestion question, ColorEnum randomColor, ConfusionTouch questionType)
    {
        ColorEnum color = GetColorBasedOnAnswerOrSpriteID(IDType.AnswerID, CurrentColorID);

        switch (questionType)
        {
        case ConfusionTouch.ColorX:
            for (int i = 0; i < question.Options.Count; i++)
            {
                question.Options[i].Sprite    = AnswerInfos[i].SpriteID;
                question.Options[i].ID        = AnswerInfos[i].AnswerID;
                question.Options[i].text      = AnswerInfos[i].TextInBalloon.ToString();
                question.Options[i].TextColor = GetColorBasedOnColorEnum(AnswerInfos[i].TextColor);
                if (CurrentColorID == AnswerInfos[i].AnswerID)
                {
                    question.Options[i].IsCorrect = true;
                    question.Question             = "Touch the " + color.ToString() + " balloon.";
                }
                else
                {
                    question.Options[i].IsCorrect = false;
                }
            }
            break;

        case ConfusionTouch.WordColorX:
            for (int i = 0; i < question.Options.Count; i++)
            {
                question.Options[i].Sprite    = AnswerInfos[i].SpriteID;
                question.Options[i].ID        = AnswerInfos[i].AnswerID;
                question.Options[i].text      = AnswerInfos[i].TextInBalloon.ToString();
                question.Options[i].TextColor = GetColorBasedOnColorEnum(AnswerInfos[i].TextColor);
                if (CurrentColorID == AnswerInfos[i].AnswerID)
                {
                    question.Options[i].IsCorrect = true;
                    question.Question             = "Touch the " + AnswerInfos[i].TextColor.ToString() + " word.";
                }
                else
                {
                    question.Options[i].IsCorrect = false;
                }
            }
            break;

        case ConfusionTouch.WordX:
            for (int i = 0; i < question.Options.Count; i++)
            {
                question.Options[i].Sprite    = AnswerInfos[i].SpriteID;
                question.Options[i].ID        = AnswerInfos[i].AnswerID;
                question.Options[i].text      = AnswerInfos[i].TextInBalloon.ToString();
                question.Options[i].TextColor = GetColorBasedOnColorEnum(AnswerInfos[i].TextColor);
                if (CurrentColorID == AnswerInfos[i].AnswerID)
                {
                    question.Options[i].IsCorrect = true;
                    question.Question             = "Touch the word " + question.Options[i].text + ".";
                }
                else
                {
                    question.Options[i].IsCorrect = false;
                }
            }
            break;
        }
    }
Ejemplo n.º 14
0
    /// <summary>
    /// Main method to set the question property and answer button property for each answer button
    /// </summary>
    /// <param name="question">Question.</param>
    /// <param name="answer">Answer.</param>
    /// <param name="randomColor">Random color.</param>
    /// <param name="questionType">Question type.</param>
    private void SetAnswerOption(ref BaseQuestion question, List <SpeedTouchAnswerInfo> answer, ColorEnum randomColor, SpeedTouch questionType)
    {
        ColorEnum color = GetColorBasedOnAnswerOrSpriteID(IDType.AnswerID, CurrentColorID);

        switch (questionType)
        {
        case SpeedTouch.OneX:
            question.Question = "Touch the " + color.ToString() + " balloon.";

            for (int i = 0; i < question.Options.Count; i++)
            {
                question.Options[i].IsCorrect = (CurrentColorID == answer[i].AnswerID) ? true : false;
                question.Options[i].ID        = answer[i].AnswerID;
                question.Options[i].Sprite    = answer[i].SpriteID;
            }
            break;

        case SpeedTouch.ExceptX:
            question.Question = "Touch any balloon except the " + color.ToString() + " balloon.";
            for (int i = 0; i < question.Options.Count; i++)
            {
                question.Options[i].IsCorrect = (CurrentColorID == answer[i].AnswerID) ? false : true;
                question.Options[i].ID        = answer[i].AnswerID;
                question.Options[i].Sprite    = answer[i].SpriteID;
            }
            break;

        case SpeedTouch.AnyX:
            question.Question = "Touch any " + color.ToString() + " balloon.";
            int secondColorPos = -1;
            int firstColorPos  = -1;

            for (int i = 0; i < question.Options.Count; i++)
            {
                question.Options[i].ID     = answer[i].AnswerID;
                question.Options[i].Sprite = answer[i].SpriteID;
                Debug.Log("Answer Image = " + question.Options[i].Sprite.ToString());

                if (answer[i].AnswerID == CurrentColorID)
                {
                    firstColorPos = i;
                }

                question.Options[i].IsCorrect = (CurrentColorID == answer[i].AnswerID) ? true : false;
            }

            secondColorPos = Random.Range(0, question.Options.Count);
            while (secondColorPos == firstColorPos)
            {
                secondColorPos = Random.Range(0, question.Options.Count);
            }

            question.Options[secondColorPos].ID        = CurrentColorID;
            question.Options[secondColorPos].Sprite    = GetSpriteIDBasedOnAnswerID(CurrentColorID);
            question.Options[secondColorPos].IsCorrect = true;

            break;

        case SpeedTouch.LeftX:
            question.Question = "Touch the balloon on the left of the " + color.ToString() + " balloon.";
            int randomLeftx = Random.Range(0, 10);

            randomLeftx = (randomLeftx % 2 == 0) ? 1 : 3;
            Debug.Log("randomLeftx = " + randomLeftx);
            CheckAndRearrangeAnswers(answer, randomLeftx);

            for (int i = 0; i < question.Options.Count; i++)
            {
                question.Options[i].ID        = answer[i].AnswerID;
                question.Options[i].Sprite    = answer[i].SpriteID;
                question.Options[i].IsCorrect = (i + 1 == randomLeftx) ? true : false;
            }
            break;

        case SpeedTouch.RightX:
            question.Question = "Touch the balloon on the right of the " + color.ToString() + " balloon.";
            int randomRightX = Random.Range(0, 2);

            randomRightX = (randomRightX == 1) ? 0 : 2;
            CheckAndRearrangeAnswers(answer, randomRightX);

            for (int i = 0; i < question.Options.Count; i++)
            {
                question.Options[i].ID        = answer[i].AnswerID;
                question.Options[i].Sprite    = answer[i].SpriteID;
                question.Options[i].IsCorrect = (i - 1 == randomRightX) ? true : false;
            }
            break;

        case SpeedTouch.AboveX:
            question.Question = "Touch the balloon above the " + color.ToString() + " balloon.";
            int randomAboveX = Random.Range(0, 2);

            randomAboveX = (randomAboveX == 1) ? 2 : 3;
            CheckAndRearrangeAnswers(answer, randomAboveX);

            for (int i = 0; i < question.Options.Count; i++)
            {
                question.Options[i].ID        = answer[i].AnswerID;
                question.Options[i].Sprite    = answer[i].SpriteID;
                question.Options[i].IsCorrect = (i + 2 == randomAboveX) ? true : false;
                Debug.Log("Answer Image = " + question.Options[i].Sprite.ToString());
            }
            break;

        case SpeedTouch.BelowX:
            question.Question = "Touch the balloon below the " + color.ToString() + " balloon.";
            int randomBelowX = Random.Range(0, 2);

            randomBelowX = (randomBelowX == 1) ? 0 : 1;
            CheckAndRearrangeAnswers(answer, randomBelowX);

            for (int i = 0; i < question.Options.Count; i++)
            {
                question.Options[i].ID        = answer[i].AnswerID;
                question.Options[i].Sprite    = answer[i].SpriteID;
                question.Options[i].IsCorrect = (i - 2 == randomBelowX) ? true : false;
                Debug.Log("Answer Image = " + question.Options[i].Sprite.ToString());
            }
            break;
        }
    }
Ejemplo n.º 15
0
    public void ButtonClicked(int buttonID, int ClickCounter, bool isCorrect, List <SequenceOfClick> SequenceOfClicks)
    {
        //Debug.Log("Clicked");

        Debug.Log("ClickCounter = " + ClickCounter);

        bool         matchedSequence = false;
        BaseQuestion question        = GameManager.Instance.GetCurrentQuestion();


        if (question.IgnoreClickCount && ClickCounter > 1)
        {
            return;
        }

        if (!isCorrect)
        {
            Debug.Log("!isCorrect");
            GameManager.Instance.AnsweredWrongly();
        }
        else
        {
            Debug.Log("IsCorrect");
            if (!question.HasSequenceAnswer && !question.HasBoolValue)
            {
                GameManager.Instance.AnsweredCorrectly();
            }
            else if (!question.HasSequenceAnswer && question.HasBoolValue)
            {
                if (question.ReturnValue_Bool)
                {
                    GameManager.Instance.AnsweredCorrectly();
                }
                else
                {
                    Debug.Log("!GameManager.Instance.CurrentQuestion.HasSequenceAnswer && !GameManager.Instance.CurrentQuestion.HasBoolValue");
                    GameManager.Instance.AnsweredWrongly();
                }
            }
            else if (question.HasSequenceAnswer)
            {
                Debug.Log("question.HasSequenceAnswer");

                byte properClicked = 0;
                byte properTimed   = 0;

                if (GameManager.Instance.SequenceOfClick == null)
                {
                    Debug.LogError("Something wrong. Question has Sequence but No sequence data found from options.");
                }
                else
                {
                    if (question.CountSequenceIgnoreValue)
                    {
                        Debug.Log("CountSequenceIgnoreValue");
                        for (int i = 0; i < SequenceOfClicks.Count; i++)
                        {
                            if (!GameManager.Instance.SequenceCount.Contains(SequenceOfClicks[i].SequenceNumber))
                            {
                                Debug.Log("<color=cyan>!GameManager.Instance.SequenceCount.Contains(SequenceOfClicks[i].SequenceNumber)</color>");
                                GameManager.Instance.SequenceCount.Add(SequenceOfClicks[i].SequenceNumber);
                                if (GameManager.Instance.SequenceCount.Count >= GameManager.Instance.MaxSequence)
                                {
                                    Debug.Log("GameManager.Instance.SequenceCount.Count >= GameManager.Instance.MaxSequence");
                                    properClicked = 1;
                                    properTimed   = 1;
                                    break;
                                }
                                else
                                {
                                    return;
                                }
                            }
                            else
                            {
                                Debug.Log("Something wrong. More than 1 click on the same sequence number when sequence is to be ignored");
                            }
                        }
                    }
                    else
                    {
                        for (int i = 0; i < SequenceOfClicks.Count; i++)
                        {
                            if (GameManager.Instance.SequenceOfClick.SequenceNumber == SequenceOfClicks[i].SequenceNumber)
                            {
                                if (question.IgnoreClickCount)
                                {
                                    Debug.Log("question.IgnoreClickCount");
                                    //ignore click count
                                    properClicked = 1;
                                }
                                else
                                {
                                    if (GameManager.Instance.SequenceOfClick.RequiredClicks == ClickCounter)
                                    {
                                        Debug.Log("==");
                                        properClicked = 1;
                                    }
                                    else if (GameManager.Instance.SequenceOfClick.RequiredClicks < ClickCounter)
                                    {
                                        Debug.Log("<");
                                        properClicked = 0;
                                    }
                                    else if (GameManager.Instance.SequenceOfClick.RequiredClicks > ClickCounter)
                                    {
                                        Debug.Log("RequiredClicks = " + GameManager.Instance.SequenceOfClick.RequiredClicks + " and ClickCounter = " + ClickCounter);
                                        Debug.Log(">");
                                        properClicked = 0;
                                        //Keep clicking.
                                        return;
                                    }
                                }

                                if (question.IgnoreClickTime)
                                {
                                    properTimed = 1;
                                }
                                else
                                {
                                    if (GameManager.Instance.SequenceOfClick.ClickOnTime >= GameManager.Instance.timerInt)
                                    {
                                        properTimed = 1;
                                    }
                                    else if (GameManager.Instance.SequenceOfClick.ClickOnTime < GameManager.Instance.timerInt)
                                    {
                                        properTimed = 0;
                                    }
                                }
                            }
                        }
                    }

                    if (properTimed + properClicked == (byte)2)
                    {
                        if (question.CountSequenceIgnoreValue)
                        {
                            GameManager.Instance.AnsweredCorrectly();
                        }
                        else
                        {
                            if (GameManager.Instance.SequenceOfClick.SequenceNumber == GameManager.Instance.MaxSequence)
                            {
                                GameManager.Instance.AnsweredCorrectly();
                            }
                            else
                            {
                                GameManager.Instance.IncreaseSequenceNumber();
                            }
                        }
                    }
                    else
                    {
                        Debug.Log("properTimed = " + properTimed);
                        Debug.Log("properClicked = " + properClicked);

                        Debug.Log("Sequence Wrong");
                        GameManager.Instance.AnsweredWrongly();
                    }
                }
            }
        }
    }
Ejemplo n.º 16
0
        private BaseQuestion CreateBaseQuestion(int questionIndex)
        {
            Random r = new Random();

            BaseQuestion baseQuestion = new BaseQuestion();

            baseQuestion.Question = "Question " + questionIndex + Guid.NewGuid().ToString().Substring(0, 4);
            baseQuestion.Index = questionIndex + 1;
            baseQuestion.Value = Convert.ToDecimal(r.Next(1, 3));
            baseQuestion.Tip = "Dica...";

            return baseQuestion;
        }
Ejemplo n.º 17
0
 public virtual void SetQuestion(BaseQuestion info, Action <int, int, bool, List <SequenceOfClick> > Answered)
 {
     this.info = info;
     this.CorrectlyAnswered = Answered;
     this.WronglyAnswered   = Answered;
 }